Their are two tables 'A' and'B'.Table 'A' contains 3 columns
named 'eid','ename','dept'.
Table 'B'contains 3 columns
named'sid','designation','salary'.
We have to retrieve the names of employees working in the
same department,same designation and same salary.
Its urgent can anyone help me out in this problem.

Answers were Sorted based on User's Feedback



Their are two tables 'A' and'B'.Table 'A' contains 3 columns named &..

Answer / patan

WE HAVE TABLE A (EID,ENAME,DEPT) AND TABLE B (NAMED,SID,DESIGNATION,SALARY)

--WE WANT TO RETRIEVE FOLLOWING
SELECT
B.NAMES AS NAMES
,B.DEPT AS DEPARTMENT
,B.SALARY AS SALARY
,B.DESIGNATION AS DESIGNATION

FROM TABLEA AS A
LEFT JOIN TABLEB AS B
ON A.EID=B.SID
ORDER BY B.NAMED


NOTE:WHEN WE ARE USING LEFT JOIN IT WILL MATCH THE RECORDS FROM BOTH THE TABLES AND LEFT TABLE OF RECORDS WILL DISPLAY...THAT ONLY I DID HERE

TRY IT..SURE IT WILL USEFUL

Is This Answer Correct ?    0 Yes 0 No

Their are two tables 'A' and'B'.Table 'A' contains 3 columns named &..

Answer / jayesh sonawane

this one correct try it:

SELECT
distinct
B.NAMES AS NAMES
B.SID
,B.DEPT AS DEPARTMENT
,B.SALARY AS SALARY
,B.DESIGNATION AS DESIGNATION

FROM TABLEB AS A join TABLEB AS b
on A.EID=B.SID and B.DEPT=A.DEPT and B.SALARY=A.SALARY and B.DESIGNATION =A.DESIGNATION
join TABLEA as taba on ON A.taba =B.SID

Is This Answer Correct ?    0 Yes 0 No

Their are two tables 'A' and'B'.Table 'A' contains 3 columns named &..

Answer / shankaranarayanan v

select eid,ename,dept,desg,salary from a,b
where a.eid=b.sid


(when a.eid=b.sid)

Is This Answer Correct ?    1 Yes 2 No

Their are two tables 'A' and'B'.Table 'A' contains 3 columns named &..

Answer / varunkumar

by using unions we can do it create two tables separetly and
apply union in between two tables .

Is This Answer Correct ?    0 Yes 3 No

Their are two tables 'A' and'B'.Table 'A' contains 3 columns named &..

Answer / litmus rav

If there is many to many relationship between two tables
then this will work,

you need to create thired table name A_B with attributes
eid references A(eid),sid references B(sid)

SELECT * FROM A,B,A_B WHERE A.eid=A_B.eid AND B.sid=A_B.sid
AND ORDER BY ename;

Is This Answer Correct ?    4 Yes 8 No

Their are two tables 'A' and'B'.Table 'A' contains 3 columns named &..

Answer / jeya

select Emp.* , sal.*
From Emp
Inner Join Sal On Emp.EmpId = sal.EmpId
Inner Join (
Select X.Department , sal.Designation , sal.salary
From Emp
Inner join (
Select Department
From emp Group By Department Having COUNT(*) > 1
)As X On X.Department = Emp.Department
Inner Join Sal On sal.EmpId = emp.EmpId
Group by X.Department , sal.Designation , sal.salary
Having COUNT(*) > 1
)as y on y.Department = emp.Department and y.Designation =
sal.Designation
and y.salary = Sal.salary

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More SQL Server Interview Questions

hi i am working as a testengineer , so i want to no the backend data base connection can any one tell mwe in detail

0 Answers   IntraLogic, Oracle,


What are distributed partitioned views?

0 Answers  


When would you use an insert into .. Select option versus an insert into .. Values option? Give an example of each?

0 Answers  


Relational calculus is what type of language?

0 Answers   HCL,


What is an extended stored procedure? Can you instantiate a COM object by using T-SQL?

1 Answers  






What does dml stand for?

0 Answers  


do you know what is a deadlock and what is a live lock? How will you go about resolving deadlocks? : Sql server database administration

0 Answers  


please give me query code of unique fuction select UNIQUE (name) from emp_info Incorrect syntax near the keyword 'UNIQUE'.

1 Answers   TCS,


how to get 25th row in any table in sqlserver can u tell me syntax

8 Answers  


What is Query Execution Plan? How does it help optimize or tune a database driven application?

2 Answers   Accenture, Polaris,


is there a column to which a default can't be bound? : Sql server database administration

0 Answers  


Explain query editor regions

0 Answers  


Categories