How can I apply Unpivot to a simple select, I want to leave a query upright

Asked

Viewed 805 times

0

According to the code below:

SELECT 1 DADO1 ,2 DADO2 FROM DUAL

I would like to leave the search results vertically, I am beginner in Oracle, I saw that to do with unpivot but I did not find a simple example demonstrating the inversion of columns vertically and their results next to each field.

  • As far as I know, Oracle is the same in SQL. http://answall.com/questions/189841/12-colunas-de-meses-1-coluna-de-valores-1-coluna-de-m%C3%Aas/189863#189863

1 answer

0


As consultation used, below is how it would look. To suit your scenario, I recommend consult Documentation - Pivot and Unpivot EN.

SELECT valor
  FROM ((SELECT '1' dado1
               ,'2' dado2
               ,'3' dado3
               ,'4' dado4
               ,'5' dado5
           FROM dual)
        unpivot(valor FOR tipo_de_valor IN (dado1
                                 ,dado2
                                 ,dado3
                                 ,dado4
                                 ,dado5)))
  • Thanks for the example David, I will implement here in the query.

Browser other questions tagged

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