View Full Version : creating calculated field with two expressions


peacemaka
08-06-2007, 11:49 PM
Hi guys,

I am writing a select query and need an extra column which will be calculated using two tables.

The problem i am having is that i need to to say basically, return value A if value from table x < value from table y or return value B if value from table x > value from table y.

I tried using the HAVING clause but you cant use the if function with this it seems.

Your help is most appreciated.

neileg
08-07-2007, 02:25 AM
Do you need the HAVING clause? Can't you do the comparisons in a couple of nested Iif() statements?

Iif([FieldX]<[FieldY],A,Iif([FieldX]>[FieldY],B,Something in here to fit when [FieldX]=[FieldY])

peacemaka
08-07-2007, 04:55 AM
thanks ill give it a try :D