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 / lince p. thomas
select T.empname,salary from
(
select a.empname as empname ,a.salary as salary from dep1 a
union all
select b.empname as empname,b.salary as salary from dept2 b
)T where T.salary=(select max(T.salary) as salary from
(select max(a.salary) as salary,a.empname as empname
from dep1 a group by a.empname
union all
select max(b.salary)as salary,b.empname as empname from
dept2 b group by b.empname)T
)
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why I have to use stored procedures?
I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration
how you can configure a running aggregate in SSRS?
Why do we use functions?
What is database replication?
Can you explain powershell included in sql server 2008?
What is a field in a table?
Is it possible to update the views? If yes, how, if not, why?
Can you explain what are various ways to enhance the ssrs report?
Explain few examples of RDBMS?
You want your report to display a hyperlink that will take users to your intranet. How do you configure such a hyperlink?
What is the purpose of indexing?
Explain how many normalization forms?
Do you know what is difference between index seek vs. Index scan?
Which are the two editions in which SQL Azure database available?