我有兩列每個月的表,這樣從列轉換數據行上PLSQL甲骨文
表1:
_____________________________________________________________________
|item | jan_p | jan_r | feb_p | feb_r | commpany|
|______|___________|___________|____________|___________|____________
|1294 | 1234232 | 2323322 | 1242122 | 532323 | E987 |
|______|___________|___________|____________|___________|___________|
我需要將數據轉移到一個新的,更標準化的表是這樣的:
表2:
________________________________________________
| item | month | cost_p | cost_r | company |
|_______|_______|_________|_________|__________|
| 1294 | 1 |1234232 | 2323322| E987 |
| 1295 | 2 |1242122 | 532323 | E987 |
|_______|_______|_________|_________|__________|
我編寫了一個循環遍歷第一個表格嵌套循環中插入行每個月這樣的:
for reg in (select * from table1) loop
for x in 1..12 loop
case x
when 1 then
insert into table2(..., mes , ...) values(... , x, ...)
when 2 then
insert into table2(..., mes , ...) values(... , x, ...)
這是工作,但我只是想知道,如果還有另一種方法可以實現相同的結果。
請編輯您的問題,並只使用英語,或在這裏發佈您的問題:https://es.stackoverflow.com/ – dparoli
沒有sabe nada de plsql cierto? –