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 current pricing model of SQL Azure?

104


Which are the important points to note when multilanguage data is stored in a table?

1004


what's the maximum size of a row? : Sql server database administration

1094


What's new in sql management studio for sql server? : sql server management studio

1068


Find first and last day of current month in sql server

1028


You have modified 100 store procedures and want to replicate these changes from development to prodution, and production can have users using the Server/DB, how would you replicate without causing issues?

2154


Will count(column) include columns with null values in its count?

1104


Explain important index characteristics?

1042


what is the difference between count(*) and count(1) ?

1091


How to update muliple row in single query?

1065


Why union all is faster than union?

915


How and why use sql server?

1016


What are different replication agents and what's their purpose? : sql server replication

1026


What is the difference between a local and a global temporary table?

1126


what is raid and what are different types of raid configurations? : Sql server database administration

1049