DECLARE @From_Date DATETIME = convert(DATETIME, '##StartD...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Portuguese Language

Q&A for linguists, teachers and learners wanting to discuss the finer points of the Portuguese language

DECLARE @From_Date DATETIME = convert(DATETIME, '##StartDate?2006/01/01##')
DECLARE @To_Date DATETIME = dateadd(mm, 200, @From_Date)

PRINT 'from ' + format(@From_Date, 'D') + ' to ' + format(@To_Date, 'D')

SELECT TOP 100 Posts.id AS [Post Link],
    users.id AS [User Link],
    Posts.CreationDate,
    Posts.Score AS [Question Score],
    max(Answer.Score) AS [max Answer Score],
    Posts.ViewCount,
    Posts.FavoriteCount
FROM Posts
INNER JOIN users
    ON Posts.OwnerUserId = users.id
LEFT JOIN Posts AS Answer
    ON Answer.parentid = Posts.id
        AND Answer.posttypeid = 2
WHERE Posts.ClosedDate IS NULL
    AND Posts.posttypeid = 1
    AND Posts.CreationDate BETWEEN @From_Date
        AND @To_Date
GROUP BY Posts.Id,
    users.id,
    Posts.CreationDate,
    Posts.Score,
    Posts.ViewCount,
    Posts.FavoriteCount
ORDER BY Posts.score DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results