Home » SQL & PL/SQL » SQL & PL/SQL » Grouping the Columns (Oracle, 9i, XP)
icon3.gif  Grouping the Columns [message #379299] Tue, 06 January 2009 00:06 Go to next message
sri4oracle
Messages: 2
Registered: January 2009
Junior Member
Hi All,

Any body will explain on grouping function. For Example i have a product table P1 (Prdo_name, Prod_cost_fcy, Prod_date, Prod_cost_inr).

from this table how i can get the sum of Prod_cost_fcy, Prod_cost_inr by month wise.

required output:

Month Prod_cost_fcy Prod_cost_inr
~~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
JAN XXXXX.XX XXXXX.XX
FEB XXXXX.XX XXXXX.XX
MAR XXXXX.XX XXXXX.XX
APR XXXXX.XX XXXXX.XX

Total: XXXXXXX.XX XXXXXXXX.XX



Regards,
Ravikumar
Re: Grouping the Columns [message #379309 is a reply to message #379299] Tue, 06 January 2009 00:42 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Do it in steps:
- How would you reduce each date column to only the month (and maybe also the year)?
- Then group by that function

Try it, and if you are stuck, come back. Show us what you tried (preferrably with a copy-paste from sqlplus) and we will help you further.

Good luck!
Re: Grouping the Columns [message #379311 is a reply to message #379299] Tue, 06 January 2009 00:50 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
And before posting code or result, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: Need Query??
Next Topic: Need of Table space
Goto Forum:
  


Current Time: Sun Dec 04 08:33:50 CST 2016

Total time taken to generate the page: 0.21261 seconds