I am perplexed on how to do this...pls help... [message #38633] |
Wed, 01 May 2002 17:47 |
knenk
Messages: 2 Registered: May 2002
|
Junior Member |
|
|
Hi!
I am perplexed on how to do this...pls help...
Given the Table below
---------------------------------
Sales | Date_column
8000 | 2000/01/22 19:31:39
7000 | 2001/01/22 19:31:39
7000 | 2001/02/22 19:31:39
3000 | 2001/03/22 19:31:39
5000 | 2002/02/22 19:31:39
4002 | 2002/03/01 16:10:46
I want to create a query that will return something like this...
------------------------------------
Year___|___Jan_Sales|___Feb_Sales Mar_Sales ..... Dec
2000___|________8000__
2001___|________7000__|_______7000________3000
2002___|________________|_______5000________4002
Your help is very much appreciated...
Thanks....
-knenk
|
|
|
Re: I am perplexed on how to do this...pls help... [message #38636 is a reply to message #38633] |
Wed, 01 May 2002 21:03 |
Vikas Gupta
Messages: 115 Registered: February 2002
|
Senior Member |
|
|
You can use the decode function:
select to_char(date_column,"YYYY"),
sum(decode(to_char(date_column,"MM",1,sales,0) Jan,
sum(decode(to_char(date_column,"MM",2,sales,0) Feb,
sum(decode(to_char(date_column,"MM",3,sales,0) Mar,
....
from .....
Regards
|
|
|