Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 are the types of indexing?

1084


What are the different types of Indexes available in SQL Server?

1010


Explain primary key?

974


How to insert and update data into a table with "insert" and "update" statements?

990


What is the difference between left and right outer join?

1071


What are the types of user defined functions in sql server?

1055


How to make remote connection in database?

1012


How can I get data from a database on another server?

1002


What is outer join in sql server joins?

1126


How do I start and stop sql server?

1030


Where is localdb stored?

947


Mention the different types of replication in sql server.

1032


What are the disadvantages of using the stored procedures?

1110


How do I change my passwords (database, LDAP, and so on) without causing an outage?

1072


What is conditional split?

1088