求一SQL语句,关于分组显示的,谢谢!
有以下数据 
 tel               qy 
 12344         gl 
 15468         gl 
 46447         lg 
 45647         lg 
 78767         xa 
 31234         xa 
 现在想要取出qy相同的号码的一半(不要求是上一半还是下一半),最终的显示结果类似于下表 
 tel               qy 
 15468         gl 
 45647         lg 
 78767         xa   
 请各位高手帮忙,谢谢! 
------解决方案--------------------create table #t 
 (tel varchar(10),     qy varchar(10)) 
 insert into #t 
 select  '12344 ' ,   'gl ' union all 
 select  '15468 ' ,   'gl ' union all 
 select  '45660 ' ,   'gl ' union all 
 select  '85232 ' ,   'gl ' union all 
 select  '46447 ' ,   'lg ' union all 
 select  '45647 ' ,   'lg ' union all 
 select  '78767 ' ,   'xa ' union all 
 select  '31234 ' ,   'xa '     
 select * from #t a  
 where (select count(1) from #t where qy=a.qy and tel> a.tel) <(select count(1)from #t where qy=a.qy)/2     
 tel        qy          
 ---------- ----------  
 45660      gl 
 85232      gl 
 46447      lg 
 78767      xa   
 (4 row(s) affected)     
 這樣才可以顯示每一組中數據的一半