|
ahaile
Starting Member
25 Posts |
Posted - 2010-02-17 : 09:23:34
|
| I need to sum the below daily total to weekly with the week starting day of Saturday Jan 3 2009 for the 52 weeks in 2009. The below query provides me the weekly total with the week starting day MONDAY. But I need the week starting day to be SATURDAY instead of MONDAY.select to_char(report_date, 'YYYYIW'), sum(total)from report_tablewhere to_number(to_char(report_date,'YYYYIW')) >= to_number(to_char(to_date( '&one_year_ago'),'YYYYIW'))group by to_char(report_date, 'YYYYIW')Here is a query I used to generate the Daily Sample Data: SELECT DISTINCT A.PRODUCT, TO_CHAR(B.BEGIN_DT,'YYYY-MM-DD') as post_date,'RCSL', A.DEPTID, A.ACCOUNT, SUM( A.POSTED_TOTAL_AMT) as Amount_Posted FROM A, B, C AND B.BEGIN_DT BETWEEN TO_DATE('&StartDate','YYYY-MM-DD') AND TO_DATE('&EndDate','YYYY-MM-DD')GROUP BY A.PRODUCT, TO_CHAR(B.BEGIN_DT,'YYYY-MM-DD'), A.DEPTID, A.ACCOUNT For the below sample data I would need to add data starting 2010-01-02 - 2010-01-08 to get my weekly total.7777,2010-01-01,RCSL,0170,331062,-857777,2010-01-02,RCSL,0170,331063,-1907777,2010-01-03,RCSL,0170,341413,170.187777,2010-01-04,RCSL,0170,347103,-8807777,2010-01-05,RCSL,0172,331050,-1167777,2010-01-06,RCSL,0172,331053,-507777,2010-01-07,RCSL,0172,331061,-637777,2010-01-08,RCSL,0172,331061,-63Any assistant or direction is greatly appreciated.Thanks, |
|