I am trying to use Lateral Join in Oracle(Oracle Database 11g Release 11.2.0.1.0) but it is giving some error. I have followed this link
https://oracle-base.com/articles/12c/lateral-inline-views-cross-apply-and-outer-apply-joins-12cr1#lateral-inline-views and applied it on the same data but still it isn't working. Can someone figure out the issue?
SELECT department_name, employee_name
FROM departments d,
LATERAL(SELECT employee_name FROM employees e WHERE e.department_id = d.department_id)
ORDER BY 1, 2;
Adding further details for clarify why I need a lateral join: I have a table e.g
ID Length
1 20
2 50
3 30
4 40
5 20
6 80
and I want to add another column of the sum of the length of records that have ID less than current row's ID i.e
ID Length Sum
1 20 NULL
2 50 20
3 30 70
4 40 100
5 20 140
6 80 160
With the Lateral JOIN it could have be very simple for example
select A.ID,A.length,Sum from Table A,
Lateral (select sum(B.length) as Sum from Table B where B.id<A.id);
So is there is any alternative to this?