Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8980629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:08:07+00:00 2026-06-15T20:08:07+00:00

Please imagine the following tables: Invoices |Invoice ID | Invoice Date | ——————————— |1

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:08:08+00:00Added an answer on June 15, 2026 at 8:08 pm
    DECLARE @Invoices TABLE (
    [Invoice ID] INT,
    [Invoice Date] DATE)
    
    DECLARE @Services TABLE (
    [Service ID] INT,
    [Service Date] DATE,
    [Invoice ID] INT)
    
    INSERT INTO @Invoices VALUES
    (1,'2012-11-01'),
    (2,'2012-11-01')
    
    INSERT INTO @Services VALUES
    (1,'2012-11-01',1),
    (2,'2012-11-01',1),
    (3,'2012-11-02',1),
    (4,'2012-11-03',1)
    
    ;WITH SERVICE_DATE_CTE
    AS
    (
        SELECT DISTINCT [Service Date] FROM @Services
    )
    SELECT 
        I.[Invoice ID],
        I.[Invoice Date],
        S.[Service ID],
        C.[Service Date] AS 'Transformed Service Date',
        S.[Service Date] AS 'Real Service Date'
    FROM @Invoices I
    INNER JOIN @Services S ON S.[Invoice ID] = I.[Invoice ID]
    CROSS JOIN SERVICE_DATE_CTE C ORDER BY C.[Service Date]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please imagine the following: I've this date in the Azores (GMT -1) 23/10/2010 23:00:00
Please imagine this small database... Diagram removed dead ImageShack link - volunteer database diagram
please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please look the following query: SELECT ID, START, END FROM TABLEA the result is:
Please, help me clear my mind on the following question. Recently I asked a
Please, consider the following piece of a typical VMWare configuration file (*.vmx): memsize =
I'm having trouble using the OutputCache attribute in Microsoft's MVC3 framework. Please imagine the
could you please point me, what is wrong with the following Xml file? <?xml
Anyone can help with this? Imagine the following: def example(s): s = s.replace('foo', 'foo
imagine I type the following code into the interpreter: var1 = 'zuuzuu' now suppose

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.