Search this blog

Tuesday, June 2, 2009

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

1 comment:

  1. It's ok but i want top 5 salary from two tables at a time. like in this given query we find max salary from two sal.

    ReplyDelete