I have a problem I can't find a solution.
I have a table "SELLS" with all sells of a shop and I want to display how many sales for each product each day of a period.
For example :
| DATE | NAME | QTY |
|------------|----------|-----|
| 2014-07-03 | Coca | 1 |
| 2014-07-03 | Fanta | 1 |
| 2014-07-03 | Orangina | 5 |
| 2014-07-03 | Coca | 3 |
| 2014-07-04 | Coca | 2 |
| 2014-07-05 | Coca | 4 |
| 2014-07-05 | Fanta | 1 |
| 2014-07-05 | Juice | 2 |
The display i want is :
| NAME | TOTAL | 2014-07-03 | 2014-07-04 | 2014-07-05 |
|------------|--------|------------|-------------|-------------|
| Coca | 10 | 4 | 2 | 4 |
| Fanta | 2 | 1 | 0 | 1 |
| Orangina | 1 | 1 | 0 | 0 |
| Juice | 1 | 0 | 0 | 1 |
The user will specify the period he wants to display, so I have to use a BETWEEN function for date.
I try with PIVOT function, but I'm still not familiar using it
Edit : I'm using SQL Server 2012.
Thanks a lot for your help.