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 / sumathy
Use Cursors:
declare Cursor_Name cursor scroll
for
select max(salary) as salary from dep1
union
select max(salary) as salart from dep2 order by salary desc
open Cursor_Name
fetch absolute 1 from Cursor_Name
deallocate Cursor_Name
Is This Answer Correct ? | 13 Yes | 2 No |
Post New Answer View All Answers
What is difference between oltp and olap?
What is the difference between system objects and user objects?
What is extended stored procedures?
What samples and sample databases are provided by microsoft?
What is the syntax to execute the sys.dm_db_missing_index_details? : sql server database administration
Is null vs coalesce?
What is the difference between delete and truncate statements?
Do you know what is similarity and difference between truncate and delete in sql?
How do I find my localdb version?
What is database isolation in sql server? : sql server database administration
What are the authentication modes in sql server? How can it be changed?
What is the difference between Clustered and Non-Clustered Index?
What is the need for indexing?
What are the difference between data mart and data warehouse? : sql server analysis services, ssas
Explain what is the main purpose of having conversation group?