Home > Blockchain >  Count the transactions from each with the status CANCELLED per day
Count the transactions from each with the status CANCELLED per day

Time:01-30

| 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

CodePudding user response:

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
  •  Tags:  
  • Related