Suppose I have table with sales information for different stores that sell fruit, like this:
| Store | Fruit | Sale |
|---|---|---|
| One | apples | 2 |
| Two | oranges | 5 |
| One | pears | 3 |
| Three | apples | 2 |
| One | oranges | 3 |
| Three | apples | 4 |
| Two | apples | 1 |
| One | pears | 5 |
Is there a way to write SQL query, that would return table with sum of each fruits sold for each store, something like:
| Store | apples | oranges | pears |
|---|---|---|---|
| One | 2 | 3 | 8 |
| Two | 1 | 5 | 0 |
| Three | 6 | 0 | 0 |
Or must I run 3 different queries, one for each store? Thanks.