Skip to main content

Posts

Showing posts with the label inner joins

Right approach to use join for particular scenario in sql

I have a table that looks like this: CREATE TABLE #C (grpType varchar(10), CPTCode varchar(10) NULL, Month int NULL, MTD money NULL, MonthCount int NULL, YTD money NULL, YearCount int NULL, Code varchar(10) NULL) It has the following data in it: grpType CPTCode Month MTD MonthCount YTD YearCount Code Month 76800 5 1321.61 27 6574.54 82 76800 Month 76856 5 246.01 3 380.64 6 76856 Month 76881 5 9778.95 131 50682.59 509 76881 Month 76942 5 22467.33 190 116663.58 674 76942 Then I have another table: CREATE TABLE #Prod (grpType varchar(10), TotalCharges money NULL, TotalUnits float NULL, RVU float NULL, Code varchar(10) NULL, CPTCode varchar(10) NULL) This table has the following data in it: grpType TotalCharges TotalUnits RVU Code CPTCode Month 6100.00 12 0 76800 76800 Month -475.00 -1 0 76880 76880 Mont...