Preguntas más respondidas.
Q&A about the site for science fiction and fantasy enthusiasts
/*En vez de 2016 y 9, debería ser la fecha del sistema.*/ /* o de no ser posible, en cero*/ DECLARE @ultimo_anio int = CONVERT(INT,format(CURRENT_TIMESTAMP,'yyyy')); DECLARE @ultimo_mes int = CONVERT(INT,format(CURRENT_TIMESTAMP, 'MM')); DECLARE @anio int = ##Anno?@ultimo_anio##; DECLARE @mes int = ##Mes?@ultimo_mes##; SELECT @mes = CASE WHEN @mes=1 THEN 13 ELSE @mes END; SELECT @anio = CASE WHEN @mes=13 THEN @anio-1 ELSE @anio END; SELECT @mes = CASE WHEN @mes=13 THEN 13 ELSE @mes END; WITH Answers AS ( SELECT ParentId AS Id, max(Score) AS Score FROM Posts WHERE PostTypeId = 2 GROUP BY ParentId ) SELECT TOP 100 format(Q.CreationDate,'dd/MM/yy') "Creación", /*@anio_actual "Creación",*/ CONCAT('site://q/',Q.Id,'|',Q.Title) Pregunta, Q.AnswerCount "Cantidad de Respuestas", Q.Score "Puntaje de Pregunta", A.Score "Puntaje de Mejor Respuesta" FROM Posts Q LEFT OUTER JOIN Answers A ON Q.Id = A.Id WHERE 1=1 and Q.CreationDate >= CONCAT(@anio,'/',@mes-1,'/1') and Q.CreationDate < CONCAT(@anio,'/',@mes+0,'/1') ORDER BY 3 DESC, 5 DESC, 4 DESC, 1 DESC, Q.Title ASC ;