Re: How to do this trick ?
Date: Fri, 15 Oct 1999 10:40:27 +0200
Message-ID: <3806E87B.821A13A5_at_aon.nl>
Looks like the query is ok, but to my understanding you may not order values in this table.
Kai Sodemann wrote:
> Hi,
>
> here is the solution for your problem:
>
> select min(a.empno) empno, 0 Diff from emp a
> union
> select b.empno empno, b.empno-c.empno Diff
> from emp b, emp c
> where
> c.empno=
> (select max(d.empno)
> from emp d
> where b.empno-d.empno>0
> )
> order by empno;
>
> Result:
>
> EMPNO DIFF
> --------- ---------
> 7369 0
> 7499 130
> 7521 22
> 7566 45
> 7654 88
> 7698 44
> 7782 84
> 7839 57
> 7844 5
> 7900 56
> 7902 2
> 7934 32
>
> Reg Kai
>
> Norazman Abu Sahir <norazman_at_ti.com> wrote in article
> <38069C38.A089334E_at_ti.com>...
> > Hi,
> > I have a table with one colum. When I do a select below are the data.
> >
> > SQL> SELECT MYNUMBER FROM TESTING;
> >
> > MYNUMBER
> > ----------
> > 1
> > 3
> > 5
> > 10
> >
> > What I would like to do is how to display a different betwen a row value
> > with a previous row value.
> > Something like this:
> >
> > MYNUMBER DIFF
> > ---------- -------
> > 1 0
> > 3 2
> > 5 2
> > 10 5
> >
> > Have any idea?
> > TIA
> >
> >
> >
Received on Fri Oct 15 1999 - 10:40:27 CEST
