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 the cartesian product of the table?
What is the command used to check locks in microsoft sql server?
What is 3nf normalization?
Is it true, that there is no difference between a rule and a check constraint?
Can you explain different types of joins?
What is TDS(Tabular Data Stream) Gateway?
Do you know what is sql injection?
What is a full text index?
What does asynchronous call backs means?
How will you optimize a stored procedure optimization?
What stored by the model? : sql server database administration
Explain database normalization?
What is indexing a document?
Tell me something about security and sql azure?
Explain the different types of backups available in sql server? : sql server database administration