Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with sql syntax

Status
Not open for further replies.

h2mhd

Programmer
Feb 20, 2008
40
CA
hi

i have two tables

client:
idclient
name
adress
....

invoice
idinvoice
dateinvoice
idclient
...


what i want to do is make an sql that will give me all the clients that does not have an since 90 days and more

is there a simple way to do that, im a little bit rusted in these syntax.

tahnks a lot
 
Assuming that there may be multiple invoices for a client ...

If you just want the idclient field
Code:
Select I.idclient
From invoice As I
Group By I.idclient
Having MAX(I.dateinvoice) <= Date() - 90

If you want fields from the client table
Code:
Select C.idclient, C.Name, C.Adress

From client As C INNER JOIN 

(Select I.idclient
 From invoice As I
 Group By I.idclient
 Having MAX(I.dateinvoice) <= Date() - 90) As X

ON X.idclient = C.idclient
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top