Take a report for the customers recent 2 purchase details

Posted by Jeena under C# on 7/10/2012 | Points: 10 | Views : 529 | Status : [Member] | Replies : 1
Hi All

I have 2 tables one master table and a child table
Master table will be having one unique entry for a customer and child tables will be keeping there purchase details.For ex

Customer ID Customer name Customer address

1 Jacob XXXXXXXX
2 James NNNNNNN



PurchaseID Customer ID Purchase Date Details


1 1 07/10/2012 YYYYYY

2 1 07/09/2012 YYYYYY

3 1 06/10/2012 YYYYYY

4 1 06/01/2012 YYYYYY

5 2 07/10/2011 YYYYYY

6 2 07/09/2012 YYYYYY

7 2 06/10/2012 YYYYYY

8 2 06/01/2012 YYYYYY


I need to take a report for the customers recent 3 purchase details as follows

What is the best option ?


Customer ID Customer name Customer address Purchase Date1 Details1 Purchase Date2 Details2

1 Jacob XXXXXXXX 07/10/2012 YYYYYY 07/09/2012 YYYYYY
2 James NNNNNNN 07/09/2012 YYYYYY 06/10/2012 YYYYYY

Thanks




Responses

Posted by: Ranjeet_8 on: 7/10/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
SELECT     dbo.Master_Table.Customer_ID, dbo.Master_Table.Customer_name, dbo.Master_Table.Customer_address, dbo.Child_Table.PurchaseID, 

dbo.Child_Table.Purchase_Date, dbo.Child_Table.Details
FROM dbo.Child_Table INNER JOIN
dbo.Master_Table ON dbo.Child_Table.Customer_ID = dbo.Master_Table.Customer_ID


Jeena, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response