If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > select a rolling 12 full months

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-17-12, 20:59
numberscub numberscub is offline
Registered User
 
Join Date: Jan 2012
Posts: 6
select a rolling 12 full months

Can anyone help me with a query that selects a rolling twelve full months of data based on the date the query is run? For example - if I ran the query today I would just pull data for calendar year 2011, but if I ran it february 17th, then it would pull Feb 2011 thru Jan 2012?
Reply With Quote
  #2 (permalink)  
Old 01-17-12, 21:22
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
OraFAQ Forum: General » Puzzle n°00 - Row generator *

Hopefully, you can modify code in URL above to meet your specific requirements
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #3 (permalink)  
Old 01-18-12, 15:44
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,222
select column1
from my_table
where date_column between add_months(trunc(sysdate,'MONTH'),-12) AND trunc(sysdate,'MONTH');
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On