I apologize if the question is duplicated, but in my preliminary search I haven't found anything!
In my query extraction with SQL, I need to replace the result of a column with other string values.
In particular, I have an enum:
A1 -> started
A2 -> running
In my database, I only save:
A1
B2
So, my query returns the column including strings such as:
A1
B2
I'd like obtaining:
started
running
Is it possible with a query?
Thank you so much!
CodePudding user response:
You can do it with the CASE
expression:
SELECT ...
, CASE Column
WHEN 'A1' THEN 'started'
WHEN 'B2' THEN 'running'
... END AS Status
FROM Table
Read https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql?view=sql-server-ver15