SELECT t.TagName as Topic, COUNT(DISTINCT p.Id) as TotalQ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Skeptics

Q&A for scientific skepticism

SELECT 
    t.TagName as Topic, 
    COUNT(DISTINCT p.Id) as TotalQuestions, 
    SUM(p.ViewCount) as TotalViews, 
    AVG(CAST(p.Score AS FLOAT)) as AvgScore
FROM Posts p
LEFT JOIN PostTags pt ON p.Id = pt.PostId
LEFT JOIN Tags t ON pt.TagId = t.Id
LEFT JOIN Users u ON p.OwnerUserId = u.Id
WHERE u.Location LIKE '%USA%' OR u.Location LIKE '%United States%'
  AND t.TagName IN ('trains', 'railways', 'public-transport', 'metro', 'bus', 'subway')
  AND p.PostTypeId = 1 -- Questions only
GROUP BY t.TagName
ORDER BY TotalQuestions DESC;

Enter Parameters

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