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

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

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top