ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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?
 Question Submitted By :: Sabarish.2meet
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
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 ?    3 Yes 0 No
Sumathy
 
  Re: 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
# 2
SELECT 
OUTERTABLE.EMPID,
MAX(OUTERTABLE.SALARY) 

FROM

(SELECT EMPID,MAX(SALARY) AS SALARY
FROM DEP1 
GROUP BY EMPID
UNION ALL
SELECT EMPID,MAX(SALARY) AS SALARY
FROM DEP2
GROUP BY EMPID) AS OUTERTABLE
GROUP BY OUTERTABLE.EMPID
 
Is This Answer Correct ?    2 Yes 0 No
Swati Tripathi
 
 
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
Can you explain the types of Joins that we can have with Sql Server?  2
what is index seek and index scan?  2
How to give a user the option of importing Excel and a delimited text file into a SQL Server Database without manually using SQL DTS? GE1
what is the query and condition to delete datas in sql server.  2
Explain different isolation levels?  3
what is the maximum size of a row in sql server 2000 and 2005  2
write down the code for "how we delete a table without using of Drop command " ? Sonata2
What is the datatype returned by count(*) Asian-CERC18
What is lock escalation?  1
How can you see what type of locks used?  1
What is a cursor in SQL Server 2000 and their types?  4
How do we rollback the table data in SQL Server  3
How can we write or define DDL statements in Sql server and DML statements?  2
can primery key be a non clustered index?  8
when we use function instead of procedure? plz tell me the situation with ex?  1
WHAT OPERATOR PERFORMS PATTERN MATCHING? CTS2
what is Data Transformation Services (DTS) ?can u explain me in detail? TCS5
Questions on identity? Infosys1
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?  1
what is Archive old data?  1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com