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


Please Help Members By Posting Answers For Below Questions

What is difference between oltp and olap?

580


What is the difference between system objects and user objects?

711


What is extended stored procedures?

576


What samples and sample databases are provided by microsoft?

579


What is the syntax to execute the sys.dm_db_missing_index_details? : sql server database administration

631






Is null vs coalesce?

511


What is the difference between delete and truncate statements?

576


Do you know what is similarity and difference between truncate and delete in sql?

581


How do I find my localdb version?

500


What is database isolation in sql server? : sql server database administration

570


What are the authentication modes in sql server? How can it be changed?

607


What is the difference between Clustered and Non-Clustered Index?

610


What is the need for indexing?

504


What are the difference between data mart and data warehouse? : sql server analysis services, ssas

510


Explain what is the main purpose of having conversation group?

527