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

sql抽出唯一的数据
比如出现以下数据

name                       phone
aa                               111
bb                               111
aa                               111
cc                               111
aa                               22
aa                               1
bb                               3333

想抽出的结果是:


name                   phone
aa                         22
aa                           1
bb                         3333

应该怎做好的咯;我是这样的
select   name,phone   from   table   group   by   name,phone   having   count(phone)=1

当然这是错的咯;请指正

------解决方案--------------------
select
t.name,t.phone
from
[table] t
where
1=(select count(*) from [table] where phone=t.phone)