嗨我有一個查詢,目前正在返回我4行。返回1行而不是多行
SELECT (case when a.duedate < '2016-04-26' and a.total_paid > 0
then count(a.duedate)
else 0 end) as paidWithDelay,
(case when a.duedate < '2016-04-26' and a.total_paid = 0
then count(a.duedate)
else 0 end) as Overdue,
(case when a.duedate > '2016-04-26' and a.total_paid > 0
then count(a.duedate)
else 0 end) as paidOnTime,
(case when a.duedate > '2016-04-26' and a.total_paid = 0
then count(a.duedate)
else 0 end) as waitingForPayment
FROM payment_plan a
where a.payor_orig_id = 611 and a.UPDATE_DT is null
group by a.duedate;
喜歡此圖片。 基本上我想要的只是返回一行 像這樣 paidWithDelay 2 , overdue 1 , paidontime 0 and waitingForPayment 1 ,
我試過寫了總結前面的情況,但沒有工作。
這個工作,但我得到的總和(paidwithdelay),sum(逾期)列名稱,有沒有什麼辦法可以刪除? – FaF
編輯答案 立即檢查 – Priyanshu