Dev Helpers

SQL / Set operations

Compare two literal lists

Dev Helpers · November 15, 2026

Set operations compare rows under SQL's rules for duplicates. Check whether the result represents membership or the number of occurrences.

Worked example

WITH a(n) AS (VALUES (1),(2)), b(n) AS (VALUES (2),(3)) SELECT n FROM a INTERSECT SELECT n FROM b;

Result

[
  {
    "n": 2
  }
]

Implementation notes

Set operators can remove duplicates even if they were meaningful in the source. Compare aggregation counts when reconciling quantities.

Try it yourself

Repeat a value several times on one side of the comparison.

Open the SQL example →

Editorial date November 15, 2026 · Published December 6, 2026

Related articles

Count jobs per active day

Grouping timestamps by day produces counts only for days present in the data. A continuous chart may need a calendar series as well.

Read the previous duration

LAG retrieves a prior row's value within an ordered window. The first row lacks a predecessor and usually needs its own display rule.