Tasa de Respuestas Efectivas (altos votos o aceptadas) java

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans Meta

Q&A about the site for music historians, critics, and fans

-- Tasa de Respuestas Efectivas (altos votos o aceptadas)
DECLARE @TagName NVARCHAR(100) = 'java'
DECLARE @MinVotos INT = 5 -- Define el umbral de "altos votos"

SELECT 
    COUNT(DISTINCT p.Id) AS TotalPreguntas,
    AVG(DATEDIFF(MINUTE, p.CreationDate, a.CreationDate)) AS PromedioTiempoRespuestaMinutos,
    AVG(p.Score) AS PromedioVotosPregunta,
    AVG(a.Score) AS PromedioVotosRespuesta,
    COUNT(DISTINCT a.Id) AS TotalRespuestas,
    COUNT(CASE WHEN p.AcceptedAnswerId IS NOT NULL THEN 1 END) AS TotalRespuestasAceptadas,
    ROUND((COUNT(CASE WHEN p.AcceptedAnswerId IS NOT NULL THEN 1 END) * 100.0) / COUNT(p.Id), 2) AS PorcentajeRespuestasAceptadas
FROM 
    Posts p
JOIN 
    PostTags pt ON p.Id = pt.PostId
JOIN 
    Tags t ON t.Id = pt.TagId
LEFT JOIN 
    Posts a ON a.ParentId = p.Id AND a.PostTypeId = 2 -- Respuestas
WHERE 
    t.TagName = @TagName
    AND p.PostTypeId = 1 -- Preguntas

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results