Aggregating Year, Month and Week to date
531441Sep 13 2010 — edited Sep 13 2010Good day,
I have a requirement that has led me thinking where I have to sum up sales value at three levels - year_to_date, month_to_date and week_to_date. While it is easy for me to represent the yearly and monthly version, I need to do a bit of logic to get the weekly variant.
The definitions of the functions are thus
year_to_date: Sum up the sales record from the january 1 to sysdate
month_to_date: sum up all sales record from 1 of the current month to sysdate
week_to_date: sum up all sales record from 12:00 am monday of the current week to sysdate
Is are they any such oracle sql functions to achieve this? I have googled and also search the oracle 10g R2 sql reference and could not find what I was looking for? Does anyone know of web reference where I could find a likely solution.
table definition
=============
id number(6)
trans_date date
sales_value number(15, 4)
receipt_no varchar2(20)
thanks