I have a table in database that has structure and data as follows:
+-----+--------+--------+--------+--------+--------+
| ID | Col1 | Col2 | Col3 | Col4 | Col5 |
+-----+--------+--------+--------+--------+--------+
| 1 | MALE | MALE | FEMALE | NULL | NULL |
| 2 | FEMALE | MALE | NULL | NULL | NULL |
| 3 | FEMALE | NULL | NULL | NULL | NULL |
| 4 | MALE | OTHER | FEMALE | FEMALE | NULL |
| 5 | MALE | OTHER | FEMALE | MALE | FEMALE |
+-----+--------+--------+--------+--------+--------+
The order of data has to be in order of first appearance in the columns, from Col1 to Col5, to get the following output:
+-----+--------------------------------------------+
| ID | Remarks |
+-----+--------------------------------------------+
| 1 | 2 Male and 1 Female |
| 2 | 1 Female and 1 Male |
| 3 | 1 Female |
| 4 | 1 Male, 1 Other and 2 Female |
| 5 | 2 Male, 1 Other and 2 Female |
+-----+--------------------------------------------+