Please imagine the following tables:
Invoices
|Invoice ID | Invoice Date |
---------------------------------
|1 | 01-11-12 |
|2 | 01-11-12 |
Services
|Service ID | Service Date | Invoice ID |
-------------------------------------------------
|1 | 01-11-12 | 1 |
|2 | 01-11-12 | 1 |
|3 | 02-11-12 | 1 |
|4 | 03-11-12 | 1 |
I would like to return a dataset like so:
|Invoice ID | Invoice Date | Service ID | Transformed Service Date | Real Service Date |
--------------------------------------------------------------------------------------------------------
|1 | 01-11-12 | 1 | 01-11-12 | 01-11-12 |
|1 | 01-11-12 | 2 | 01-11-12 | 01-11-12 |
|1 | 01-11-12 | 3 | 01-11-12 | 02-11-12 |
|1 | 01-11-12 | 4 | 01-11-12 | 03-11-12 |
|1 | 01-11-12 | 1 | 02-11-12 | 01-11-12 |
|1 | 01-11-12 | 2 | 02-11-12 | 01-11-12 |
|1 | 01-11-12 | 3 | 02-11-12 | 02-11-12 |
|1 | 01-11-12 | 4 | 02-11-12 | 03-11-12 |
|1 | 01-11-12 | 1 | 03-11-12 | 01-11-12 |
|1 | 01-11-12 | 2 | 03-11-12 | 01-11-12 |
|1 | 01-11-12 | 3 | 03-11-12 | 02-11-12 |
|1 | 01-11-12 | 4 | 03-11-12 | 03-11-12 |
Please notice how all services get returned for each service date. I hope this is possible. I am using this query to help with grouping in SQL Server reports.
Thank you for your kind help.
1 Answer