Query with if statement :/
Hi. I need to create a view, where i have some informations column about product. I have columns like that:
ID(int), Name(varchar), Price(money), Tax(bit)
I need to create a query where if Tax=1 then in Price column show a Price=Price+22%, when Tax=0 then Price=Price+7%. How to do that?
I want to result look like that:
|ID|Name|Price|
Any sugestions?
Thaks
[387 byte] By [
beeper] at [2007-11-19 17:12:37]

# 1 Re: Query with if statement :/
Add a column to the DataTable. Set the expression property of this DataColumn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.asp
Use the IIF to use conditions in the expressions (you can set conditions to other columns.
# 2 Re: Query with if statement :/
I want to use a IIF function, but sql server drop an error statment.
when i have this query: "select iif(Tax=1, "yes","no") from table" i have "Incorrect syntax near '='."
What is wrong?
beeper at 2007-11-10 3:31:37 >

# 3 Re: Query with if statement :/
DataColumn.Expression="IIF(Tax=0, 'yes', 'no')";