select columns by a concat text as columnname in oracle
- by glaudiston
I have a table with columns named with the number of hour of day like this:
col00 NUMBER(5)
col01 NUMBER(5)
col02 NUMBER(5)
...
col23 NUMBER(5)
...and I have another query that returns a count by hour.
I want to recover the colXX value by hour.... then I can recover with "decode" or "case when..." but I want know if exists any way to recover the column by a text like this:
select "col"||hour from table;
in the hypothetical above example if hour is 13 then would be translated like:
select col13 from table;
there is any way to do this ?