I would like to select all duplicate from a table:
SELECT * FROM people HAVING (count(*) OVER (PARTITION BY name)) > 1;
Unfortunately I get the error:
Error Code: 3593. You cannot use the window function 'count' in this context.
One less elegant solution would be:
SELECT
*
FROM
people
WHERE
code IN (SELECT
name
FROM
people
GROUP BY name
HAVING COUNT(*) > 1);
How can I rewrite my first query to make it work?