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

Is it possible to call a stored procedure within a stored procedure?

917


Scalability, Availability, Integration with internet, etc.)?

2824


what is spatial nonclustered index

945


How we create SQL Server 2005 Reporting Services ? Give me Sample

1940


What are the tables in sql?

1041


can a database be shrunk to 0 bytes, if not, why? : Sql server administration

1118


What are the main sources of data?

1040


What is difference between count (*) and count column?

841


What is a not null constraint?

977


what are defaults? : Sql server database administration

1008


What is the use of custom fields in report?

948


How to check status of stored procedure in sql server?

914


How to define the name and server for a new dsn?

1009


What is the syntax for encrypting a column in SQL Server?

1060


What is temporary stored procedure?

899