0
Below is a query performed for ORACLE database:
SELECT
ITOS.CD_NUMERO_OS,
ITOS.DESCRICAO_RECLA AS "DEFEITO APRESENTADO"
FROM GMITEMOS ITOS
INNER JOIN GMOSERVI OS ON OS.CD_NUMERO_OS = ITOS.CD_NUMERO_OS
INNER JOIN GMITEMOS IT ON IT.CD_NUMERO_OS = ITOS.CD_NUMERO_OS
WHERE OS.DT_OS BETWEEN TO_DATE(:data_os_inicial, 'DD/MM/YYYY') AND TO_DATE(:data_os_final, 'DD/MM/YYYY')
AND OS.SITUACAO LIKE 'E'
AND IT.TIPO_OS LIKE '3'
UNION
SELECT DISTINCT
ITOS.CD_NUMERO_OS,
SL.DESCRICAO_SOLUC AS "SOLUCAO DO DEFEITO"
FROM GMITEMOS ITOS
INNER JOIN GMOSERVI OS ON OS.CD_NUMERO_OS = ITOS.CD_NUMERO_OS
INNER JOIN GMITEMOS IT ON IT.CD_NUMERO_OS = ITOS.CD_NUMERO_OS
INNER JOIN GMDETALH SL ON SL.CD_NUMERO_OS = ITOS.CD_NUMERO_OS
WHERE OS.DT_OS BETWEEN TO_DATE(:data_os_inicial, 'DD/MM/YYYY') AND TO_DATE(:data_os_final, 'DD/MM/YYYY')
AND OS.SITUACAO LIKE 'E'
AND IT.TIPO_OS LIKE '3'
Below is a PRINT of how the information is being delivered on screen:
As we can observe, a DEFECT is presented and soon after a SOLUTION to the same number of OS (CD_NUMERO_OS). For example in the OS with CD_NUMERO_OS = 860, item 1 of the grid is a DEFECT and item 2 is a SOLUTION. I need to display DEFECT AND SOLUTION side by side, display in column format and not in rows according to the above print.
Any idea how I can display this result side by side???
Detail: A OS with CD_NUMERO_OS = 866 appears 3 times a DEFECT and 3 times a SOLUTION because the same OS has 3 different items.
note: OS 866 will appear the same solution 3 times, because the solution is by OS and not by item
– JMSlasher
It worked great buddy, thank you very much! But look, I need to appear only 1 defect and 1 solution per OS item, as I mentioned earlier OS 866 has 3 items, so 3 defects and 3 solutions. Below is the result returned for the following query. Do you have any idea how else I can solve this "problem" ai?? rsrs @Jmslasher
– Adair Juneo
guy just missed the item table relationship
IT
with the OS item tableITOS
– JMSlasher
question ITOS and IT are relating the same table, I believe that give only to reference the table
ITOS
and omitIT
– JMSlasher