Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > Find payments before a specific date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-20-07, 04:39
tsiger tsiger is offline
Registered User
 
Join Date: Sep 2007
Posts: 2
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?
Reply With Quote
  #2 (permalink)  
Old 09-20-07, 05:11
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
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.
Reply With Quote
  #3 (permalink)  
Old 09-20-07, 05:33
tsiger tsiger is offline
Registered User
 
Join Date: Sep 2007
Posts: 2
yes this seems to work just fine thank you
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On