In the fiddle below, I have two tables. The first table contains a column with a numeric value (e.g.
int). The second table contains rows of numeric ranges (stored in two columns that hold the “low” and “high” limits of the range).
The query in the fiddle works, using a
FULL OUTER JOIN to produce the expected results. I can add indices to speed queries, but would appreciate thoughts on how to generate
SQL to achieve a more optimal query plan than that provided in the fiddle.
DB Fiddle here
Solutions need not be portable (so long as they work in
PostgreSQL), but no third-party solutions, please.