Select turning different records into single

Asked

Viewed 48 times

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 update the tables.

Example:

inserir a descrição da imagem aqui

1 answer

1

You might get this by using the function PIVOT oracle: https://www.techonthenet.com/oracle/pivot.php

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.