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
How to create a ddl trigger using "create trigger" statements?
How do I create a partition table in sql server?
What is the command used to recompile the stored procedure at run time?
How to start and end transact-sql statements?
What happens on checkpoint?
Stored Procedure returns data from multiple tables. How to access it in your ASP.Net code?
What are date and time data types in ms sql server?
Explain transaction server isolation?
System variable and temporary variables
What is the full form of ddl?
What is implicit mode in sql server?
Will sql server 2005 allow you to reduce the size of a column?
How to recompile stored procedure at run time?
What is a derived table?
what method you can use to reduce the overhead of Reporting Services data sources?