SELECT numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL
GROUP BY numero_documento
order by cuantos desc ;
I need only records with value of "Cuanto" > 1
SELECT numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL
GROUP BY numero_documento
order by cuantos desc ;
I need only records with value of "Cuanto" > 1
Add having to the query
SELECT numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL GROUP BY numero_documento
having count(numero_documento) > 1
order by cuantos desc
Sometimes it is helpful to see another way to do something. I'm not claiming this way to be better, but it works.
Use a Sub Query like this
Select * from
(
SELECT numero_documento,COUNT(*) AS cuantos
FROM dbo.PERSONAL
GROUP BY numero_documento
) G1
WHERE cuantos > 1
order by cuantos desc