Denis wrote:
Hi,
I want to find out how to find the maximum number from a number of
different fields .
ie find the max number between field1, field2 and field3 in a table
using a query
Regards,
Denis
Probably a VBA function is the most efficient way to find MaxOf per row,
then use SQL to get the Max() of the MaxOf:
(not tested)
Public Function MaxOf (Val1, Val2, Val3) As Double
Dim tmp1 as double
Dim tmp2 as double
Dim tmp3 as double
tmp1 = Abs(Val1-Val2)
tmp2 = Abs(Val1-Val3)
tmp3 = Abs(Val2-Val3)
If tmp1 tmp2 and tmp1 tmp3 Then
MaxOf = tmp1
ElseIf tmp2 tmp3 Then
MaxOf = tmp2
Else
MaxOf = tmp3
EndIf
End Function
SELECT Max(MaxOf(Field1, Field2, Field3))
GROUP BY ???;
--
Smartin