Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the difference between a unique key and primary key?

894


Is null vs coalesce?

815


How to connect to a sql server using odbc_connect()?

1093


What happens when unicode strings concatenate with non-unicode strings?

1000


Determine when to use stored procedure to complete sql server tasks?

985


Explain multiserver query

961


What is Transparent Data Encryption?

938


Is the log file is a part of file group?

974


How to find related tables in sql server?

870


Do you know data definition language, data control language and data manipulation language?

981


How to call stored procedure using http soap?

998


what is the main function of a query parameter?

140


What are system databases into sql server (2005/2008)?

953


What is the distinction amongst delete and truncate?

1000


What is normalization 1nf 2nf 3nf?

1003