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 BCNF? How is it better than 2NF & 3NF?
What is scan table/view and seek table/view when its occurs? : sql server database administration
Explain identity in sql server?
To automatically record the time on which the data was modified in a table, which data type should you choose for the column?
Suggest a method of joining two tables.
What gets stored inside msdb database?
What is the optimal disk configuration for a database server and what raid configurations would you use if budget is not a constraint?
What is subquery? Explain the properties of a subquery?
Explain the concept of recursive stored procedure.
How do you migrate data from mssql server to azure?
What is use of attributehierarchyenabled? : sql server analysis services, ssas
What is mean by candidate key?
Can you type more than one query in the query editor screen at the same time?
What program is used to store the data source file?
How to create a dml trigger using create trigger statements?