What would you group by? If you group by transdate, then the results are grouped by transdate rather than quarter, and the quarters would not be identified. If I'm not getting your point, please post a complete select statement that I can understand/test.
Thanks!
Here's my table:
SQL> desc mytable
Name Null? Type
----------------------------------------- -------- -----------
TRANSDATE DATE
TRANSPRICE NUMBER(6,2)
Oracle provides format model 'Q' for date-to-cahr and char_to_date conversion that we could use to get a quarter the date belongs to.
SELECT TO_CHAR(transdate,'YYYY') year, TO_CHAR(transdate,'Q') quarter, SUM(sales)
FROM sales_table
GROUP BY TO_CHAR(transdate,'YYYY'), TO_CHAR(transdate,'Q');
So there is no need to use DECODE....
Jurij Modic ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Bookmarks