StackOverflowデータダンプで遊んでいます。今私はT-SQLの問題を抱えています:
1か月および1年あたりの質問数のリストを次のように選択できます。
select datepart(year, posts.creationdate) as year,
datepart(month, posts.creationdate) as month,
count(distinct posts.id) as questions
from posts
inner join posttags on posttags.postid = posts.id
inner join tags on tags.id = posttags.tagid
where posts.posttypeid = 1
group by datepart(month, posts.creationdate),
datepart(year, posts.creationdate)
order by datepart(year, posts.creationdate),
datepart(month, posts.creationdate)
-rowを追加するand tags.tagname = 'scala'
と、すべての「scala-questions」の数がわかります。WHERE
質問の総数と特定のタグを含む質問の数の両方を同じ結果セット(異なる列)に表示する方法はありますか?
追加するand tags.tagname = 'scala'
と、1か月あたりの質問の総数が表示されなくなるためです。
これらの結果セットを1つにまとめる方法について何かアイデアはありますか?