how to compare 2 columns in a table in MS access.

J

Jo

I have a table and would like to compare 2 columns and get the max of the two

eg:

No: Count 1 count 2 Result
123 1 2 2
234 1 1 1
234 2 1 2
344 3 2 3
345 2 3 3
 
O

Ofer

try that
SELECT [No], Count1, Count2,
IIf(nz([Count1],0)>nz([Count2],0),[Count1],[Count2]) AS Result
FROM MyTableName
 
M

Marshall Barton

Jo said:
I have a table and would like to compare 2 columns and get the max of the two

eg:

No: Count 1 count 2 Result
123 1 2 2
234 1 1 1
234 2 1 2
344 3 2 3
345 2 3 3


SELECT no, count1, count2,
IIf(count1 > count2, count1, count2) As Result
FROM Table
 
Top