List:General Discussion« Previous MessageNext Message »
From:Maciej Dobrzanski Date:March 24 2007 12:05am
Subject: Re: Finding a record in a result set
View as plain text  
"James Tu" <jtu@stripped> wrote in message =
news:FFE2B162-EDC4-43F3-BF89-E798FBA1F97E@ style="color:#666">stripped...

> I want to do a query of all employees from Maine, ordered by hiring =20
> date, and figure out where Joe falls in that list. (i.e. which record  =

> number is he?)

I think this can only be accomplished with a temporary table.

SET @n:=3D0;
SELECT t.name, t.n FROM (SELECT @n:=3D@n+1 AS n, name FROM t WHERE state =
=3D 'Maine' ORDER BY hire DESC) t WHERE t.name =3D 'Foo';

This query though may not be suitable for most situations as its =
performance depends heavly on the size of the derived table.=20

Maciek

Thread
Finding a record in a result setJames Tu22 Mar
  • Re: Finding a record in a result setPeter Brawley22 Mar
    • Re: Finding a record in a result setRolando Edwards22 Mar
    • RE: Finding a record in a result setJerry Schwartz22 Mar
      • Re: Finding a record in a result setFrancesco Riosa23 Mar
      • SPAM ?Jacques Brignon24 Mar
        • Re: SPAM ?LP24 Mar
        • Re: SPAM ?Martijn Tonies24 Mar
        • Re: SPAM ?Stephen Cook25 Mar
          • RE : SPAM ?Jacques Brignon25 Mar
            • RE : RE : SPAM ? SOLVEDJacques Brignon25 Mar
        • Re: SPAM ?Banyan He25 Mar
          • RE : SPAM ?Jacques Brignon25 Mar
            • Re: SPAM ?Banyan He25 Mar
  • Re: Finding a record in a result setRolando Edwards22 Mar
  • Re: Finding a record in a result setMaciej Dobrzanski24 Mar
    • Re: Finding a record in a result setJames Tu26 Mar
  • Re: Finding a record in a result setJames Tu26 Mar
  • Re: Finding a record in a result setJames Tu4 Apr
    • RE: Finding a record in a result setJerry Schwartz4 Apr
      • Re: Finding a record in a result setDan Buettner4 Apr
        • Re: Finding a record in a result setJames Tu4 Apr
          • Re: Finding a record in a result setDan Buettner4 Apr
      • Re: Finding a record in a result setJames Tu4 Apr