Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Max() value between two tables

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
What is the best way to get the maximum value of a "like" field in two tables?

(I.e.

Table1 - Field1 - Values: 0002, 0003, 0005
Table2 - Field1 - Values: 0001, 0005 )

Result should be: 0005
 
Code:
select max(field1) as max_field1
  from (
       select field1
         from table1
       union
       select field1
         from table2
       ) as u

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top