• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 568
  • Last Modified:

Maximum value populated in a date column for each of last 5 months

I have a column "business_date" of date datatype inside my table. Data is uploaded almost daily into that table.

I want to write a query to find the maximum value populated in this column for every month for the last 5 months.

How can I do this?
0
sunny82
Asked:
sunny82
1 Solution
 
gatorvipCommented:
I want to write a query to find the maximum value populated in this column

Do you mean the maximum value in business_date? That seems rather odd, but this should work:

select max(business_date), trunc(business_date, 'MM')
from <your_table>
where business_date >= add_months( trunc(business_date, 'MM') , -5)
group by trunc(business_date, 'MM')
0
 
sunny82Author Commented:
Great, thanks.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now