I'm trying to write a query that has many case statements and checks against thresholds. These thresholds are stored in another table and I want to load them into an array I can reference in my query.

for example

metric good fair poor
pktloss 0 2 4
jitter 0 20 30
mos 5 4 3

then my query would be something like this ideally. Basically I want to load in all these comparison parameters rather than hardcode them in the query itself. I'm sure I could just set parameters to a value in the query but want them in a table instead.

case when pktloss between $thresh(pktloss,good) and $thresh(pktloss,fair) then 'good'

from callrecords

any help is greatly appreciated.