Now let's examine the case of semi-open, semi-closed ranges:
select x from t where x >  low_x and x <= high_x; -- (open, closed)
select x from t where x >= low_x and x <  high_x; -- (closed, open)
Instead of repeating the same steps, that would be a rather tedious process, let's see how we can apply "formal method of ranges decomposition" to re-use the results for open and closed ranges already discussed.

The strategy is: Similarly for three, four subranges.

We'll experiment (script range_sel_semi.sql) on the case of num_distinct=4 only; remember that for this case we have:
 left band     : 0   < x < 2.5
 central region: 2.5 < x < 7.5
 right band    : 7.5 < x < 10
Let's move to the conclusion.

For corrections / feedback:
[email protected]