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 / praveend

Try this. I have tried it.

Select id, name, Max(salary) as salary from
(Select id, name, salary from emp where salary = (Select
Max(salary) from emp)
Union
Select id, name, salary from emp1 where salary = (Select
Max(salary)from emp1)) as B


where salary = (
Select Max(salary) as salary from
(Select id, name, salary from emp where salary = (Select
Max(salary) from emp)
Union
Select id, name, salary from emp1 where salary = (Select
Max(salary)from emp1)) as C
)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create and drop temp table in sql server?

1060


How to create a scrollable cursor with the scroll option?

1004


How to connect to SQL Azure Database by using sqlcmd?

136


What is db stored procedure?

883


What are the different Authentication modes in SQL Server and how can you change authentication mode?

1091


What is table value parameters (tvp)?

1106


Explain about analysis services?

1056


What is raid, and how it can influence database performance?

1059


What is a group function explain with an example?

993


How to test odbc dsn connection settings?

1038


What are the different types of sql server replication? : sql server replication

1278


How do you Implement SSIS Packages in your Project?

1933


How to create function without parameter in sql server?

1062


What is the difference between char and varchar2 datatype in sql?

1070


What is table join?

1127