duetltd Posted May 1, 2010 Share Posted May 1, 2010 I need to create a list of customers that have not been called upon within a period of time. Customers: CusID Name etc. Calls: CusID Date Sales Rep etc. Is this possible using sql or should I just write a program to do this? Thank you for your help. Don Lareau Link to comment https://forums.phpfreaks.com/topic/200410-difficult-query/ Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 It's possible. Assuming the `Date` field is of a date type, you can use this example: This selects all customers that have not received calls in the past 30+ days. SELECT cu.Name, ca.CusID FROM Customers cu INNER JOIN Calls ca ON (cu.CusID = ca.CusID) WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) > ca.Date; Link to comment https://forums.phpfreaks.com/topic/200410-difficult-query/#findComment-1051696 Share on other sites More sharing options...
duetltd Posted May 2, 2010 Author Share Posted May 2, 2010 Thank you, however this excludes customers with no records in the detail file. Link to comment https://forums.phpfreaks.com/topic/200410-difficult-query/#findComment-1051705 Share on other sites More sharing options...
PFMaBiSmAd Posted May 2, 2010 Share Posted May 2, 2010 Use - LEFT JOIN Link to comment https://forums.phpfreaks.com/topic/200410-difficult-query/#findComment-1051707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.