from storeslist m,storeslistg g ,stocklockbalance b left join (select m.salordicode,g.salordgicode,g.gicode,g.gcode,g.qty ,c.restqty from salorder m, salorderg g ,salordergshipcor c where m.salordicode = g.salordicode and g.salordgicodex=c.salordgicodex and m.status > '0' and m.busimode = '10' and m.psmode in ('10','20') and c.restqty > 0) s on b.locksalordicodex = s.salordicode and b.gicode = s.gicode
,s.restqty
where m.islcode =g.islcode
from storeslist m,storeslistg g ,stocklockbalance b left join (select m.salordicode,g.salordgicode,g.gicode,g.gcode,g.qty ,c.restqty from salorder m, salorderg g ,salordergshipcor c where m.salordicode = g.salordicode and g.salordgicodex=c.salordgicodex and m.status > '0' and m.busimode = '10' and m.psmode in ('10','20') and c.restqty > 0) s on b.locksalordicodex = s.salordicode and b.gicode = s.gicode
and g.gislcodex = b.gislcodex
where m.islcode =g.islcode
and m.sheetcode = '27.25.20.11.XY'
and g.gislcodex = b.gislcodex
and b.busimode = '10'
and m.sheetcode = '27.25.20.11.XY'
and b.psmode in ('10','20')
and b.busimode = '10'
and ((b.lockdelay = 1 and (b.locksalordicodex is null or b.locksalordicodex = '')) or b.locksalordicodex is not null)
and b.psmode in ('10','20')
group by m.islcodex
and ((b.lockdelay = 1 and (b.locksalordicodex is null or b.locksalordicodex = '')) or b.locksalordicodex is not null)