日期:2014-05-18 浏览次数:20531 次
CREATE TABLE [dbo].[zf_ffr]( [id] [int] NULL, [xingming] [varchar](10) , [fenshu] [int] NULL, [lianxi] [varchar](5) ) insert into zf_ffr values(1,'a',50,'1') insert into zf_ffr values(2,'aa',80,'1') insert into zf_ffr values(3,'b',60,'2') insert into zf_ffr values(4,'bb',90,'2') insert into zf_ffr values(5,'c',85,'3') insert into zf_ffr values(6,'cc',30,'3') insert into zf_ffr values(7,'d',80,'4') insert into zf_ffr values(8,'dd',30,'4') select * from zf_ffr a order by (select max(fenshu) from zf_ffr where lianxi=a.lianxi) desc,lianxi,fenshu desc /* id xingming fenshu lianxi ----------- ---------- ----------- ------ 4 bb 90 2 3 b 60 2 5 c 85 3 6 cc 30 3 2 aa 80 1 1 a 50 1 7 d 80 4 8 dd 30 4 (8 行受影响) */ go drop table zf_ffr