Writing a SQL query for an Oracle table

1152330 pts.
Tags:
Oracle Table
SQL Query
We have this data in an Oracle table (here it is below):
MONTH VALUE

1     100
2     200
3     300
4     400
5     500
6     600
So we need to write a SQL query so the results are showing like this:
MONTH_JAN MONTH_FEB MONTH_MAR MONTH_APR MONTH_MAY MONTH_JUN
100       200       300       400       500       600
Any help would be appreciated.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Some more info could be needed to be sure, but something like this will probably do what you need:

SELECT SUM(DECODE(month,1,value,0)) month_jan,
        sum(DECODE(month,2,value,0)) month_feb,
        sum(DECODE(month,3,value,0)) month_mar,
        sum(DECODE(month,4,value,0)) month_apr,
        sum(DECODE(month,5,value,0)) month_may,
        sum(DECODE(month,6,value,0)) month_jun
FROM your_table;   


Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: