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

what are the basic functions for master, msdb, model, tempdb and resource system databases? : sql server database administration

563


What is a data source or ds? : sql server analysis services, ssas

563


Can we add a cpu to sql server?

520


How to list all schemas in a database?

578


which table keeps the locking information? : Sql server administration

517






How to enter date and time literals in ms sql server?

508


Explain what role entity and relationship play in an ER diagram.

571


What is the sql server agent?

584


Explain magic tables in sql server?

547


Define left outer join in sql server joins?

560


What happens if strings are casted into wrong code pages in ms sql server?

564


Give the query of getting last two records from the table in SQL SERVER?

537


What are the different Topologies in which Replication can be configured?

645


How many databases Microsoft SQL server provides?

610


hi i am working as a testengineer , so i want to no the backend data base connection can any one tell mwe in detail

1781