I have a table that looks like this one on SQL Fiddle: http://sqlfiddle.com/#!4/0fabe0/2/0
The table holds 12 rows. 6 belong to one "set", the other 6 belong to another "set". They are grouped by the identifier column. In reality, the table I want to query holds more rows and columns.
I want to make a select that gives me one row per identifier. Then it should show the insertTime and then for each "step" the "Yes" value and at the end for each "step" value "No" value.
I think I need to work with a combination of group by, distinct and joins to achieve this but I could not figure out how.
Here is how it should look like:
+------------+------------------+----------+----------+----------+---------+---------+---------+
| identifier | insertTime | yesStep3 | yesStep2 | yesStep1 | noStep1 | noStep2 | noStep3 |
+------------+------------------+----------+----------+----------+---------+---------+---------+
| 123 | 08.04.2018 13:37 | 13.3 | 12.2 | 11.1 | 13 | 13.3 | 14.1 |
| 124 | 08.04.2018 13:40 | 14.14 | 13.13. | 12.12. | 10.1 | 11.11 | 9.9 |
+------------+------------------+----------+----------+----------+---------+---------+---------+
PIVOTfunction then you can use conditional aggregation (as illustrated in @MT0's answer below).