Re: Loop
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 05 Oct 2005 22:32:57 +0200
On Wed, 5 Oct 2005 00:04:04 -0700, Travis wrote:
>Hi ,
>
> I like to build a query to generate a virtual running number from the
>table.
>Something like "Select @X , fieldA from TableA" . The result should look
>like ,
>
>@x FieldA
>-- -------
>1 AAA
>2 BBB
>3 CCC
>
>Please help
Hi Travis,
Maybe something like this?
SELECT COUNT(*) AS [@x], a.FieldA
FROM TableA AS a
INNER JOIN TableA AS b
ON b.FieldA <= a.FieldA
GROUP BY a.FieldA
(untested - see www.aspfaq.com/5006 if you prefer a tested solution)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
.
- Prev by Date: Re: How to calculate category value - perhaps use subqueries?
- Next by Date: Re: Referencing a column from another tables data
- Previous by thread: Re: How to calculate category value - perhaps use subqueries?
- Next by thread: Re: Referencing a column from another tables data
- Index(es):