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 / lince p. thomas

select T.empname,salary from
(
select a.empname as empname ,a.salary as salary from dep1 a
union all
select b.empname as empname,b.salary as salary from dept2 b
)T where T.salary=(select max(T.salary) as salary from
(select max(a.salary) as salary,a.empname as empname
from dep1 a group by a.empname
union all
select max(b.salary)as salary,b.empname as empname from
dept2 b group by b.empname)T
)

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create a new table in a given schema?

1112


Relational calculus is what type of language?

976


Why de-normalization required?

941


How to read data in a table with "select" statements?

918


Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

948


How does stuff differ from the replace function?

957


How does SSIS(Sql Server Integration Services) deffer from DTS(Data Transformation Services)?

1131


How to loop through result set objects using odbc_fetch_row()?

919


Where are stored procedures in sql server?

1007


Explain what are magic tables in sql server?

947


How you trouble shoot when any job fails

1894


Is sql server free?

870


How to select some specific rows from a table in ms sql server?

961


Explain indexes disadvantages?

1010


What is the report model project?

130