I have a query that does not render totals the way I need:select l.[load] as Bol#, convert(char(10), l.date, 101) as Date, p.petroexcode as PetroEXCode, l.branded as Product, substring(p.name,1,30) as Name, cast(sum(l.gross) as decimal(15, 2)) AS GrossTotal, cast(sum(l.net) as decimal(15,2)) as NetTotalfrom [SFM-TP6000-1].TP6000.dbo.product as pinner join [SFM-TP6000-1].TP6000.dbo.loadcomp as l on l.branded = p.productwhere (@Product IS null or p.petroexcode = @Product) and (@DateFrom IS Null or l.date >= @DateFrom) and (@DateTo IS Null or l.date <= DATEADD(DAY, 1, @DateTo))group by l.[load], l.date, p.petroexcode, l.branded, p.name
Result:20848 07/01/2009 V96 ULS DY DIESEL FUEL - 15 DYED - NRLM 3001.00 2972.0020848 07/01/2009 V96 ULS DY DIESEL FUEL - 15 DYED - NRLM 3001.00 2970.0020849 07/01/2009 V96 ULS DY DIESEL FUEL - 15 DYED - NRLM 4000.00 3958.00What I need is one line with totals added up.20848 07/01/2009 V96 ULS DY DIESEL FUEL - 15 DYED - NRLM 6001.00 5942.0020849 07/01/2009 V96 ULS DY DIESEL FUEL - 15 DYED - NRLM 4000.00 3958.00