Home » Other » Client Tools » I am perplexed on how to do this...pls help...
I am perplexed on how to do this...pls help... [message #38633] Wed, 01 May 2002 17:47 Go to next message
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 &#124 2000/01/22 19:31:39
7000 &#124 2001/01/22 19:31:39
7000 &#124 2001/02/22 19:31:39
3000 &#124 2001/03/22 19:31:39
5000 &#124 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___&#124___Jan_Sales&#124___Feb_Sales Mar_Sales ..... Dec
2000___&#124________8000__
2001___&#124________7000__&#124_______7000________3000
2002___&#124________________&#124_______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 Go to previous message
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
Previous Topic: Why doesn't this work ?
Next Topic: set escape ON in Stored Proc
Goto Forum:
  


Current Time: Fri Mar 29 02:16:22 CDT 2024