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 / veeresh kethari

User CTE:

with Temp as(select max(sal) Sal from Table1
union
select max(sal) sal from Table2)
select top 1 * from Temp order by sal desc

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create a ddl trigger using "create trigger" statements?

1071


How do I create a partition table in sql server?

1049


What is the command used to recompile the stored procedure at run time?

1018


How to start and end transact-sql statements?

971


What happens on checkpoint?

969


Stored Procedure returns data from multiple tables. How to access it in your ASP.Net code?

1007


What are date and time data types in ms sql server?

1021


Explain transaction server isolation?

982


System variable and temporary variables

2185


What is the full form of ddl?

866


What is implicit mode in sql server?

1030


Will sql server 2005 allow you to reduce the size of a column?

920


How to recompile stored procedure at run time?

1006


What is a derived table?

872


what method you can use to reduce the overhead of Reporting Services data sources?

234