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 are the advantages of mirroring?
Explain stored procedure?
How to recompile stored procedure at run time?
What is not null constraint?
What is dbcc updateusage?
Can we make the the chages By Using the Sql if u know any function or process please inform me Actuall result: BRK1 Break 1 Part 1 00:01:00:00 60 BRK1 Break 1 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 BRK2 Break 2 Part 2 00:01:00:00 60 BRK2 Break 2 Part 3 00:01:00:00 60 BRK3 Break 3 Part 1 00:01:00:00 60 BRK3 Break 3 Part 2 00:01:00:00 60 Desired O/P: BRK1 Break 1 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 Part 3 00:01:00:00 60
What do you understand by physical_only option in dbcc checkdb?
What are date and time data types in ms sql server?
Tell me what is the stuff and how does it differ from the replace function?
How and why use sql server?
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 the maximum size of a row in sql server?
What were the latest updates to SQL Azure service?
How to remove duplicate rows from table except one?
Can you explain full-text query in sql server?