For each customer-product pair, I need to calculate average sale of that product in each state.
Actual table ("sales" table):
cust  | prod  | state | quant
Bloom | Bread |  NY   | 1
Bloom | Butter|  NJ   | 2
.
.
.
My query:
SELECT cust, prod, state, AVG(quant)
from sales
group by cust, prod, state;
Result:
cust  | prod  | state | avg(quant)
Bloom | Bread |  NY   | 1
Bloom | Butter|  NJ   | 2
The result I want:
cust  | prod  |  NY  | NJ
Bloom | Bread |  1   | 2
