Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: PostgreSQL IGNORE NULLS in aggregate functions

Walentyna Juszkiewicz:

Need to emulate Oracle Ignore Nulls in aggregate 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 http://ift.tt/29ms7Ew

The solution can't be realized via WITH clause or sub-query since it it used in complex query.

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



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: PostgreSQL IGNORE NULLS in aggregate functions

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×