oracle9i - How to Sum the Values from current date to previous year in oracle -


can body me solve this:

 value  date   1000   01-jan-12  ............  1000   01-apr-13 

my aim calculate sum of marks secured current month , year april-13 previous 1 year current month , year.

your example data shows more 1 year apr 2013.

assuming wanted go apr-2012

select sum(value)   your_tab  date >= add_months(trunc(sysdate, 'mm', -12) -- 1st apr 2012    , date < trunc(sydate, 'mm');-- anytime end of mar 2013 

if wanted go jan of prior year,

select sum(value)   your_tab  date >= trunc(add_months(trunc(sysdate, 'mm', -12), 'yy') -- 1st jan 2012    , date < add_months(trunc(sydate, 'mm'), 1); -- anytime end of apr 2013 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -