- ```sql
  select m.islcodex
  	,m.slcodex
  	,m.corpbcode
  	,m.bcode
  	,m.wcode
  	,g.gislcodex
  	,g.keeper
  	,g.scode
  	,g.purshipgicodex
  	,g.fgislcode
  	,g.prjcode
  	,g.prjicode
  	,g.sublib
  	,g.gcode
  	,g.specifidesc
  	,g.gattr1
  	,g.gattr2
  	,g.gattr3
  	,g.gattr4
  	,g.gattr5
  	,g.gattr6
  	,g.gattr7
  	,g.gattr8
  	,g.gattr9
  	,g.gattr10
  	,g.gattr11
  	,g.gattr12
  	,g.gattr13
  	,g.gattr14
  	,g.gattr15
  	,g.gattr16
  	,g.gattr17
  	,g.gattr18
  	,g.gattr19
  	,g.gattr20
  	,g.trademode
  	,sum(g.qty) lockqty
  	,sum(g.qtx) lockqtx
  	,b.lockqty
  	,b.lockqtx
  	,b.lockdate
  	,b.lockwcode
  	,b.lockccode
  	,b.locksalordicodex
  	,b.lockupric
  	,b.lockremark
  	,b.lockdelay
  	,b.portal_sync_flag
  	,b.istracpop
  	,s.salordgicode
  	,s.qty
  	,s.restqty
  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
  where m.islcode =g.islcode 
  and g.gislcodex = b.gislcodex
  and m.sheetcode = '27.25.20.11.XY'
  and b.busimode = '10'
  and b.psmode in ('10','20')
  and ((b.lockdelay = 1 and (b.locksalordicodex is null or b.locksalordicodex = '')) or b.locksalordicodex is not null)
  group by m.islcodex
  	,m.slcodex
  	,m.corpbcode
  	,m.bcode
  	,m.wcode
  	,g.gislcodex
  	,g.keeper
  	,g.scode
  	,g.purshipgicodex
  	,g.fgislcode
  	,g.prjcode
  	,g.prjicode
  	,g.sublib
  	,g.gcode
  	,g.specifidesc
  	,g.gattr1
  	,g.gattr2
  	,g.gattr3
  	,g.gattr4
  	,g.gattr5
  	,g.gattr6
  	,g.gattr7
  	,g.gattr8
  	,g.gattr9
  	,g.gattr10
  	,g.gattr11
  	,g.gattr12
  	,g.gattr13
  	,g.gattr14
  	,g.gattr15
  	,g.gattr16
  	,g.gattr17
  	,g.gattr18
  	,g.gattr19
  	,g.gattr20
  	,g.trademode
  	,b.lockqty
  	,b.lockqtx
  	,b.lockdate
  	,b.lockwcode
  	,b.lockccode
  	,b.locksalordicodex
  	,b.lockupric
  	,b.lockremark
  	,b.lockdelay
  	,b.portal_sync_flag
  	,b.istracpop
  	,s.salordgicode
  	,s.qty
  	,s.restqty
  having sum(g.qty) > 0
  ```