I have a table TAB1
in an Oracle database:
+----+----+----+----+----+----+
| ID | C1 | C2 | C3 | C4 | C5 |
+----+----+----+----+----+----+
| 1 | 1 | 0 | 3 | 0 | 5 |
| 2 | 11 | 22 | 0 | 44 | 0 |
+----+----+----+----+----+----+
I need a select statement that gives me the following output:
+----+-------------------------+
| id | descr |
+----+-------------------------+
| 1 | column1,column3,column5 |
| 2 | column1,column2,column4 |
+----+-------------------------+
…meaning I need in to concatenate names for every column (not exactly the name of the column but a different text for every column) that is not 0.
Best Answer
Something like (untested):