SQL Query

G

Guest

My data table is like this:

Type Price1 Price2 Price3 Result
Black 2 2 3 No
Blue 2 5 6 Yes
Black 0 4 5 Yes
Red No

I am try to find an SQL query that will create the new Field "Result" based
on the following criteria:

IF Type =Black and (Price1>Price2) OR Price1=0 Return "Yes" OtherWise "No"

OR

IF Type=Blue and (Price1<Price3) OR Price1=0 Return "Yes" OtherWise "No"

OR

IF Type<>Blue OR Black Return "No"

Is this type of query possible ?

Thank You in Advance.
 
J

Jason Lepack

Expr1: IIf(Not ([Type]='Black' Or
[type]='Blue'),'No',IIf([Type]='Black',IIf([Price1]>[Price2] Or
[price1]=0,'Yes','No'),IIf([price1]<[price3] Or
[price1]=0,'Yes','No')))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top