Select transforming different records into single

0

I need to make a select by unifying two different rows into one, with two new columns.

I am using bd oracle and there is no possibility to perform update in the tables.

Example:

    
asked by anonymous 05.10.2016 / 22:02

1 answer

1

You may be able to do this by using the PIVOT function of Oracle: link

SELECT * FROM
(
  SELECT carro, ano, preco
  FROM sua_tabela
)
PIVOT
(
  sum(preco)
  FOR ano IN (2016, 2017, 2018)
)
ORDER BY carro;
    
05.10.2016 / 22:11