I'm using MySql 5.5.38 and got a following table (this is just a snippet, real one contains ~500 products):
+------+-------+----------+-------+--------+
| id | date | product | type | sales |
+------+-------+----------+-------+--------+
| 4513 | 14958 | XXXXXXX | 1 | 3 |
| 4514 | 14958 | XXXXXXX | 2 | 5 |
| 4519 | 14958 | YYYYYYY | 1 | 10 |
| 4531 | 14958 | YYYYYYY | 3 | 150 |
| 4534 | 14959 | ZZZZZZZ | 1 | 5 |
| 4536 | 14959 | ZZZZZZZ | 2 | 5 |
|+------+-------+----------+-------+--------+
from which I need to generate daily sales volume by product:
+-------+----------+----------+----------+
| date | XXXXXXX | YYYYYYY | ZZZZZZZ |
+-------+----------+----------+----------+
| 14958 | 8 | 110 | 0 |
+-------+----------+----------+----------+
| 14959 | 0 | 0 | 10 |
|+------+----------+----------+----------+
The result table has to look exactly like above - with products in columns and days in row.
Just looking for some pointers, not a working solution. Thanks, Pawel.