简体   繁体   中英

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               |

can you help me to count the transactions from each vendor with the status CANCELLED per day guys? i'm trying but failed

EXPECTATION

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

Seems that you want the following, which is not what you requested. This is a simple GROUP BY .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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