Count()可用于"其中"对于具有值>的分隔符记录数,

时间:2018-02-15 15:29:38

标签: sql count

SELECT   numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL 
GROUP BY numero_documento 
order by cuantos desc ;

我只需要值为"Cuanto" > 1

的记录

2 个答案:

答案 0 :(得分:0)

添加查询

SELECT   numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL GROUP BY numero_documento 
having count(numero_documento) > 1
order by cuantos desc 

答案 1 :(得分:0)

有时看到另一种做某事的方法会很有帮助。我并没有声称这样做会更好,但它确实有效。

使用像这样的子查询

Select * from
(
  SELECT   numero_documento,COUNT(*) AS cuantos
  FROM dbo.PERSONAL 
  GROUP BY numero_documento 
) G1
WHERE cuantos > 1
order by cuantos desc