I want to do something like this:
Select Name, IIF(Sex = 'M', 'Male', 'Female') From dbfile
select Name, if Sex='M' then 'Male' else 'Female' endif as "Sex" from
dbfile
Paul Robles
pro...@nettally.com
da...@carlson.com wrote in message ...
> Try somthing like this:
>
> select Name, if Sex='M' then 'Male' else 'Female' endif as "Sex" from
> dbfile
>
> Paul Robles
> pro...@nettally.com
>
Sheesh. I would of NEVER of thought of using a IF/ENDIF in a Query like this. Boy the
things you learn.
I just tried it out on a database I have here and works wonders. Thanks!
>Sheesh. I would of NEVER of thought of using a IF/ENDIF in a Query like this. Boy the
>things you learn.
>
>I just tried it out on a database I have here and works wonders. Thanks!
You might also be interested in the 'Case When' statement as the
If/EndIf limits you to only 2 options (as does IIF).
Eg (straight from the help):
SELECT id,
( CASE name
WHEN 'Tee Shirt' then 'Shirt'
WHEN 'Sweatshirt' then 'Shirt'
WHEN 'Baseball Cap' then 'Hat'
ELSE 'Unknown'
END ) as Type
FROM "DBA".Product
Or even better:
SELECT id, name,
( CASE
WHEN name='Tee Shirt' then 'Sale'
WHEN quantity >= 50 then 'Big Sale'
ELSE 'Regular price'
END ) as Type
FROM "DBA".Product
>