[英]Oracle group by client and date
我有一個有效的休閑查詢:
SELECT count(cand_id) as candidates, SB.client_id as client
FROM REPLIES r
JOIN clients sb on sb.main_acc_id = r.acc_id
where reply_dt >= TO_DATE('2021-02-08 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND reply_dt <= TO_DATE('2021-02-15 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
AND sb.status = 'A'
GROUP BY client_id
它產生如下結果:
Candidates| Clients
2 | client 1
4 | cleint 2
56 | client whatever..
我將如何 go 關於在給定日期范圍內按天和客戶細分候選人數量? 所以它會顯示當天,沒有候選人,客戶
這是做你想做的嗎?
SELECT TRUNC(r.reply_dt), sb.client_id, COUNT(cand_id) as candidates
FROM REPLIES r JOIN
clients sb
ON sb.main_acc_id = r.acc_id
WHERE sb.status = 'A'
GROUP BY TRUNC(r.reply_dt), client_id
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.