On the left panel data without IGNORE NULLS.
On the right panel data with IGNORE NULLS.
So I need to get right variant in PostgreSQL
Need to emulate Oracle IGNORE NULLS in window functions (LEAD and LAG) in PostgreSQL.
SELECT empno,
ename,
orig_salary,
LAG(orig_salary, 1, 0) IGNORE NULLS OVER (ORDER BY orig_salary) AS sal_prev
FROM tbl_lead;
If there are NULL, it should return the latest not null value.
I've tried it via PostgreSQL user defined aggregate functions, but it's rather hard to understand methodology of it https://www.postgresql.org/docs/9.6/static/sql-createaggregate.html
The solution can't be realized via WITH clause or sub-query since it it used in complex query.