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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I do this Query

Status
Not open for further replies.
Joined
Mar 7, 2003
Messages
2
Location
US
Table Customer with
column Key
column DOB Format: 1962/06/23

Table Retirement with column
column Key
column Age Ex:65

I need a query to list all customer's retiring on a date range.

Select * from Customer,Retirement where Customer.Key = Retirement.Key AND ??????
 
Select * from Customer,Retirement where Customer.Key = Retirement.Key AND Retirement.Age between DATEDIFF ( 'yyyy', Customer.DOB , startdate ) and DATEDIFF ( 'yyyy', Customer.DOB, enddate )




 
This should get you a list of Customer who retire in next 30 days:

Select * from Customer C join Retirement R
on C.iKey = R.iKey
where R.Age * 12 between DateDiff(month,DOB,GetDate())
and DateDiff(month,DOB,DateAdd(day,30,GetDate()))

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top