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 many no of arguments can be passed in procedures and functions

4781


Can we install sql server 2016 on windows 7?

671


What is report snapshot?

99


Call by value and call by reference in procedure and function, with NOCOPY.

838


If no size is defined while creating the database, what size will the database have?

545






Do you know what is blocking?

541


Define inner join? Explain with an example?

516


What is the difference between ddl and dml?

568


Explain different types of collation sensitivity?

533


Define inner join in sql server joins?

533


Where actually sql azure database is hosted?

149


Can a stored procedure call itself or recursive stored procedure? How many levels sp nesting is possible?

520


Explain the purpose of indexes?

544


Can you explain various data region available in ssrs with their use?

548


How do indexes help, types?

551