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

Why variables called the most powerful component of ssis?

1127


Explain can SSRS reports Cache results?

161


What is constraints and its types?

999


How to insert data with null values?

1082


What is the difference between SQL notification and SQL invalidation?

1267


What is system stored procedures?

1089


What is resultset concur_updatable?

1055


What to perform pattern match with the like operator?

936


How to make conditional sum in ssrs?

183


What are date and time data types in ms sql server?

1161


What are ddl triggers and types of ddl trigger?

1096


Can you type more than one query in the query editor screen at the same time?

1069


What are the disadvantages of using the stored procedures?

1190


What is wrong with sql server client libarary dll, ntwdblib.dll?

1094


What is a schema in ms sql server 2005?

1027