Tuesday, January 20, 2009

SQL:Find top salary among two tables

To find highest salary between 2 tables, the following query will be helpful


SELECT TOP 1 sal
FROM (SELECT MAX(sal) AS sal
FROM sal1
UNION
SELECT MAX(sal) AS sal
FROM sal2) a
ORDER BY sal DESC

No comments:

Post a Comment