There is a data_table with four columns. I am trying to make up a SELECT statement that transforms each initial row into one or two rows depending on a value in type column.
For example, when type = 'X' row (a,b,c) is transformed into (a,b) and (a,c), otherwise it is just (a,b).
initial_data_table
| a | b | c | type
---------------------------
| 1 | 2 | 3 | X
| 4 | 5 | 6 | Y
---------------------------
query result
| first | second | type
---------------------------
| 1 | 2 | X
| 1 | 3 | X
| 4 | 5 | Y
---------------------------
Could you help me tow find out how to "split" rows on condition in a relational way using only SQL?