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 command is used to create a database in the sql server and how?
How to create a view with data from multiple tables?
What new changes are being made in SQL Server?
What are the benefits of filtered indexes?
How to enter binary string literals in ms sql server?
What do you know about system database? : SQL Server Architecture
Does dbcc checkdb requires db to be in single_user mode? : sql server database administration
What is difference between count (*) and count column?
Why use identity in sql server?
what is the system function to get the current user's user id? : Sql server database administration
What number sorts of privileges are accessible in sql?
I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that
How to skip remaining statements in a loop block using continue statements?
What is "scheduled jobs" or "scheduled tasks"?
What do you mean by a Composite primary key?