?
Solved

Select min value from multiple tables

Posted on 2010-01-12
1
Medium Priority
?
364 Views
Last Modified: 2012-05-08
Lets say I have 4 tables all with different loc_id values(10,15,20,10). How do I select the min value found in all 4 tables.

select min(loc_id)  from table1
select min(loc_id)  from table2
select min(loc_id)  from table3
select min(loc_id)  from table4

Results:
1| 10
--------
1| 15
--------
1| 20
-------
1|10

what I would like is 1 row with the value:10


0
Comment
Question by:byteboy11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 total points
ID: 26299133
SELECT MIN(locID) from
(
select min(loc_id) locid  from table1
union
select min(loc_id)  from table2
union
select min(loc_id)  from table3
union
select min(loc_id)  from table4 )A
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question