Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team

I have two tables "Invoices and Customers" and each their have their own ID. Now how do I
write a SQL query to return a list of all the invoices. For each invoice, show the Invoice ID, the billing date, the customer’s name, and the name of the customer who referred that customer (if any). The list should be ordered by billing date.


What I have tried:

// Invoices  
  
SELECT TOP (1000) [Id]  
      ,[BillingDate]  
      ,[CustomerId]  
  FROM [eNtsaRegistration].[dbo].[Invoices]  
  
// Customers  
SELECT TOP (1000) [Id]  
      ,[Name]  
      ,[ReferredBy]  
  FROM [eNtsaRegistration].[dbo].[Customers] 
SQL

Posted
Updated 11-Nov-20 12:03pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900