Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
schonne
Starting Member
3 Posts |
Posted - 2007-06-13 : 01:25:54
|
| Hi guys!I need help. I have two tables (customers & orders). I want to build a query that lists all the customers who haven't placed an order in over a year. Below are the simplified tables (i've removed other fields that I don't think are relevant to this query). Do I need to do a subquery or something? Please help!TABLES:CUSTOMERScustid (unique autonumber)ORDERScustid (int)orderdate (date) |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-13 : 02:34:29
|
| you can do in different ways...using sub querySelect id, name from @t where id not in(Select id from @c where ord_date > dateadd(month, -12, getdate()))--------------------------------------------------S.Ahamed |
 |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-13 : 02:37:43
|
| if u want to eliminate time partdateadd(day, 0,datediff(day,0, dateadd(month, -12, getdate())))--------------------------------------------------S.Ahamed |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|