Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HAVING of GROUP BY #311

Open
the42 opened this issue Jan 20, 2023 · 1 comment
Open

Support HAVING of GROUP BY #311

the42 opened this issue Jan 20, 2023 · 1 comment

Comments

@the42
Copy link

the42 commented Jan 20, 2023

Title has it. Don't know of another easy way to search for duplicates in a column. Sure

SELECT col, count(col)
FROM a
GROUP BY col
ORDER BY 2 desc
LIMIT 100

works somehow, but requires fiddling with LIMIT.

@cube2222
Copy link
Owner

Hey @the42, HAVING should be added at some point.

For the time being you can also use subqueries / common table expressions.

SELECT * FROM (SELECT col, COUNT(*) as howmany FROM a GROUP BY col) q WHERE q.howmany > 1
WITH
    valcounts AS (SELECT col, COUNT(*) as howmany FROM a GROUP BY col)
SELECT * FROM valcounts WHERE howmany > 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants