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
Where can you find the error log information? : sql server database administration
Do you know what is fill factor and pad index?
Give a example to search fr a string in all stored procedure in sql server.
Explain filtered indexes benefits?
What is the difference between a fill factor of 100 and 0?
What are the differences between triggers and stored procedures?
how you can list all the tables in a database?
What is raid? : SQL Server Architecture
what is a default tcp/ip socket assigned for sql server? : Sql server database administration
What is a ddl statement?
Do you know the different ddl commands in sql?
What does REVERT do in SQL Server 2005?
What is the use of @@spid?
What are the instances when triggers are appropriate?
Is sql server 2016 free?