Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Select min value from multiple tables

Posted on 2010-01-12
1
Medium Priority
?
377 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
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

580 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