У меня есть существующая таблица со структурой и образцами данных, как показано ниже:
+----------+-------+--------+--------+
| S.No | Desc | ACC ID | Value |
+----------+-------+--------+--------+
| 1 | abc | ACC_1 | 1.23 |
+----------+-------+--------+--------+
База на деловых условиях
select S.No, desc,
case when acc id=ACC_1 then value else 0 end as ACC_2,
case when acc id=ACC_1 then value else 0 end as ACC_3,
case when acc id=ACC_1 then value else 0 end as ACC_4,
from table1
Токовый выход:
+----------+-------+--------+--------+--------+
| S.No | Desc | ACC_2 | ACC_3 | ACC_4 |
+----------+-------+--------+--------+--------+
| 1 | abc | 1.23 | 1.23 |1.23 |
+----------+-------+--------+--------+--------+
Требуемый вывод с той же бизнес-логикой:
+----------+-------+--------+--------+
| S.No | Desc | ACC ID | Value |
+----------+-------+--------+--------+
| 1 | abc | ACC_2 | 1.23 |
+----------+-------+--------+--------+
| 1 | abc | ACC_3 | 1.23 |
+----------+-------+--------+--------+
| 1 | abc | ACC_4 | 1.23 |
+----------+-------+--------+--------+