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.76k stars 200 forks source link

Common Table Expressions #185

Closed cube2222 closed 4 years ago

cube2222 commented 4 years ago

Make queries such as this one possible:

WITH
    fluffy_cats AS
        (SELECT * FROM cats c WHERE c.description = 'fluffy'),
    grouped_cats AS
        (SELECT c.name, COUNT(*) as count, AVG(c.livesleft) as average_livesleft
        FROM fluffy_cats c
        GROUP BY c.name),
    future_proof_cats AS
        (SELECT * FROM grouped_cats c WHERE c.average_livesleft > 5.5),
SELECT * FROM future_proof_cats c