繁体   English   中英

每天计算每个状态为 CANCELED 的事务

[英]Count the transactions from each with the status CANCELLED per day

| id | status    | Transaction date    | Vendor    | Customer ID          |
|  1 | Completed | 2019-11-15 11:46:11 | Vendor A  | 12345                |
|  2 | Completed | 2019-11-14 23:03:24 | Vendor B  | 67891                |
|  3 | Completed | 2019-11-15 12:04:13 | Vendor C  | 456                  |
|  4 | Cancelled | 2019-11-14 11:46:11 | Vendor A  | 22225                |
|  5 | Cancelled | 2019-11-20 23:03:24 | Vendor B  | 789999               |
|  6 | Cancelled | 2019-11-20 12:04:13 | Vendor C  | 789999               |

你能帮我计算每个供应商的交易,状态为每天取消吗? 我正在尝试但失败了

EXPECTATION

Transaction date    | Vendor    | TOTAL TRANSACTION
2019-11-14          | Vendor A  | 1
2019-11-20          | Vendor B  | 1
2019-11-20          | Vendor C  | 1

似乎您想要以下内容,这不是您所要求的。 这是一个简单的GROUP BY

SELECT date(transaction_date), vendor, count(*)
FROM table
WHERE status = 'Cancelled'
GROUP BY transaction_date, vendor

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM