我有这个提取形式的查询即时写作。 我想要做的只是总结成功的付款
的内容, SUM(CASE WHEN (LOWER(result) = 'successful') THEN (SUM(amount) as amt_paid) ELSE 0 END) AS Successful_Payed
这是查询摘录。
Select
resultdate
, SUM(amount) as amt_paid
, SUM(CASE WHEN (LOWER(result) = 'successful') THEN 1 ELSE 0 END) AS Successful
, SUM(CASE WHEN (LOWER(result) = 'unsuccessful') THEN 1 ELSE 0 END) AS Unsuccessful
, SUM(CASE WHEN (LOWER(result) = 'tracking') THEN 1 ELSE 0 END) AS Tracking
, SUM(CASE WHEN (LOWER(result) = 'dispute') THEN 1 ELSE 0 END) AS Dispute
From paysoft_results
Group By resultdate
Order By resultdate
答案 0 :(得分:0)
像这样改变
Select
resultdate
, SUM(CASE WHEN (LOWER(result) = 'successful') THEN amount ELSE 0 END) AS
Successful_Payed
, SUM(CASE WHEN (LOWER(result) = 'successful') THEN 1 ELSE 0 END) AS Successful
, SUM(CASE WHEN (LOWER(result) = 'unsuccessful') THEN 1 ELSE 0 END) AS Unsuccessful
, SUM(CASE WHEN (LOWER(result) = 'tracking') THEN 1 ELSE 0 END) AS Tracking
, SUM(CASE WHEN (LOWER(result) = 'dispute') THEN 1 ELSE 0 END) AS Dispute
From paysoft_results
Group By resultdate
Order By resultdate