I have a recordset named rsProductClass
that is returned from a table in the database. It is a very simple SELECT * FROM Table WHERE ProductID = {ID Value Here}
and the table is like this:
ProductID | UPPERTIER | LOWERTIER | NATIER | OTHERTIER
1 20 60 10 10
2 10 90 NULL NULL
3 NULL 40 NULL 5
The table may or may not have a value for each of the various tiers.
What I want to do is show to the user which column has the highest value and what the name of that column is. So for example, if you were looking at ProductID
2
, then the page should display "This is likely to be a LOWERTIER
product"
I need to sort the rsProductClass
query in such a way that it returns me a list of columns in that query ordered by the value in each column. I want to treat the NULL values as zeros.
I tried to mess about with doing valuelist()
and some ArrayToList()
type functions but it crashes on the NULL values. Say I add columns to an array, and then use ArraySort()
to get them in some kind of order, I'll get an error saying something like "Position 1 is not numeric" because it has a NULL value.
Is this something that can be done by ColdFusion? I suppose its some sort of pivoting of the recordset which is beyond my ability.