3つのクエリを1つにまとめようとしていますが、同じ結果を1つのテーブルとして作成しようとしています。 ColumnAとColumnBはどちらも実際には 'yyyy-mm-dd'の日付形式になっています。理想的には、最終結果は単に日付の列になり、各クエリから別々にカウントされます。 UNION ALL
と列ごとに条件を指定して集計します。
select columnA, count(*)
from data.table
where timestamp between '2017-01-01' and '2017-01-07'
group by columnA
select columnB, count(*)
from data.table
where timestamp between '2017-01-01' and '2017-01-07'
group by columnB
select columnB, count(distinct columnC)
from data.table
where timestamp between '2017-01-01' and '2017-01-07'
and columnX in ('itemA','ItemB')
group by columnB
'UNION ALL'の教科書ユースケースに似ています –
私はゴードンがよく理解していると思いますが、 –