How can you say that!? Do you even understand what is going on?1) Did you test?2) Do you have fact before you post "IT DO NO WORK!"?Try this for fact-- Prepare sample dataDECLARE @Sample TABLE (Col1 INT, Col2 VARCHAR(10), Col3 CHAR(1), Col4 INT)INSERT @SampleSELECT 100, 'tv', 'p', 5 UNION ALLSELECT 100, 'tv', 's', -4 UNION ALLSELECT 101, 'radio', 'p', 5 UNION ALLSELECT 101, 'radio', 's', -5 UNION ALLSELECT 102, 'cdplayer', 'p', 2 UNION ALLSELECT 102, 'cdplayer', 's', -2 UNION ALLSELECT 103, 'dvdplayer', 's', -2 UNION ALLSELECT 104, 'mobile', 'p', 2 UNION ALLSELECT 104, 'mobile', 's', -3-- Show the expected outputSELECT Col1, Col2, p, s, p + s AS rFROM ( SELECT Col1, Col2, SUM(CASE WHEN Col3 = 'p' THEN Col4 ELSE 0 END) AS p, SUM(CASE WHEN Col3 = 's' THEN Col4 ELSE 0 END) AS s FROM @Sample GROUP BY Col1, Col2 ) AS qORDER BY Col1
I can't see duplicates. Can you?
E 12°55'05.25"N 56°04'39.16"