with UNIT6 as(
select t0.ItemCode,t0.OcrCode
,sum(t0.PlannedQty) 'PlannedQty'
from owor t0 where t0.CreateDate>='2020-07-01 00:00:00.000'
and t0.OcrCode='UNIT6'
group by t0.ItemCode ,t0.OcrCode
),
UNIT7 as(
select t0.ItemCode,t0.OcrCode
,sum(t0.PlannedQty) 'PlannedQty'
from owor t0 where t0.CreateDate>='2020-07-01 00:00:00.000'
and t0.OcrCode='UNIT7'
group by t0.ItemCode,t0.OcrCode
)
select (select itemname from oitm o1 where o1.itemcode=t1.ItemCode)'itemname' ,* from UNIT6 t1
inner join UNIT7 t2 on t1.ItemCode=t2.ItemCode
这是2个单位的示例,我想要多个单位的结果