0
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

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
deyzab
  • 3
  • 2

2 Answers2

0

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 
Ven
  • 2,011
  • 1
  • 13
  • 27
0

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
jeffld
  • 726
  • 1
  • 9
  • 17