What is a self join? Explain it with an example?
Answer Posted / ramya
CREATE TABLE EMPLOYEE(
[EMPLOYEE_ID] INT PRIMARY KEY,
[NAME] NVARCHAR(50),
[MANAGER_ID] INT
)
INSERT INTO EMPLOYEE VALUES(101,'Mary',102)
INSERT INTO EMPLOYEE VALUES(102,'Ravi',NULL)
INSERT INTO EMPLOYEE VALUES(103,'Raj',102)
INSERT INTO EMPLOYEE VALUES(104,'Pete',103)
INSERT INTO EMPLOYEE VALUES(105,'Prasad',103)
INSERT INTO EMPLOYEE VALUES(106,'Ben',103)
select e1.employee_id,e1.name,e1.manager_id,e2.name from
employee e1 join employee e2
on e1.employee_id = e2.manager_id
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
You are testing the performance of a query the first time you run the query, the performance is slow. the second time you run the query, the performance is fast. why is this?
What you can do to remove data from the cache and query plans from memory for testing the performance of a query repeatedly?
What is a database development?
I have a few records all are same structures data, I want to store data in multiple targets how
What is an application role and explain a scenario when you would use one?
What are the main phases of database development?
You have a table with three columns: amount1, amount2, and amount3 in a single row only one of these three columns will have a value and the other two will be null. Write a sql query to retrieve the values from these columns?
explain detail about ftp in datastage?
What are the 18 schemas?
How you can make a parameterized view?
Explain the cube operator?
What is the maximum length of an extended property?
Which four data types cannot be used as a return type from a user-defined function?
What are the three basic rules which are to be followed for the relational model of the database?
I HAVE A PI ON COL A THE NEXT DAY I WANT CHANGE THE PI ON COL B? PLS SEND ME THE ANS