flaviooooo
Programmer
Hi,
I have a table containing Code-Cylinders. Each code has several cylinders, with some kind of sequencenumber.
Now it can happen that some codes have a duplicate sequencenumber, if for example a cylinder as used as backup.
It can also happen that a cylinder was removed, and a gap is in the sequence.
It looks a little like this:
DRUKCODE DRUKVORD CYL
A 1 xx
A 2 yy
A 3 zz
B 1 xy
B 2 yx
B 3 zx
B 3 xz
C 1 yxz
C 2 xyz
C 4 zyx
Now I wold like to add another field in a query, which gives me the real sequencenumber.
This would be like this:
DRUKCODE DRUKVORD CYL SEQ
A 1 xx 1
A 2 yy 2
A 3 zz 3
B 1 xy 1
B 2 yx 2
B 3 zx 3
B 3 xz 4
C 1 yxz 1
C 2 xyz 2
C 4 zyx 3
For this I have constructed this query, but it fails when a duplicate sequence is found:
Does anyone have an idea on how to solve this?
I have a table containing Code-Cylinders. Each code has several cylinders, with some kind of sequencenumber.
Now it can happen that some codes have a duplicate sequencenumber, if for example a cylinder as used as backup.
It can also happen that a cylinder was removed, and a gap is in the sequence.
It looks a little like this:
DRUKCODE DRUKVORD CYL
A 1 xx
A 2 yy
A 3 zz
B 1 xy
B 2 yx
B 3 zx
B 3 xz
C 1 yxz
C 2 xyz
C 4 zyx
Now I wold like to add another field in a query, which gives me the real sequencenumber.
This would be like this:
DRUKCODE DRUKVORD CYL SEQ
A 1 xx 1
A 2 yy 2
A 3 zz 3
B 1 xy 1
B 2 yx 2
B 3 zx 3
B 3 xz 4
C 1 yxz 1
C 2 xyz 2
C 4 zyx 3
For this I have constructed this query, but it fails when a duplicate sequence is found:
Code:
SELECT DRUKCYL.DRUKCODE, DRUKCYL.DRUKVORD, DRUKCYL.CYLNUM, (SELECT Count([DRUKVORD]) AS seq FROM drukcyl AS d2 WHERE (((d2.DRUKVORD)<=[DRUKCYL].[DRUKVORD]) and ((d2.DRUKCODE)=DRUKCYL.DRUKCODE))) AS SEQFROM DRUKCYL;
Does anyone have an idea on how to solve this?