I have a T-SQL query where I want all negative quantities to be zeroed out.
SELECT p.productnumber, v.[Description], SUM(i.Quantity) as quantity FROM ... LEFT JOIN ... LEFT JOIN ... LEFT JOIN ... GROUP BY productnumber, [Description]
In principle, if the sum consists of 5, 5, -1, the result should be 5 + 5 + 0 = 10, and not (5 + 5 + (- 1) = 9.
How can I do it?
sql sql-server tsql group-by
John
source share