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
What is the distinction amongst delete and truncate?
Show Practically Sql Server Views are updatable?
What do you mean by stored techniques? How would we use it?
What is default constraint in ms sql server?
Can you explain what are various ways to enhance the ssrs report?
Explain about local stored procedure?
How does a profiler work?
What is user defined datatypes and when you should go for them?
What is outer join in sql server joins?
List some major differences between triggers and stored procedures?
What are the hotfixes and patches in sql server?
I have triggers,views,functions,stored Procedures for a table. When I am dropping that table which objects are deleted?
Are null values the same as that of zero or a blank space?
Can You Use A Stored Procedure To Provide Data To An Ssrs Report?
Explain the different types of backups available in sql server? : sql server database administration