-
help on this sql query.
I have this table with this result when i query. The table has two column: orderdate and total_order.
orderdate total_order
Jan/27/1987 12000.00
Jan/04/1987 17000.00
Mar/01/1987 18000.00
Mar/21/1987 15000.00
May/11/1987 52000.00
May/03/1987 12700.00
Feb/12/1987 12000.00
Feb/24/1987 12000.00
Now I need to write an aggregate select statement that groups each month's total in one Grand Total. And the result should gives me:
orderdate total_order
Jan/27/1987 12000.00
Feb/04/1987 17000.00
Mar/01/1987 18000.00
May/21/1987 15000.00
Please help, I am a new to oracle Business....
xuduro_2000
-
You sure that you don't want ...
Jan/01/1987 12000.00
Feb/01/1987 17000.00
Mar/01/1987 18000.00
May/01/1987 15000.00
... ? That would just be ...
Code:
Select
Trunc(orderdate,'MM'),
Sum(total_order)
From
my_table
Group By
Trunc(orderdate,'MM');
The logic behind the selection of day numbers is not clear from your example. Some of them don't appear in your source data.
-
ATTN: SLIMDAVE.
Hey Slimdave, you are a pro--I mean one of the best Tech support I have run into.
To answer your concerns that about the day selection, The day selections are not Hypothetical day. I was in a hurry so I made them up, but the months are real. My problem was to sum the Three Months with sales total into a one group each (Jan,Feb,Mar and May), And you have answered that for me. I never thought about the (TRUNC function).
I am sorry to mislead you, but that was My Problem and you answered.
what a expert........that is why I always come to this SITE......
xuduro_2000
-
Sorry for the Typo..The day selections are not Hypothetical day.
I mean The day selections are Hypothetical days.
xuduro_2000
-
Re: ATTN: SLIMDAVE.
Originally posted by xuduro
Hey Slimdave, you are a pro--I mean one of the best Tech support I have run into.
Didn't you read the sign about no feeding the egos.
Sheesh,
- Chris
-
Re: Re: ATTN: SLIMDAVE.
Originally posted by chrisrlong
Didn't you read the sign about no feeding the egos.
Sheesh,
- Chris
Don't listen to Chris -- keep it coming.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|