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
What are the recovery models for a database?
What is transact-sql ddl trigger?
How to round a numeric value to a specific precision?
Is INSTEAD OF trigger directly applicable to Table ?
How to create new tables with "select ... Into" statements in ms sql server?
Tell me about normalization in DBMS.
In which format does an image save in SQL Server database ?
What is a primary key?
How column data types are determined in a view?
List out different types of normalizations in sql server and explain each of them?
If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?
What to perform pattern match with the like operator?
How to defragment indexes with alter index ... Reorganize?
What is the recovery model?
How to insert multiple rows with one insert statement in ms sql server?