Hi Rob,

That worked quite well - thank you!  I do have one remaining issue
however.  When my USER changes, I would like the first DIFF value to
be 0 (or Null) - any idea how to get that to work?

Thanks again,

Mike

On Nov 19, 4:29 pm, Rob Wolfe <[EMAIL PROTECTED]> wrote:
> On Nov 19, 6:24 pm, myk <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I have a table that contains two columns, USER and VALUE.  For each
> > user there are multiple values.  What I would like to do is, after
> > ordering the list by user and then value, subtract each value from the
> > next value and place this new data-element into a third column named
> > DIFF.
>
> > Example:
>
> > DATA AS IS:
> > USER             VALUE
> > 1                        7
> > 1                        9
> > 1                       11
> > 1                       13
> > 2                        5
> > 2                        6
> > 2                        7
>
> > DATA AS I WOULD LIKE TO GET IT:
> > USER             VALUE         DIFF
> > 1                        7                 -
> > 1                        9                 2
> > 1                       11                2
> > 1                       15                4
> > 2                        5                 -
> > 2                        8                 3
> > 2                       15                7
>
> > Anyone know how to do this in SQL or PL*SQL?
>
> > TIA!
>
> > myk
>
> On my way out the door but what you should do is take a peek at the
> documentation for the LAG function 
> athttp://download.oracle.com/docs/cd/B10501_01/server.920/a96540/functi...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to