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 are the advantages of partitioning?
Why use update_statistics command in sql server?
What does REVERT do in SQL Server 2005?
What is use of attribute hierarchy optimized state? : sql server analysis services, ssas
What is SQL Server?
What are the different Authentication modes in SQL Server and how can you change authentication mode?
How to make remote connection in database?
What is server-level principal?
Different types of keys in SQL?
Why functions are used in sql server?
What is a deadlock and what is a live lock?
How do I partition a table in sql server?
What is an execution plan? When would you use it?
What are sub reports and how to create them?
What is spid in sql server profiler?