我想將三個單獨的查詢合併爲一個,並且仍然產生相同的結果,但是作爲單個表。 ColumnA和ColumnB實際上都是'yyyy-mm-dd'的日期格式,理想情況下最終結果只是日期列和每個查詢的單獨計數。基於單獨的組列和條件計數
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
看起來像一個教科書用例'聯盟所有' –
雖然在反思我認爲戈登已經更好地理解。 –