Sorry for messy title, if you are a moderator and know a better title, feel free to change.
Say, we have two SQL tables
intervals vals -------- ------- since val -------- ------- 1 1 4 2 8 3 20 4 ... ... 500 100
I want to make a join so that “since” field from intervals table would be a lower bound for a “val”. And “since” values that have no “val” that is larger would not appear. See what I want to get:
since val -------------- 1 1 1 2 1 3 4 4 4 5 4 6 4 7 8 8 8 9 .....
How do I do it in generic SQL? Postgres-only solution will fit as well.
Credit to RhodiumToad on #postgresql