How can I display column values in two columns?

64 Views Asked by At

I'm using SQL Developer and currently have a table like this:

PROD | SER_NUM | PROD_DESC
Xxxx | 255236  | 'BLK'
Yyyy | 785412  | 'RED'
Zzzz | 254861  | 'BLK'
Wwww | 985465  | 'RED'

and I need to display it like this:

PROD |  BLK   |  RED   |
Xxxx | 255236 |        |
Yyyy |        | 785412 |
Zzzz | 254861 |        |
Wwww |        | 985465 |
1

There are 1 best solutions below

0
On BEST ANSWER

Try this:

  select prod, 
  case when prod_desc ='RED' then ser_num else '' end As RED, 
  case when prod_desc='BLK' then ser_num else '' end BLK  
  from your_table;