sql 多表返回汇总结果

with tb(id,product,barcode,qty) as
(
select 1,'AA',240,3
union all select 2,'BB',245,2
union all select 3,'AA',255,2
union all select 4,'BB',240,1
)

select * from tb compute sum(qty),sum(barcode)

编程技巧