Re: assign numbers to the occurence of data
- From: "sharman" <sharman@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 21 May 2005 17:10:01 -0700
Thanks a lot, Ken. It works like a charm. Can you suggest a good book which
has lots of examples on the different SQL queries?
"Ken Snell [MVP]" wrote:
> Slight typo corrected below:
>
> UPDATE Tablename SET NewFieldName =
> DCount("*", "Tablename", "DataFieldName='" &
> [DataFieldName] & "' And PrimaryKeyFieldName<=" &
> [PrimaryKeyFieldName]);
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
> "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx> wrote in message
> news:OPlW36hXFHA.3760@xxxxxxxxxxxxxxxxxxxxxxx
> > Is ther a primary key on the table? Assuming that there is (and that it's
> > just one field), you can use an update query to write "ranking" values to
> > the new field that you've added. Something like this (note: use of DCount
> > will make the query run a bit slowly):
> >
> > UPDATE Tablename SET NewFieldName =
> > DCount("*", "Tablename", "DataFieldName='" &
> > [DataFieldName] & " And PrimaryKeyFieldName<=" &
> > [PrimaryKeyFieldName]);
> >
> > --
> >
> > Ken Snell
> > <MS ACCESS MVP>
> >
> >
> >
> > "sharman" <sharman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:F5F45F3C-AB2B-41F8-BB5E-A129E2DB7DBB@xxxxxxxxxxxxxxxx
> >>I have a database that contains a field having duplicate data. I have
> >>created
> >> another column and I want to insert numbers in the other column that will
> >> start at 1 and increment up to the count of the data. For example if
> >> "ABC"
> >> occurs 3 times in the first column then in the second column it will be 1
> >> for
> >> the first occurence of "ABC", 2 for the second occurence of "ABC" and 3
> >> for
> >> the third occurence of "ABC". Similarly, if the data occurs 100 times
> >> this
> >> count will increment up to 100 for that data.
> >>
> >> Can anyone please let me know how this can be accomplished either
> >> programatically or by a query? Thanks in advance.
> >
> >
>
>
>
.
- Follow-Ups:
- Re: assign numbers to the occurence of data
- From: Ken Snell [MVP]
- Re: assign numbers to the occurence of data
- References:
- assign numbers to the occurence of data
- From: sharman
- Re: assign numbers to the occurence of data
- From: Ken Snell [MVP]
- Re: assign numbers to the occurence of data
- From: Ken Snell [MVP]
- assign numbers to the occurence of data
- Prev by Date: Re: assign numbers to the occurence of data
- Next by Date: Re: assign numbers to the occurence of data
- Previous by thread: Re: assign numbers to the occurence of data
- Next by thread: Re: assign numbers to the occurence of data
- Index(es):
Relevant Pages
|