how to get the maximum among two tables,for example table 1
(dep1) have (emp_id,emp_name,salary) columns and table 2
(dept2) have (emp_id,emp_name,salary) columns,i want which
employee have the maximum salary among two tables?

Answer Posted / newbie

SELECT MAX(E.Salary) FROM
(SELECT MAX(Salary) SalaryFROM dep1
UNION
SELECT MAX(Salary) Salary FROM dep2) E

Is This Answer Correct ?    36 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how we use window authentication connection with sql server.?

615


What does executeupdate return?

528


How to find tables without indexes?

617


What are entities and relationships?

544


Tell me what is difference between view and materialized view?

512






Differentiate between SQL and ORACLE joins and write their syntax.

577


What are the extra roles available in msdb? : sql server security

629


How to recompile stored procedure at run time?

562


How to drop existing indexes in ms sql server?

577


How to Insert multiple rows with a single insert statement?

541


Characterize join and name diverse sorts of joins?

522


Explain the steps to use transact-sql cursor?

516


What are the advantages of sql azure?

116


What are the disadvantages of indexes?

522


Differentiate between truncate vs delete in mssql?

518