it will give only one record for the trackingevent = 'process'
[quoted text, click to view] "Krishnakumar S" wrote:
> Hi vanitha
> Try this
> SELECT
> t.orderid, t.trackid,
> (SELECT
> TOP 1 trackid
> FROM
> Table1
> WHERE
> trackid > t.trackid AND orderid = t.orderid AND trackevent = 'process')
> trackid
> FROM
> Table1 t
> WHERE
> t.trackevent = 'sample'
> --
> Krishnakumar S
>
>
> "vanitha" wrote:
>
> > hi,
> >
> > i have a table like
> > orderid int
> > trackid int
> > trackevent varchar(50)
> >
> > values will be like
> >
> > orderid trackid trackevent
> > 1 1 'sample'
> > 1 2 'process'
> > 1 3 'sample'
> > 1 4 'process'
> >
> > now i want to fetch the record where the tracking event is 'sample' and the
> > first occurance of the trackid where trackevent is 'process'
> >
> > output shd be like this
> >
> > orderid trackid trackid
> > 1 1 2 (first subsequent occurance where
> > trackevent= 'process')
> > 1 3 4
> >
> >
> > pls help me to solve this.
> >
> > its very urgent.
> >
> > thanks
> > vanitha
> >