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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
try that
SELECT [No], Count1, Count2,
IIf(nz([Count1],0)>nz([Count2],0),[Count1],[Count2]) AS Result
FROM MyTableName
 
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
 
Back
Top