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

How many types of keys are there?

522


It is important form e to get the information from log files of applications executed by the task scheduler? Does sql studio save these log files? : sql server management studio

545


What is report rendering ?

102


How does clustered and non clustered index work?

507


What is the use of keyword with encryption. Create a store procedure with encryption?

571






Define a cross join?

583


Explain transaction server consistency?

516


How can delete duplicate records in cte in sql server?

506


What does COMMIT command do?

618


What are the dis_advantages of stored procedures, triggers, indexes?

1675


What is a fan-out query in SQL Azure?

99


How to make a column nullable?

586


Explain four layers of abstraction microsoft architectured?

120


what are the different types of SSRS reports?

108


Explain what are magic tables in sql server?

530