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

How do you drop an index?

501


Relational calculus is what type of language?

576


What is a ddl statement?

511


What is the purpose of the model database?

598


explain databases and sql server databases architecture? : Sql server database administration

521






How would we use distinct statement? What is its use?

603


List some major differences between triggers and stored procedures?

522


What is named calculation? : sql server analysis services, ssas

531


How to create a new schema in a database?

551


What is resultset concur_updatable?

584


how to control the amount of free space in your index pages? : Sql server database administration

598


Can two different columns be merged into single column? Show practically?

608


What is 3nf normalization form?

563


Can primary key be null?

513


How to create database with physical files specified in ms sql server?

542