這種什麼實現?我的語句是:select ISNULL(fritemcd,tofritemcd)as fritemcd, qty,qty2 from
(SELECT a.fritemcd,a.qty FROM iniop03t a
left join biitm01t b on fritemcd=itemcd
WHERE a.movedt='20150204' AND a.frstockcd IN ('A710','A711','A713','a712' )and b.itemkind='2') T
full join
(SELECT a.fritemcd tofritemcd,a.qty as qty2 FROM iniop03t a --入
left join biitm01t b on fritemcd=itemcd
WHERE movedt='20150204' AND tostockcd IN ('A710','A711','A713','a712') and b.itemkind='2')F on T.fritemcd=F.tofritemcd
結果如下:
比如你這個表為table,列為fritemcd,qty,qty2 你可以這麼寫
select gritemcd, qty, 0 qty2 from table
union all
select gritemcd, 0, qty2 from table
再加上你的條件即可