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 can you tell if a database object is invalid?

1074


Call by value and call by reference in procedure and function, with NOCOPY.

1306


What is the difference between a stored procedure and a user defined function?

1020


What do we need queues in sql service broker?

1065


How to execute function in stored procedure sql server?

1153


What do you understand by the denormalisation?

957


Can I disable or restrict ssrs export formats (rendering formats)?

150


What will happen if a column containing char type data is changed to the nchar data type?

1102


What are the different types of normalization?

1165


what kind of lan types do you know? : Sql server database administration

980


In how many ways you can invoke ssrs reports?

139


What is the difference between mysql and sql server?

1024


How do I save a stored procedure in sql server?

996


Can you explain various data region available in ssrs with their use?

976


What is difference between Datepart() and Datename() in SqlServer?

1203