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

In which tcp/ip port does sql server run? Can it be changed?

536


What is the difference between function and stored procedure in sql server?

478


What is compound operators?

536


how can a database be repaired? : Sql server administration

509


How do I make a resultset scrollable?

492






how would you improve etl (extract, transform, load) throughput?

530


Explain atomicity?

567


How to encrypt data between dialogs?

559


Difference between connected and disconnected database in .net with sql server?

566


Can you explain what are various ways to enhance the ssrs report?

575


what is an extended stored procedure? : Sql server database administration

490


Explain various On-Delete options in a DB table. Which is the default option?

885


What is the Disadvantage of indexed sequential file.

605


What is query parameter in ssrs?

118


Why truncate is ddl?

598