I want a query that pulls four fields from a table, finds the maximum of those fields and appends that value as a computed field.
It seems simple enough and maybe I'm complicating it but I want to do this without writing a VB function. In other words I want it to be done using only SQL and and the expression builder. I have done this using IIF but its a monster! I have added line breaks to make it a more readable.
The four fields are S, F, O, and P.
Seems to me there must be a better way. This method is really hard to scale.
It seems simple enough and maybe I'm complicating it but I want to do this without writing a VB function. In other words I want it to be done using only SQL and and the expression builder. I have done this using IIF but its a monster! I have added line breaks to make it a more readable.
The four fields are S, F, O, and P.
Code:
iif (
IIf(Nz([Table1]![S],0)>Nz([Table1]![F],0),Nz([Table1]![S],0),Nz([Table1]![F],0))
>
IIf(Nz([Table1]![O],0)>Nz([Table1]![P],0),Nz([Table1]![O],0),Nz([Table1]![P],0))
,
IIf(Nz([Table1]![S],0)>Nz([Table1]![F],0),Nz([Table1]![S],0),Nz([Table1]![F],0))
,
IIf(Nz([Table1]![O],0)>Nz([Table1]![P],0),Nz([Table1]![O],0),Nz([Table1]![P],0))
)
Seems to me there must be a better way. This method is really hard to scale.