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 are the types of indexing?
What are the different types of Indexes available in SQL Server?
Explain primary key?
How to insert and update data into a table with "insert" and "update" statements?
What is the difference between left and right outer join?
What are the types of user defined functions in sql server?
How to make remote connection in database?
How can I get data from a database on another server?
What is outer join in sql server joins?
How do I start and stop sql server?
Where is localdb stored?
Mention the different types of replication in sql server.
What are the disadvantages of using the stored procedures?
How do I change my passwords (database, LDAP, and so on) without causing an outage?
What is conditional split?