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

Posted on 2012-09-10
Last Modified: 2012-09-10
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?
Question by:sunny82
    LVL 20

    Accepted Solution

    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')

    Author Comment

    Great, thanks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
    I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
    This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
    This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now