How to get weekly summarized data

Database

How to get weekly summarized data

Guys,
I'm trying to get the sales data summarized weekly(of course with simple sql query)
Can any guys give some good reference?
(Table columns are date, sales, price sold at for eacy day)
1 REPLY

Re: How to get weekly summarized data

Do you have a Fiscal Calendar table to join with your base table? If not, Join your base table with SYS_CALENDAR.CALENDAR table to get the week_of_Calendar field for each DATE in your table. Now having the week numbers in your result set , use the sum function and group by week_of_calendar.

Something like this:

Select A.Week_No, SUM( A.sales_Amt)
From ( Select Date As Sales_Date,
Sales As Sales_Amt,
Price As Price,
Week_of_Calendar As Week_No
From your_table, SYS_CALENDAR.CALENDAR
Where your_table.Date=SYS_CALENDAR.CALENDAR.Calendar_Date ) A
Group By 1