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
You want to implement the many-to-many relationship while designing tables. How would you do it?
What happens if time-only values are provided as date and time literals?
What is merge?
What command would you use to add a column to a table in sql server?
Explain few examples of RDBMS?
How to generate create table script on an existing table in ms sql server?
How to search for a string in all stored procedure in sql server?
Mention a few common trace flags used with sql server?
What is the process of indexing?
How many categories of functions based their return modes?
How can you check the version of sql server?
How will you find out if there are expensive SQL statements running or not?
How to get a list of columns in a view using the "sp_help" stored procedure?
What is model database? : SQL Server Architecture
How to optimize stored procedure optimization?