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 / saurabh agrawal
select top 1 empid, empname, max(salary) from (
Select empid, empname, salary = max(salary) from dep1 group
by empid, empname
union all
Select empid, empname, salary = max(salary) from dep2 group
by empid, empname
)A
group by empid, empname order by max(salary) desc
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What do you mean by an execution plan? How would you view it?
What is bcp? When does it use?
List the types of recovery model available in sql server?
What is truncate table?
Which tools are available to manage SQL Azure databases and servers?
Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?
How do I completely remove sql server instance?
I have triggers,views,functions,stored Procedures for a table. When I am dropping that table which objects are deleted?
What do you understand by physical_only option in dbcc checkdb?
Explain four layers of abstraction microsoft architectured?
What are the types of subquery?
What are the events recorded in a transaction log?
What is the use of custom fields in report?
What is a collation?
explain the storage models of olap? : Sql server database administration