Limit records by number of repetitions

Asked

Viewed 88 times

1

I have a query as follows, and would like to filter by COUNT

SELECT COUNT(1) AS QTD,
       Nome,
       Cpf
FROM Funcionarios
WHERE QTD >= 2
GORUP BY Nome, Cpf
  • explain better, from an example result. You want to recover duplicate Cpf and names?

1 answer

4

Try adjusting your query to filter after grouping the data with the clause Having:

SELECT COUNT(1) AS QTD,
       Nome,
       Cpf
  FROM Funcionarios
 GROUP BY Nome, Cpf
HAVING COUNT(1) >= 2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.