count two records and insert a word in third.

pm709

New member
Local time
Today, 14:27
Joined
Nov 8, 2002
Messages
8
Hi all:

I need some help in this please. I want to create a field in a query that inserts a word every 3 records; this is: it counts 2 records and inserts "my_word" only in the third record, it counts another two and inserts "my_word" in record # 6 and so on, no matter the way how other fields are sorted (which is not important, anyway).

-----------------------
| Myfield: "My_word"
-----------------------
| 1 |
-----------------------
| 2 |
-----------------------
| 3 | My word
-----------------------

I'll apprecciate any help, thanks in advance.
 
I think you need at least one condition to determine every third record. In the following query I use a date field for that.
Code:
UPDATE tblPM AS P
SET P.MyField = "my_word"
WHERE (((SELECT Count(*) FROM tblPM AS T
  WHERE T.MyDate < P.MyDate)+1) Mod 3) = 0
hth nouba
 

Users who are viewing this thread

Back
Top Bottom