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

Where can you find the error log information? : sql server database administration

972


Do you know what is fill factor and pad index?

941


Give a example to search fr a string in all stored procedure in sql server.

914


Explain filtered indexes benefits?

954


What is the difference between a fill factor of 100 and 0?

922


What are the differences between triggers and stored procedures?

992


how you can list all the tables in a database?

970


What is raid? : SQL Server Architecture

1106


what is a default tcp/ip socket assigned for sql server? : Sql server database administration

1005


What is a ddl statement?

856


Do you know the different ddl commands in sql?

1000


What does REVERT do in SQL Server 2005?

919


What is the use of @@spid?

958


What are the instances when triggers are appropriate?

929


Is sql server 2016 free?

886