Thnx Marco! Your solution looks a lot like Massimo's, BTW.
Still, suppose I have a table with some 500,000 records and I try an interval match to the ranges table - would the nested if be more slow than the match table? I will do the experiment today..