SELECT numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL
GROUP BY numero_documento
order by cuantos desc ;
我只需要值为"Cuanto" > 1
答案 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