Re: Running counter
From: MichaelK (michaelk_at_gomobile.com)
Date: 12/28/04
- Next message: Derrick Leggett: "Re: Running counter"
- Previous message: Hugo Kornelis: "Re: Running counter"
- In reply to: Hugo Kornelis: "Re: Running counter"
- Next in thread: Derrick Leggett: "Re: Running counter"
- Reply: Derrick Leggett: "Re: Running counter"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 27 Dec 2004 16:08:54 -0800
Thanks Hugo.
Interesting idea and works, but takes very long.
Unfortunately can't use it, need something faster.
Hey guys any other ideas?
Regards,
Michael
"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:q961t0l1ohanli4b68a4j71d4vet8t8j72@4ax.com...
> On Mon, 27 Dec 2004 13:37:05 -0800, MichaelK wrote:
>
>>Is it possible to make a query to have a counter which would have
>>a sequential number of each record in the query starting with 1?
>
> Hi Michael,
>
> That depends. Relational databases handle sets, which are UNordered by
> definition, so there is no such thing as an intrinsic "row number". But if
> you can define something to base the numbering on, you can have SQL Server
> add the numbers.
>
> As an example, the following query will list all authors with a ranking
> based on alphabetic order of last name (note how the tie for Albert Ringer
> and Ann Ringer is handled!):
>
> USE pubs
> GO
> SELECT au_id, au_lname, au_fname,
> (SELECT 1 + COUNT(*)
> FROM authors AS b
> WHERE b.au_lname < a.au_lname) AS rank
> FROM authors AS a
> ORDER BY rank
> GO
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Derrick Leggett: "Re: Running counter"
- Previous message: Hugo Kornelis: "Re: Running counter"
- In reply to: Hugo Kornelis: "Re: Running counter"
- Next in thread: Derrick Leggett: "Re: Running counter"
- Reply: Derrick Leggett: "Re: Running counter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|