日期:2014-05-18  浏览次数:20414 次

记录排序问题。
abc     aa       abc@dk.com
    aaa     ddd     abc@dk.com
    122     skl     sa@dk.com
    sll     ksk     sdfk@kk.com
    aas     kll     abc@dk.com

怎么按邮箱数量最大的排最前面??


------解决方案--------------------
数量在哪?哪个是数量?没看明白.
------解决方案--------------------
order by
------解决方案--------------------
create table TemTable
(
Tname varchar(30),
Tpwd varchar(30),
Temail varchar(200)
)
go


insert into TemTable
select 'abc ', 'aa ', 'abc@dk.com ' union all
select 'aaa ', 'ddd ', 'abc@dk.com ' union all
select '122 ', 'skl ', 'sa@dk.com ' union all
select 's11 ', 'ksk ', 'sdf@kk.com ' union all
select 'aas ', 'kll ', 'abc@dk.com '

go

select T.Temail,T.CountEmail from (select count(Temail)
as countEmail,Temail from TemTable
group by Temail) as T order by T.CountEmail desc