I have been trying to solve this but could not figure it out.
so this is the table and more columns could be added:
+------------+-----------+------------+-----------+------------+------------+
| patient_ID | code_ID | happy? | mad? | smiling? | scared? |
+------------+-----------+------------+-----------+------------+------------+
| kkk | kgg | 1 | 0 | 1 | 1 |
+------------+-----------+------------+-----------+------------+------------+
| 2k2 | 2g2 | 0 | 1 | 0 | 1 |
+------------+-----------+------------+-----------+------------+------------+
So if the value is one then I will display it in a different row but with the value being the column header itself My boss suggested using pivot to solve this but I am open to any way.
output should be like this:
+------------+-----------+------------+
| patient_ID | code_ID | segment |
+------------+-----------+------------+
| kkk | kgg | happy? |
+------------+-----------+------------+
| kkk | kgg | smiling? |
+------------+-----------+------------+
| kkk | kgg | scared? |
+------------+-----------+------------+
| 2k2 | 2g2 | mad? |
+------------+-----------+------------+
| 2k2 | 2g2 | scared? |
+------------+-----------+------------+