and a.loc_no like '%' + #{map.loc_no} + '%'
and a.matnr like '%' + #{map.matnr} + '%'
and a.maktx like '%' + #{map.maktx} + '%'
and a.batch like '%' + #{map.batch} + '%'
and a.anfme like '%' + #{map.anfme} + '%'
and a.modi_time between #{map.startTime} and #{map.endTime}
and a.memo like '%' + #{map.memo} + '%'
and a.memo is not null
and a.memo !=''
select
a.matnr
, sum(a.anfme) as anfme
from wms_loc_detl a
where 1=1
group by a.matnr
SELECT SUM(anfme) FROM wms_loc_detl
select
a.*
from wms_loc_detl a
left join wms_loc_mast b on a.loc_no = b.loc_no
where 1=1
and b.row1 >= 31
and b.row1 <= 32
and b.row1 >= 2
and b.row1 <= 17
and b.row1 >= 18
and b.row1 <= 30
and a.matnr = #{matnr}
and b.bay1 = #{bay}
and b.loc_sts = 'F'
order by b.row1
desc
select
*
from
(
select
no = 1,
orderBy = 'true',
b.bay1 as bay,
sum(anfme) as count
from wms_loc_detl a
left join wms_loc_mast b on a.loc_no = b.loc_no
where 1=1
and b.loc_sts = 'F'
and a.matnr = #{matnr}
and b.row1 >= 31
and b.row1 <= 32
group by b.bay1
union
select
no = 2,
orderBy = 'true',
b.bay1 as bay,
sum(anfme) as count
from wms_loc_detl a
left join wms_loc_mast b on a.loc_no = b.loc_no
where 1=1
and b.loc_sts = 'F'
and a.matnr = #{matnr}
and b.row1 >= 2
and b.row1 <= 17
group by b.bay1
union
select
no = 3,
orderBy = 'false',
b.bay1 as bay,
sum(anfme) as count
from wms_loc_detl a
left join wms_loc_mast b on a.loc_no = b.loc_no
where 1=1
and b.loc_sts = 'F'
and a.matnr = #{matnr}
and b.row1 >= 18
and b.row1 <= 30
group by b.bay1
) a
order by no, count desc