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
Explain mixed authentication mode of sql server?
What is the difference between stored procedure and user defined functions?
what is isolation level at dead lock?
What do you mean by stored techniques? How would we use it?
What are dml triggers and types of dml triggers?
What is exclusive locks?
Explain how to send email from sql database?
How to delete duplicate rows from table except one?
How to set the current database in ms sql server?
Do you know how to send email from database?
How to update values in a table with update statements in ms sql server?
How to run queries with sql server management studio express?
Write down the syntax and an example for create, rename and delete index?
What is lock escalation? : sql server database administration
Can you explain what is sql server english query?