Ok, I have two tables, a customer table and a product sales table. Here is the relavent info:
Customers
-CustomerID
-CustomerName
-IsActive
ProductSales
-CustomerID
-ProductName
-DateSold
Here is what I need. It needs to be done in one query. I need a list of customers who are active and have the last product sold (if any) attached to their record. How do I do this?
Example:
Customers
1000,Todd,Yes
1001,Nick,No
1002,Tim,Yes
ProductsSales
1000,Product1,1/1/2005
1000,Product2,4/1/2005
The query would then output this info:
1000,Todd,Yes,Product2,4/1/2005
1002,Tim,Yes,NULL,NULL
This is not a school assignment or anything, I need to do this at work. I am very proficient with SQL but this one is stumping me!
Any help is greatly appreciated.
Nick
Customers
-CustomerID
-CustomerName
-IsActive
ProductSales
-CustomerID
-ProductName
-DateSold
Here is what I need. It needs to be done in one query. I need a list of customers who are active and have the last product sold (if any) attached to their record. How do I do this?
Example:
Customers
1000,Todd,Yes
1001,Nick,No
1002,Tim,Yes
ProductsSales
1000,Product1,1/1/2005
1000,Product2,4/1/2005
The query would then output this info:
1000,Todd,Yes,Product2,4/1/2005
1002,Tim,Yes,NULL,NULL
This is not a school assignment or anything, I need to do this at work. I am very proficient with SQL but this one is stumping me!
Any help is greatly appreciated.
Nick