Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Unanswered: Find payments before a specific date

    I need some help with a query i am trying to build. I have a table which holds annual member subscriptions. The table is like this

    id | memberID | year | amount

    and a typical select will return data like that:

    1 | 001 | 1999 | 50
    2 | 001 | 2000 | 50
    3 | 001 | 2001 | 50
    4 | 002 | 2000 | 50
    5 | 002 | 2001 | 50
    6 | 003 | 2000 | 50
    7 | 003 | 2001 | 50

    what i want to get is all the members who haven't paid after 2002.
    Any ideas?

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I think something like the following should work:
    Code:
    SELECT memberID,MAX(year) 
    FROM <tablename> 
    GROUP BY memberID HAVING MAX(year) < 2003

    Edit : You don't need the MAX(year) in the select clause part of the statement.
    Last edited by aschk; 09-20-07 at 05:23.

  3. #3
    Join Date
    Sep 2007
    Posts
    2
    yes this seems to work just fine thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •