Help with putting together a query in Oracle?

1

I have a table called ESTRUCTURA that has the fields

ID_ESTRUCTURA, NOMBRE_TRABAJADOR, ACTIVO

And a table called TRABAJADOR_RANGO that has the fields

ID_TRABAJADOR_RANGO, ID_ESTRUCTURA, ID_SERVICIO, TIPO_RANGO

What I want is to show the name of the worker who are RESPONSIBLE and the name of the worker who are ALTERNATES of a specific service,

the TIPO RANGO field, can have the values 1 or 2, where 1 = RESPONSIBLE and
 2 = ALTERNATE

and this is my query

SELECT E.NOMBRE_TRABAJADOR RESPONSABLE, E.NOMBRE_TRABAJADOR SUPLENTE
FROM TABLE_ESTRUCTURA  E, TABLE_TRABAJADOR_RANGO R
WHERE E.ID_ESTRUCTURA = R.ID_ESTRUCTURA
AND R.ID_SERVICIO = 2019

and it shows me the following:

shows two records since that service has RESPONSIBLE AND ALTERNATE, but it repeats the same name, and what I want is that it comes out this way

How can I get it to go as I want? let me paint RESPONSIBLE AND ALTERNATE

can a subquery be made? where first do something like this, look for the name of the RESPONSIBLE and then another select but with TYPE_RANGE = 2?

SELECT E.NOMBRE_TRABAJADOR RESPONSABLE
FROM TABLE_ESTRUCTURA  E, TABLE_TRABAJADOR_RANGO R
WHERE E.ID_ESTRUCTURA = R.ID_ESTRUCTURA
AND R.ID_SERVICIO = 2019
AND R.TIPO_RANGO = 1

or would it be with GROUP BY?

I hope you can help me, I do not know much about BD

    
asked by Root93 05.10.2018 в 05:57
source

0 answers