I have a table for orders with two columns: shipping_id
that references a shipping method and packed
that keeps the date when the order has been packed.
+-------------+------------+
| shipping_id | packed |
+-------------+------------+
| 1 | 2017-05-07 |
| 1 | 2017-05-06 |
| 2 | 2017-05-06 |
| 2 | 2017-05-06 |
| 3 | 2017-05-05 |
+-------------+------------+
I need to somehow group the results by the date packed
, shipping types put as the columns and values of the cells be the counts of orders that has been packed that day and with that shipping method. Something like this:
+------------+---+---+---+
| date | 1 | 2 | 3 |
+------------+---+---+---+
| 2017-05-05 | 0 | 0 | 1 |
| 2017-05-06 | 1 | 2 | 0 |
| 2017-05-07 | 1 | 0 | 0 |
+------------+---+---+---+
Is this possible in MySQL? How would the SQL query look like?
Thank you