Select ... from ((Select ...)(Select...))

J

John

I have two Select statements and each generates a number. I want to build
another Select statement that returns the max number of those two numbers.
Please help.

Thanks.
 
O

Ofer

You dont need to queries, you can use one query to return the max of each
table and the max between the two
Create a query add both tables to the query without a link between them
Try this

SELECT Max(MyTable1.MyNumber) AS MaxMyNumber1, Max(MyTable2.MyNumber) AS
MaxMyNumber2,
IIf(Max([MyTable1].[MyNumber])>Max([MyTable2].[MyNumber]),Max([MyTable1].[MyNumber]),Max([MyTable2].[MyNumber])) AS MaxBetweenTheTwo
FROM MyTable1, MyTable2

If Both fields are on the same table then
SELECT Max(MyTable.MyNumber1) AS MaxMyNumber1, Max(MyTable.MyNumber2) AS
MaxMyNumber2,
IIf(Max([MyTable].[MyNumber1])>Max([MyTable].[MyNumber2]),Max([MyTable].[MyNumber1]),Max([MyTable].[MyNumber2])) AS MaxBetweenTheTwo
FROM MyTable1
 
Top