I'm trying to create a summary/pivot result from data in our inventory. I want to see Machine_Type and Machine_Size as rows down the left for each change in Machine_Size, then columns for count of Fleet_no, sum of 'Weekly_Rate' and average of 'Weekly_Rate'. How can I do this in SQL? My select query is below:Select iv.cat [Machine_Type], tm.Machine_Size [Machine_Size], di.item [Fleet_No], di.weekchg [Weekly_Rate] from deltickitem di left join inventory iv on iv.item = di.itemleft join MCSReports.tblMLookup tm on tm.Subcategory = iv.subwhere (di.stop_rent is null or di.stop_rent > GETDATE()-5) and di.orig_start_rent <= GETDATE() and di.stage < 16 and iv.cat not in ('ATTACH','AUGER','BREAK','BUCKET','CAR', 'COMP', 'CROSSHIRE','FORKS','GATOR', 'MISC','ROTOATT', 'TIPPER', 'TRAIL') and iv.sub <> '360BUCKET'
Many thanksMartyn