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 / swati tripathi

SELECT
OUTERTABLE.EMPID,
MAX(OUTERTABLE.SALARY)

FROM

(SELECT EMPID,MAX(SALARY) AS SALARY
FROM DEP1
GROUP BY EMPID
UNION ALL
SELECT EMPID,MAX(SALARY) AS SALARY
FROM DEP2
GROUP BY EMPID) AS OUTERTABLE
GROUP BY OUTERTABLE.EMPID

Is This Answer Correct ?    8 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between triggers and stored procedures?

1070


Explain data warehousing in sql server?

1051


A trigger can reference objects outside the current database? State true or false.

1010


What does COMMIT command do?

1067


How do we Backup SQL Azure Data?

108


How to change parameter value inside the report?

164


Where views are stored in sql server?

987


How we can refresh the view?

1108


How to optimize stored procedures in sql server?

1185


After removing a table from database, what other related objects have to be dropped explicitly?

1055


List the different normalization forms?

984


Which operator do you use to return all of the rows from one query except rows are returned in a second query?

992


What is a print index?

886


Can we use where clause with group by?

904


What is serializable?

1044