I have a an Enum
at the programming language level which is stored as a simple integer on the table. Think:
APPLE = 1
GOOGLE = 2
MSFT = 3
AMAZON = 4
... (100s more)
I just wanna query the table and instead of the number return the corresponding string value. Is there an easier way of doing this without using case
statement or a temp table:
SELECT
CASE WHEN type = 1 THEN "APPLE"
CASE WHEN type = 2 THEN "GOOGLE"
CASE WHEN type = 3 THEN "MSFT"
CASE WHEN type = 4 THEN "AMAZON"
...
ELSE "UNKNOWN"
FROM t
Basically it's just a key look-up in a dictionary.