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
How to create and drop temp table in sql server?
How to create a scrollable cursor with the scroll option?
How to connect to SQL Azure Database by using sqlcmd?
What is db stored procedure?
What are the different Authentication modes in SQL Server and how can you change authentication mode?
What is table value parameters (tvp)?
Explain about analysis services?
What is raid, and how it can influence database performance?
What is a group function explain with an example?
How to test odbc dsn connection settings?
What are the different types of sql server replication? : sql server replication
How do you Implement SSIS Packages in your Project?
How to create function without parameter in sql server?
What is the difference between char and varchar2 datatype in sql?
What is table join?