Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL query
Huascar Espinoza wrote:
>
> How can I get the following statistics in singles SQL queries:
>
> Table has a sequencing number field (NRO_CORREL) and a date field =
> (DATE_REF). Example (ORDER BY DATE_REF):
>
> NRO_CORREL DATE_REF
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D=3D
> 1 date1
> 2 date2
> 3 date3
> 5 date4
> 6 date5
> 4 date6
> 8 date7
> 9 date8
>
> I need to find:
>
> 1) Qty. and list of regs. with lacked NRO_CORREL in the sequence
> 2) Qty. and list of regs. With disordered NRO_CORREL
>
> Thank you!
>
> Hu=E1scar
> ----------------------------------------------------------------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> ----------------------------------------------------------------
> To unsubscribe send email to: oracle-l-request_at_freelists.org
> put 'unsubscribe' in the subject line.
> --
> Archives are at http://www.freelists.org/archives/oracle-l/
> FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
> -----------------------------------------------------------------
Huascar,
Have a look at the lag() and lead() analytical functions. Order by date in the window attribute of the function, and compare NRO_CORREL to lag(NRO_CORREL).
-- Regards, Stephane Faroult Oriole Software ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line. -- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Tue May 18 2004 - 15:26:00 CDT
![]() |
![]() |