SQL每日一题(20211215)
SQL每日一题(20220510)
select
a.item,
a.qty,
case when a.qty<=b.qty then '在途' else '缺货' end status,
case when a.qty<=b.qty then riqi - cast('2021-7-13' as date) else 0 end pending_days
from t0824a a ,
(select item ,sum(qty) as qty,max(arrival_dt) as riqi from t0824b group by item) b
where a.item=b.item;