SQL: help assigning value to temp column for results from 2 fields

  • Thread starter Thread starter JaneLeigh
  • Start date Start date
J

JaneLeigh

Hi
I am trying to assign a value to a temp column for something based on 2
other columns.

Select ID, Imm, Ell
From table_1
where Imm='Y' OR Ell='Y'

I want the column to report an E if or an I. Where and How do I declare?
 
If this is with an Access MDB or ACCDB database file, you could use the IIF
function:

Select ID, Imm, Ell, IIF (Imm='Y', 'I', 'E') as Expr1
From ...


For SQL-Server, you will need to use the Case statement:

Select ID, Imm, Ell, Case When Imm='Y' Then 'I' Else 'E' End as Expr1
From ...

Of course, if both Imm and Ell equal 'Y', then the above solutions might not
be what you want to get.

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)
 
Back
Top