I am trying to put together a query that summarises a month worth of items in a detail table and I'm struggling a bit. Basically what I want to have at the end is:
Item 1 - 15 - £10
Item 2 - 1 - £12
Covers deliveries 1232, 1234, 502. Dates 01/01/2000, 01/02/2000, 01/02/2000
The item rows are easy, but I'm not sure how to put together that final row. Tables being worked with are something like this:
Summary Table:
ID
Total
Date
Detail Table:
ID
SummaryID
DeliveryNumber
DeliveryDate
I can do a simple select to return all detail rows required (SELECT [DeliveryNumber], [DeliveryDate] FROM [DetailTable] WHERE [SummaryID] = @SummaryID) but I need to get this into a single row and formatted as closely as I can to the sample above.
Any solutions?
Start Free Trial