i have the following tables

client
-----
id
name

purchases
---------
p_id
c_id
date
...

i want to select all purchases for all clients where their last purchase was before date X.

For example:
Consider client 1, 2, 3 and 4.
client 1 made 20 purchases before time X and just one recent purchase.
Client 2 made 1000 purchases before time X
Client 3 made only 1 purchase before time X
Client 4 made only 1 purchase recently.

The query should select "all" the purchases for client 2 and 4 only.

first who writes the correct query gets the reward first.

more info: http://www.besthostingforums.com/sho...2&postcount=10

How the query works:
we should select the MAX dat for each site and see if its maximum date entry is older than a year from now.
if so we select all its rows. if not, we don't select any of its rows.

solution: http://www.besthostingforums.com/sho...4&postcount=12
tdsii Reviewed by tdsii on . mysql query help ($5 reward) i have the following tables client ----- id name purchases --------- p_id Rating: 5