0
Below is a select for data query in a table:
SELECT
'OS:'||AT.CD_NUMERO_OS ||' ITEM:'|| AT.ITEM ||' ETAPA DA ATVD:'||AT.CD_ETAPA_ATIVID||' ATVD:'|| AT.CD_ATIVIDADE AS "DADOS DA OS",
AT.DT_INICIO AS "DATA DE INICIO",
AT.DT_TERMINO AS "DATA DE FIM"
FROM GMATIVID AT
INNER JOIN GMOSERVI OS ON OS.CD_NUMERO_OS = AT.CD_NUMERO_OS
WHERE OS.DT_OS BETWEEN TO_DATE(:data_abertura_os_inicial, 'DD/MM/YYYY') AND TO_DATE(:data_abertura_os_final, 'DD/MM/YYYY')
AND OS.SITUACAO LIKE 'E'
ORDER BY AT.CD_NUMERO_OS ASC, AT.ITEM ASC, AT.CD_ATIVIDADE ASC
Below follows the result of this consultation:
I need to turn the lines into columns to fit the report we are developing, follows below as accurate information:
It is possible to perform this "transposition" of rows into columns directly in the SQL query?
Search Pir PIVOT or CASE PIVOT https://www.oracle.com/technical-resources/articles/database/sql-11g-pivot.html https://blogs.oracle.com/sql/how-to-convert-rows-to-columns-and-backagain-with-sql-aka-pivot-and-unpivot
– Motta