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

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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is normalization process?

604


Explain different forms of normalization?

534


SQL Server Architecture ?

1938


What is the optimization being performed in oracle and SQL Server?

632


What are the triggers in sql?

561






What are constraints in microsoft sql server?

565


What is the full form of ddl?

513


System requirements for sql server 2005 express edition?

571


Can a table have 2 foreign keys?

511


How to manipulate data from one table to another table ?

550


What type of Index will get created after executing the above statement?

647


How do I save a stored procedure in sql server?

497


What is difference between equi join and inner join?

486


What are unicode character string data types in ms sql server?

609


Define inner join? Explain with an example?

518