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 / praveend

Try this. I have tried it.

Select id, name, Max(salary) as salary from
(Select id, name, salary from emp where salary = (Select
Max(salary) from emp)
Union
Select id, name, salary from emp1 where salary = (Select
Max(salary)from emp1)) as B


where salary = (
Select Max(salary) as salary from
(Select id, name, salary from emp where salary = (Select
Max(salary) from emp)
Union
Select id, name, salary from emp1 where salary = (Select
Max(salary)from emp1)) as C
)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of for clause?

585


What is difference between view and materialized view?

542


What are the instances when triggers are appropriate?

529


How to receive output values from stored procedures?

487


Explain where clause?

539






What is the difference between upgrade and migration in sql server?

598


How to sort query output in descending order in ms sql server?

551


What is the significance of null value and why should we avoid permitting null values?

538


How do I create a trace in sql server?

520


Explain different types of Normalization.

601


What happens when the SQL Azure database reaches Max Size?

90


What is standby servers? Explain types of standby servers.

518


How do I setup a local sql server database?

540


What are magic tables in sql server?

630


How to grant a permission in ms sql server using "grant execute" statements?

571