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 / kaka

create table #temp
(salary numeric(18,0)
)
insert into #temp
select max(salary) as salary from EmpSalary
union
select max(salary)as salary from EmpSalary1
select max(salary) from #temp
drop table #temp

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Delete duplicate rows without using rowid.

1078


How many levels of sp nesting are possible?

559


Help!!!!!!!!!!!! My database has gone offline, it is highlighted as 'Suspect'. Foolishly, i haven't got a recent back up. Is there a way of quickly restoring the database? Thank you

1307


What are translations and its use? : sql server analysis services, ssas

611


What is a file group?

628






What is collation?

717


Explain Geometry datatype in sql server 2008 with example

595


What is data file in computer?

547


What is the tcp/ip port on which sql server runs?

570


Does partitioning ssd reduce performance?

495


Explain what is cte (common table expression)?

632


Tell me what do you mean by an execution plan? Why is it used? How would you view it?

532


What are “phantom rows”?

1249


How to test a dml trigger in ms sql server?

583


What is the chart in report?

111