"dave k" wrote in message
...
Is there a way to embed an if statement into a SQL select? I want to make
a
select output field = to one thing if a field is 1 and different if a
field
is < 1. I am using Excel to perform all queries. If possible it might
look
like this but I don't see if the IF is supported. If not, is there a
workaround?
SELECT F1, F2, IF(F11,F1*3,F1*2) FROM ATABLE
Thanks,
Dave
It's called a CASE expression in SQl Server:
http://www.craigsmullins.com/ssu_0899.htm
Your query would end up like this:
SELECT F1, F2,
F3 = CASE F1
WHEN F1 1 THEN F1 * 3 ELSE F1 * 2
END,
FROM ATABLE
/Fredrik
/Fredrik