我需要一個單一的查詢,這將給結果如我在下面給出選擇查詢輸出
createddate recordcount acceptdate submitdate createddate
27-MAR-16 24 36 11
28-MAR-16 79 207 58
參考我提供一些疑問,我想合併成一個單一查詢
select trim(date_created) createddate,count(*) recordcount
from man
where status IN ('CREATED')and date_created>sysdate-15
group by trim(date_created) ORDER BY TO_DATE(createddate,'DD/MM/YYYY');
此查詢的結果如下。此查詢的
createddate recordcount
27-MAR-16 11
28-MAR-16 58
第二查詢
select trim(DATE_SUB) submitdate,count(*) recordcount
from man
where status IN ('SUBMITTED')and DATE_SUB>sysdate-15
group by trim(date_sub) ORDER BY TO_DATE(submitdate,'DD/MM/YYYY');
結果就像
submitdate recordcount
27-MAR-16 36
28-MAR-16 207
和第三個查詢就像是 -
select trim(DATE_PUB) acceptdate,count(*) recordcount
from man
where status IN ('ACCEPTED')and DATE_PUB>sysdate-15
group by trim(DATE_PUB) ORDER BY TO_DATE(acceptdate,'DD/MM/YYYY');
acceptdate recordcount
27-MAR-16 24
28-MAR-16 79
我怎麼能合併這三種查詢,以便我可以統計所有單身查詢?這會給我造成像
createddate recordcount acceptdate submitdate createddate
27-MAR-16 24 36 11
28-MAR-16 79 207 58
我能看到的唯一區別是在第二個查詢中缺少「group by」。您能否添加一些幫助我們重現問題的示例數據? –
第一個查詢按'date_c'過濾,第二個按'date_p'過濾。他們可能會不同。 –