I get a row, which contains non-zero values in two columns: FixHours
and AddHours
:
FixHours | AddHours | CalculatedValue
---------+----------+----------------
0,5 | 1,5 | 16.5
How can I split it into two rows such as:
FixHours | AddHours | CalculatedValue
---------+----------+----------------
0,5 | 0 | 16.5
0 | 1,5 | 16.5
I have had an idea to find that row and artificially make a second row using the union
operator. But I have many rows with values in two columns at the same time. Any ideas?
Assuming I understand your question correctly, I think something like this is what you are looking for:
SELECT FixHours, AddHours, CalculatedValue
FROM tbl
WHERE FixHours = 0
OR AddHours = 0
UNION
SELECT FixHours, 0, CalculatedValue
FROM tbl
WHERE FixHours <> 0
AND AddHours <> 0
UNION
SELECT 0, AddHours, CalculatedValue
FROM tbl
WHERE FixHours <> 0
AND AddHours <> 0
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments