I’m trying to find the T-SQL syntax to find the totals invoiced per engineer over a period of time. The problem is that for each invoice there’s one value in the invoice header (freight), plus the total value of all the invoice lines. I’ve got a query that gives me the right numbers, but for each engineer I get a line for each different invoice number. What I want is one total per engineer.
I know this must be simple to more experienced SQL folks, so please bear with me.
My code is something like this:
SQL
SELECTemployee.name'Engineer','Sales MTD'=inv_hdr.freight+SUM(inv_item.qty_invoiced*inv_item.price)FROM<SELECTandWHEREclausesGROUPBYemployee.name,inv_hdr.freight
(I have to "group by" the freight column in order to add it to the value of the lines)
And the output is something like this:
EngineerSales...
<