Re: A SQL Question

From: AK <ak_tiredofspam_at_yahoo.com>
Date: 15 Jan 2004 15:23:35 -0800
Message-ID: <46e627da.0401151523.60f9fc8b_at_posting.google.com>


"Telus" <sraisdana_at_l3technology.com> wrote in message news:<_omNb.13141$wf1.11109_at_edtnps89>...
> A SQL question
>
> Hi Everybody,
> Imagine I have a file with 7 records
> and two fields with these data:
>
> Record1--Field1=1--Field2=10:45pm
> Record2--Field1=1--Field2=10:46pm
> Record3--Field1=2--Field2=10:47pm
> Record4--Field1=2--Field2=10:48pm
> Record5--Field1=2--Field2=10:49pm
> Record6--Field1=1--Field2=10:50pm
> Record7--Field1=1--Field2=10:51pm
>
> How can I write a SQL to give me
> Records 2,5 and 7, fields 1 and 2?
>
> I mean I sort records base on field 2 then
> for each change on field1, I need one record
> that can be max or min of field2,
> I couldn't use group by because group by consider
> all record with field1 value of 1 one group but
> I need one record for each changes on record1,
>
> Thank you in advance - Sasan

  1. add ROWNUM to select list
  2. Join adjacent rows, it's easy to do it on ROWNUM
  3. add a condition LEFT_SIDE.FIELD1<>RIGHT_SIDE.FIELD1
Received on Fri Jan 16 2004 - 00:23:35 CET

Original text of this message