Evaluating the data in SELECT statement

  • Thread starter Thread starter Tor Inge Rislaa
  • Start date Start date
T

Tor Inge Rislaa

I have an simple query as below:


SELECT MyValue

FROM MyTable

Based on the value in the field MyValue I want to add a value to a new
column in the result of the query.

Example:

If the value in MyValue = 0 then I would add the text "External"

If the value in MyValue = 1 then I would add the text "Internal"

I what to see the same result as the query below (on the fly), without using
union all:

SELECT MyValue, "External" AS ValueDescription

FROM MyTable

WHERE MyValue = 0

UNION ALL

SELECT MyValue, "Internal" AS ValueDescription

FROM MyTable

WHERE MyValue = 0

Is there a way to do this?

TIRislaa
 
SELECT MyValue, Choose([MyValue] - 1, "External", "Internal") As
ValueDescription
FROM MyTable

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Back
Top