如果PREITEM,ITEM ,如楼主所写完全相同,on_hand除了一个非0,其他都为0
select PREITEM,ITEM,SUBITEM,sum(on_hand) from table group by PREITEM,ITEM,SUBITEM;
select PREITEM,ITEM,SUBITEM,sum(on_hand) from table group by PREITEM,ITEM,SUBITEM;
from tbname
group by preitem,item,subitem;
(select distinct subitem from tbl order by on_hand desc )
--------------------------------------------------------------
select
a.*
from
Test a
where
not exists(select 1 from Test where ON_HAND>a.ON_HAND)