Create a query using a single table, in SQLServer

0

List the names of the employees and the name of their respective boss (only those who have a boss). [use joins]

SELECT * TABLE employee

What I want is, if supervisor is 3 then the name of Karolina appears, which is the one that corresponds.

> Best response executed.

But I still have a problem, supervisors Karolina (3) and Glenda (2) intersect. What is expected is the following.

    
asked by Vicete Geovanny Franco Siles 04.11.2016 в 08:46
source

1 answer

4

You need to join with the same table but when the code of empleado_1 is equal to the supervisor of empleado :

SELECT empleado.codigo,
empleado.nombre,
empleado.supervisor,
empleado_1.nombre
FROM empleado
INNER JOIN empleado AS empleado_1
ON empleado_1.codigo = empleado.supervisor

Updated: 07-11-2016

    
answered by 04.11.2016 / 09:41
source