Reputation: 8995
I'm trying to select an integer field as text but I have no idea how to do it.
The 1
represents low
, the 2
represents medium
, and 3
represents hi
.
Upvotes: 0
Views: 73
Reputation: 223402
Select
CASE WHEN field = 1 then 'low'
WHEN field = 2 then 'medium'
WHEN field = 3 then 'hi'
END as Col
from yourtable;
Upvotes: 2
Reputation: 4957
SELECT CASE intfield
WHEN 1 THEN 'low'
WHEN 2 THEN 'medium'
WHEN 3 THEN 'hi'
END AS inttext
FROM table
Upvotes: 2
Reputation: 29121
you can do this with CASE WHEN
SELECT (CASE WHEN column = 1 THEN "low"
WHEN column = 2 THEN "medium"
WHEN column = 3 THEN "high"
END) AS value
FROM table_name;
Upvotes: 3