日期:2014-05-19  浏览次数:20585 次

一道面试题
表A中有字段B   其中有重复值(内容)   请计算出重复值(内容)是什么?   有几个?  


------解决方案--------------------
select B,count(*)
from A
group by B
having count(*)> 1
------解决方案--------------------
select B,count(*)
from A
group by B
having count(*)> 1

------解决方案--------------------
select B,
count(*) [个数]
from A
group by B
------解决方案--------------------
1楼2 楼正解
------解决方案--------------------
只有顶塞
------解决方案--------------------
ding
------解决方案--------------------
看来我不用怕sql面试了...
------解决方案--------------------
select B,count(*)
from A
group by b
having count(b)> 1

------解决方案--------------------
easy
------解决方案--------------------
select B,count(*)
from A
group by B
having count(*)> 1
------解决方案--------------------
pass
------解决方案--------------------
select count(1),b from
from a
where exists(select * from a z where z.b = a.b)
group by b

这样也可以.
嘿嘿,面试的时候多写几种方法应该更好吧?