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
Why variables called the most powerful component of ssis?
Explain can SSRS reports Cache results?
What is constraints and its types?
How to insert data with null values?
What is the difference between SQL notification and SQL invalidation?
What is system stored procedures?
What is resultset concur_updatable?
What to perform pattern match with the like operator?
How to make conditional sum in ssrs?
What are date and time data types in ms sql server?
What are ddl triggers and types of ddl trigger?
Can you type more than one query in the query editor screen at the same time?
What are the disadvantages of using the stored procedures?
What is wrong with sql server client libarary dll, ntwdblib.dll?
What is a schema in ms sql server 2005?