cube2222 / octosql

OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
Mozilla Public License 2.0
4.78k stars 202 forks source link

Support HAVING of GROUP BY #311

Open the42 opened 1 year ago

the42 commented 1 year ago

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 commented 1 year ago

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