加索引:
create index idx_test on [table](A,B,C)我做了一个小测试,发现第二种方法比较快:set statistics time on
select fitemid,max(fqty) from icstockbillentry group by fitemid
set statistics time off
/*SQL Server 执行时间: 
   CPU 时间 = 0 毫秒,耗费时间 = 0 毫秒。SQL Server 执行时间: 
   CPU 时间 = 0 毫秒,耗费时间 = 1184 毫秒。(11268 行受影响)
*/set statistics time on
select fitemid,fqty from icstockbillentry t where not exists(select 1 from icstockbillentry where fitemid=t.fitemid and fqty>t.fqty)
set statistics time off
/*
SQL Server 执行时间: 
   CPU 时间 = 0 毫秒,耗费时间 = 0 毫秒。SQL Server 执行时间: 
   CPU 时间 = 13 毫秒,耗费时间 = 138 毫秒。(11268 行受影响)
*/