Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Ignore first record in LAG function

MDK999Feb 23 2017 — edited Feb 23 2017

Hello

I am using oracle 12.2.0.1 and I have following LAG syntax in my query -

readvalue - nvl(lag(readvalue) over (partition by c_id, d_id, e_id order by readtime),0) diff_readvalue,

But when I get my output for first record, I get

823571913.81913.808012015 18:01:00
823571917.73.908022015 18:02:00
823571919.31.608032015 18:03:00
823571920.61.308042015 18:03:00

but since first record is starting point, I need to get something like this -

823571913.8008012015 18:01:00
823571917.73.908022015 18:02:00
823571919.31.608032015 18:03:00
823571920.61.308042015 18:03:00

How can I achieve this? Thanks for your help

This post has been answered by mathguy on Feb 23 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2017
Added on Feb 23 2017
6 comments
2,125 views