locked
Combine tables (3) RRS feed

  • Question

  • Hello experts I need your help to combine 3 tables

           

    this is the query that I combie 2 tables

    SELECT i.[InstallationId]
          ,i.[ProviderId]
          ,i.[InvoiceDate]
          ,i.[RevenueClassId]
          ,i.[RevenueGroupId]
          ,i.[RevenueTypeId]
          ,i.[RevenueSubTypeId]
          ,i.[PracticeGroupCategoryId]
          ,i.[Quantity]
          ,i.[Charges]

      FROM [enterprise].[dbo].[FACT_InvoiceCharge] as i
      left join [enterprise].[dbo].[DIM_RevenueGroup] as r
      on i.RevenueClassId = r.RevenueClassId



     where InvoiceDate = '01/05/2019'


    I need to add another tables called

    SELECT [InstallationId]
          ,[PracticeName]
            FROM [enterprise].[dbo].[DIM_Installation]

    with the installationid in both tables

    thank you


    guaya81

    Tuesday, February 11, 2020 6:47 PM

Answers

  • This?

    SELECT i.[InstallationId]
          ,i.[ProviderId]
          ,i.[InvoiceDate]
          ,i.[RevenueClassId]
          ,i.[RevenueGroupId]
          ,i.[RevenueTypeId]
          ,i.[RevenueSubTypeId]
          ,i.[PracticeGroupCategoryId]
          ,i.[Quantity]
          ,i.[Charges]
    	  di.PracticeName
      FROM [enterprise].[dbo].[FACT_InvoiceCharge] as i
      left join [enterprise].[dbo].[DIM_RevenueGroup] as r
      on i.RevenueClassId = r.RevenueClassId
      /*LEFT*/ JOIN [enterprise].[dbo].[DIM_Installation] di 
      on di.[InstallationId]=i.[InstallationId]
      where i.InvoiceDate = '01/05/2019'

    • Marked as answer by guaya81 Tuesday, February 11, 2020 7:00 PM
    Tuesday, February 11, 2020 6:51 PM