Need query to compare three columns and return a fourth column

  • Thread starter Thread starter Scott Whitinger via AccessMonster.com
  • Start date Start date
S

Scott Whitinger via AccessMonster.com

I have a table that I need to Compare 2 columns, when they match then
compare 2 others columns and return the results of a 4 column.

IF (Column1=column2 and column 3 is greater than column 4 or > column 5
then return column 6),0

Any help would be appreciated.
 
I have a table that I need to Compare 2 columns, when they match then
compare 2 others columns and return the results of a 4 column.

IF (Column1=column2 and column 3 is greater than column 4 or > column 5
then return column 6),0

Any help would be appreciated.

The IIF() function will help here. The first argument is an expression
which evaluates to TRUE or FALSE; if it's TRUE it returns the second
argument; if it's FALSE it returns the third. E.g.

IIF([Column1] = [Column2] AND ([Column3] > [Column4] OR [Column3] >
[Column5]), [Column6], 0)

Note that the OR operator *is a mathematical operator*, not an English
language conjunction; the syntax "column3 > column4 or > column5" will
NOT work since the OR needs to have two true/false operands to its
left and right, and the expression " > column5" is not such an
operand.


John W. Vinson[MVP]
 
Back
Top