西柚(提问者)select * from(select * from(select kc.day_wid,kc.update_date,kc.item_id,kc.item_code,kc.item_name,kc.unit,kc.warehouse_code,
kc.warehouse_quantity as quantity1,
case when kc2.warehouse_quantity=\'\' or kc2.warehouse_quantity is null then 0 else kc2.warehouse_quantity end quantity2,
(case when kc2.warehouse_quantity=\'\' or kc2.warehouse_quantity is null then 0 else kc2.warehouse_quantity end)-kc.warehouse_quantity as kcyy
from nhbidw.dw_warehouse_day kc
left join
(select day_wid,update_date,item_id,item_code,item_name,unit,warehouse_code,warehouse_quantity
from nhbidw.dw_warehouse_day
where day_wid=\'${结束时间}\' ) kc2
on kc.item_code=kc2.item_code and kc.warehouse_code=kc2.warehouse_code
where kc.day_wid=\'${开始时间}\')
where warehouse_code in(\'${仓库}\')
and kcyy !=0
水平太次 就这么写了