SELECT T2_id , T1_id , Quantity FROM ( select 1 AS ORD, T2_id , T1_id , Quantity from Table2 UNION ALL select 2 AS ORD,0 AS T2_id , T1_id , SUM(Quantity ) AS Quantity from Table2 GROUP BY T1_id ) AS P ORDER BY T1_id, ORD
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)