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
List out the difference between union and union all in sql server?
What is the difference between getdate and sysdatetime?
What are 3 ways to get a count of the number of records in a table?
Explain full-text indexing?
What is raid, and how it can influence database performance?
Does union all remove duplicates?
How to create an multi-statement table-valued function?
Explain the commands in sql server?
Do you know what is raid and what are different types of raid configurations? : SQL Server Architecture
Define model database?
Explain the types of indexes.
How to drop an existing stored procedure in ms sql server?
What are the diifferences between the ms sql server vs mysql?
What is merge join?
explain extended properties