Self Join to get employee manager name

0 votes

Hello, the columns in my employee table are as follows.

Emp_id, Emp_Name and Mgr_id.

I'm attempting to develop a view that will display:

Emp name, Emp id, Mgr name, and Mgr id (by cross joining the Employee table). I tried outer join, inner join, and other approaches, but I was unable to solve the problem.

CREATE TABLE [dbo].[tblEmployeeDetails](
[emp_id] [bigint] NOT NULL, 
[emp_name] [nvarchar](200) NULL,    
[emp_mgr_id] [bigint] NULL, CONSTRAINT [PK_tblEmployeeDetails] PRIMARY KEY CLUSTERED (
[emp_id] ASC )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] ) ON [PRIMARY]

Can someone please help me with this?

Aug 25, 2022 in Database by Kithuzzz
• 38,020 points
418 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

What is the SQL query to get the third highest salary of an employee from employee_table

You can try out something like this: SELECT ...READ MORE

answered Sep 27, 2018 in Database by Sahiti
• 6,370 points
12,373 views
0 votes
0 answers

How to get address, Column Name and Row Name of all marked rows in Excel table as rows in new worksheet

 need the row/column combinations marked with an ...READ MORE

Feb 24, 2022 in Database by Edureka
• 13,690 points
1,979 views
0 votes
1 answer

How to get the "Name Box" name of an Excel cell?

By typing in the Name Box, you ...READ MORE

answered Mar 15, 2022 in Database by gaurav
• 23,260 points
5,189 views
0 votes
2 answers

What are the ways to get the count of records in a table

With the help of the SQL count ...READ MORE

answered Aug 20, 2020 in Database by Okugbe
• 280 points
3,929 views
0 votes
1 answer

How will I get all the rows from my table where name starts with 's' and ending with 'I'?

Hi Santanu, I understand your problem, You can try ...READ MORE

answered May 28, 2019 in Database by sampriti
• 1,120 points
2,025 views
0 votes
1 answer

How to set SSL to Domain name for MYSQL database

Hello @ Lakshminarayanan, Yes, It is possible to setup ...READ MORE

answered Jul 9, 2020 in Database by Niroj
• 82,880 points
1,347 views
0 votes
0 answers

Altering column size in SQL Server

How to change the column size of ...READ MORE

Aug 23, 2022 in Database by Kithuzzz
• 38,020 points
523 views
0 votes
0 answers

Why do you create a View in a database?

When and why does a database owner ...READ MORE

Aug 26, 2022 in Database by Kithuzzz
• 38,020 points
431 views
0 votes
1 answer

Correct use of transactions in SQL Server

A transaction in SQL Server is a sequential ...READ MORE

answered Nov 7, 2022 in Others by gaurav
• 23,260 points
545 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,070 points
771 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP