RE: help with a monthly rollup

From: Baumgartel, Paul <paul.baumgartel_at_credit-suisse.com>
Date: Tue, 13 May 2008 14:25:10 -0400
Message-ID: <21469B88E0EA11498818517F210335310455AE34@EPRI17P32001A.csfb.cs-group.com>


Use the LAST_DAY function. You can look it up in the SQL Reference manual.  

Paul Baumgartel
CREDIT SUISSE
Information Technology
Prime Services Databases Americas
One Madison Avenue
New York, NY 10010
USA
Phone 212.538.1143
paul.baumgartel_at_credit-suisse.com
www.credit-suisse.com  


From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Rick Ricky Sent: Tuesday, May 13, 2008 1:45 PM
To: oracle-l_at_freelists.org
Subject: help with a monthly rollup

I need to rollup data by month.

There are a couple ways to do this.

I have a date field. So I can rollup with a to_char(mydate,'YYYYMM') this requires a where clause as followings where to_char(mydate,'YYYYMM') = pSomeMonth;

This means I need a function based index to support this. We have alot of data, so where possible, I want to avoid adding more indexes. Is there a way to calculate what the last
day of the month is?

so I can use a between as follows
where myDate between to_date(01-MON-YYYY') and to_date(LASTDAYOFMONTH-MON-YYYY')

Since the last day of the month can be
28,29,30,31



Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html


--
http://www.freelists.org/webpage/oracle-l
Received on Tue May 13 2008 - 13:25:10 CDT

Original text of this message