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

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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is BCNF? How is it better than 2NF & 3NF?

1020


What is scan table/view and seek table/view when its occurs? : sql server database administration

1060


Explain identity in sql server?

1016


To automatically record the time on which the data was modified in a table, which data type should you choose for the column?

966


Suggest a method of joining two tables.

1165


What gets stored inside msdb database?

1255


What is the optimal disk configuration for a database server and what raid configurations would you use if budget is not a constraint?

976


What is subquery? Explain the properties of a subquery?

990


Explain the concept of recursive stored procedure.

965


How do you migrate data from mssql server to azure?

165


What is use of attributehierarchyenabled? : sql server analysis services, ssas

1243


What is mean by candidate key?

1014


Can you type more than one query in the query editor screen at the same time?

1011


What program is used to store the data source file?

968


How to create a dml trigger using create trigger statements?

1038