Added
A reporting service needs results from several PostgreSQL 9.6 query patterns. Match each requirement to the SQL construct that gives the stated behavior.
Drag each item onto its matching target. On a phone: tap an item, then tap a target.
- Keep every left-side row, with nulls when no right-side row matches. → LEFT JOIN
- Return rows present in both query results, with duplicates eliminated. → INTERSECT
- Return one row for each distinct grouping key and its aggregate. → GROUP BY
- Return rows from the first query that are absent from the second query. → EXCEPT
LEFT JOIN preserves unmatched rows from its left input and fills right-side columns with nulls. INTERSECT returns common rows and removes duplicates unless INTERSECT ALL is specified. GROUP BY forms groups by the selected grouping expressions so aggregates are calculated per group. EXCEPT removes rows found in the second query from the first result. These constructs have distinct row-preservation and set semantics, so substituting one for another would change the requested output.