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
What is normalization process?
Explain different forms of normalization?
SQL Server Architecture ?
What is the optimization being performed in oracle and SQL Server?
What are the triggers in sql?
What are constraints in microsoft sql server?
What is the full form of ddl?
System requirements for sql server 2005 express edition?
Can a table have 2 foreign keys?
How to manipulate data from one table to another table ?
What type of Index will get created after executing the above statement?
How do I save a stored procedure in sql server?
What is difference between equi join and inner join?
What are unicode character string data types in ms sql server?
Define inner join? Explain with an example?