I wish to duplicate rows based on a column value using CONNECT BY LEVEL.
This is the code I used:
SELECT
tbl1.*,
(tbl1.START_WEEK - tbl1.END_WEEK) wks_inbtwn
FROM
My_SQL_table tbl1 INNER JOIN (SELECT rownum repeat FROM dual CONNECT BY LEVEL <= tbl1.END_WEEK ) tbl2
ON tbl2.Repeat > tbl1.START_WEEK
I keep getting the error:
SQL Error [904] [42000]: ORA-00904: "tbl1"."START_WEEK": invalid identifier
My table is as below:
+------------+------------+----------+
| Site_NUM | start_week | end_week |
+------------+------------+----------+
| France | 50 | 52 |
| Germany | 41 | 43 |
| USA | 12 | 13 |
+------------+------------+----------+
The result I want is as below:
+----------+---------+
| Site_NUM | Week_no |
+----------+---------+
| France | 51 |
| France | 52 |
| Germany | 42 |
| Germany | 43 |
| USA | 13 |
+----------+---------+
Any help would be greatly appreciated, Thanks in advance.