--首先把上边的结果生成临时表
select  dzxl=substr(a.dzxl,1,4),a.com_code,b.name, sum_num=sum(a.hslsje-a.zzk) into #t from pszx_jxc_com_day a ,commod b 
where a.com_code=b.code and a.rq>='01-jun-04' and a.rq<='22-jun-04'
and substr(a.dzxl,1,3) in('108','109','110','111') 
group by substr(a.dzxl,1,4),a.com_code,b.name order by --查询
select * from #t t
  where com_code in (select top 10 com_code from #t where dzlx=t.dzlx order by sum_num desc)