spiff2002
IS-IT--Management
- Jan 31, 2003
- 40
Hi all
I am trying to group sales by month creating new columns by month.
Right now if I run my query like this
Select period,brand,division,sum(cases) as cases
From sales_table
group by period,brand,division
order by brand,period,division
and the result is
period brand division cases
2004-01 brand1 northern 200
2004-01 brand1 southern 356
2004-02 brand1 northern 345
2004-02 brand1 southern 334
2004-03 brand1 northern 234
2004-03 brand1 southern 543
2004-01 brand2 northern 456
2004-01 brand2 southern 213
2004-02 brand2 northern 890
2004-02 brand2 southern 98
2004-03 brand2 northern 345
2004-03 brand2 southern 789
I'm looking a result more like
brand division 2004-01 2004-02 2004-03
brand1 northern 200 345 234
brand1 southern 356 334 543
brand2 northern 456 890 345
brand2 southern 213 98 789
is this possible with a simple query??
Thanks in advance
I am trying to group sales by month creating new columns by month.
Right now if I run my query like this
Select period,brand,division,sum(cases) as cases
From sales_table
group by period,brand,division
order by brand,period,division
and the result is
period brand division cases
2004-01 brand1 northern 200
2004-01 brand1 southern 356
2004-02 brand1 northern 345
2004-02 brand1 southern 334
2004-03 brand1 northern 234
2004-03 brand1 southern 543
2004-01 brand2 northern 456
2004-01 brand2 southern 213
2004-02 brand2 northern 890
2004-02 brand2 southern 98
2004-03 brand2 northern 345
2004-03 brand2 southern 789
I'm looking a result more like
brand division 2004-01 2004-02 2004-03
brand1 northern 200 345 234
brand1 southern 356 334 543
brand2 northern 456 890 345
brand2 southern 213 98 789
is this possible with a simple query??
Thanks in advance