Re: Running counter
From: Derrick Leggett (derrickleggett_at_yahoo.com)
Date: 12/28/04
- Previous message: MichaelK: "Re: Running counter"
- In reply to: MichaelK: "Re: Running counter"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 27 Dec 2004 19:04:34 -0600
Insert the records into a table variable or temp table (if more than 10k
records) that includes an identity column. The query selects the final
resultset. How big of a recordset are you talking about here? Why do you
need to do this?
"MichaelK" <michaelk@gomobile.com> wrote in message
news:esS9uFH7EHA.128@TK2MSFTNGP15.phx.gbl...
> 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)
>
>
- Previous message: MichaelK: "Re: Running counter"
- In reply to: MichaelK: "Re: Running counter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|