Max function

  • Hi! Please help

    I have a table with bi-annual ratings for staff, I want to select only the latest ratings for staff. My query is returning duplicates. here's what I wrote

    select distinct(SNO), rating, Max(RATING_MONTH) as RatingMonth

    from PI_All

    Group by SNO, Rating

    Please help

  • Is this what you're after?

    SELECT SNO, Rating, Rating_Month as RatingMonth

    FROM PI_ALL

    WHERE Rating_Month = (SELECT MAX(Rating_Month) FROM PI_ALL)

    GROUP BY SNO, Rating, Rating_Month

  • Thank you it is what I wanted.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply