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.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about nested stored procedure?

594


How to bind a view to the schema of the underlying tables?

583


How to trouble shoot if unable to connect SQL Server

1478


How to set database to be single_user in ms sql server?

561


What is the maximum size of column in sql server?

503






What is intellisense?

583


How do I start sql server 2016?

525


What is triggers and stored procedures?

512


How to execute multiple stored procedures at one time in sql server?

502


what is a correlated sub-query? : Sql server database administration

480


What is the difference between DATETIME2 and DATETIME?

623


How can you find out how many rows returned in a cursor?

547


Determine when to use stored procedure to complete sql server tasks?

532


Explain how you can deploy an SSRS report?

106


Explain about Joins?

603