重复的行数

时间:2011-08-16 06:47:58

标签: sql-server sql-server-2005 sql-server-2008 sql-server-2000 sql-server-express

tbl1

字段id,name

id = 1 name = a

id = 1 name = a

id = 1 name = w

id = 1 name = f

id = 2 name = c

id = 2 name = a

如何获得重复的场数。 id = 1,name = a ==> 2

1 个答案:

答案 0 :(得分:2)

很简单

select
  id,
  name,
  count(*)
from
  table
group by
  id, name