PIVOT Help - SELECT SQL

Asked

Viewed 85 times

1

I have a table with the data:

unidade  tipo  valor  
      1     2  10,00  
      1     3  15,00  
      2     2  16,00  
      3     3  10,00  
      3     1  25,00

I need to make a select with pivot that brings me

unidade tipo1 tipo2 tipo3
1        0,00 10,00 15,00
2        0,00 16,00  0,00  
3       25,00  0,00  0.00

How do I do that?

  • 1

    it would be interesting if you put the table structure and what you have tried to do, click on edit and modify your question by making it clearer.

  • Pedro, welcome to Stack Overflow. At GOKU’s suggestion you could edit your question including the DDL of the table. Also include the database you are using in the question (some databases have better support than others, your answer may vary depending on the DBMS).

No answers

Browser other questions tagged

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