L
Leslie Isaacs
Hello All
I have a table [absences] with fields 'absencedate' and 'absencetype'
(amongst others).
I need a query that will return, for each record in [absences], the position
of each of the "w" 'absencetypes' when the records are sorted by
'absencedate'.
e.g.
absencedate absencetype position
14 July 2008 s 0 (or blank)
18 July 2008 s 0 (or blank)
19 July 2008 w 1
22 July 2008 s 0 (or blank)
26 July 2008 w 2
etc
I realise that there is no real order of records in a table, so I decided to
try, for each record, to count the number of records of 'absencetype' "w"
with an earlier absencedate. The sql of my qruery was:
SELECT absences.absencedate, absences.absencetype,
DCount("[absencedate]","[absences]","[absencetype]='w' and
[absencedate]<[absencedate]")+1 AS Position
FROM absences;
.... but this obviously returns a Position of 0 for all records (because of
the criteria [absencedate]<[absencedate]), so I amended it to:
SELECT absences.absencedate AS thisabsencedate, absences.absencetype,
DCount("[absencedate]","[absences]","[absencetype]='w' and
[thisabsencedate]<[absencedate]")+1 AS Position
FROM absences;
.... but now I get an error that access cannot find the name 'absencedate'.
I'm now stuck, and hope someone can help!
Many thanks
Leslie Isaacs
I have a table [absences] with fields 'absencedate' and 'absencetype'
(amongst others).
I need a query that will return, for each record in [absences], the position
of each of the "w" 'absencetypes' when the records are sorted by
'absencedate'.
e.g.
absencedate absencetype position
14 July 2008 s 0 (or blank)
18 July 2008 s 0 (or blank)
19 July 2008 w 1
22 July 2008 s 0 (or blank)
26 July 2008 w 2
etc
I realise that there is no real order of records in a table, so I decided to
try, for each record, to count the number of records of 'absencetype' "w"
with an earlier absencedate. The sql of my qruery was:
SELECT absences.absencedate, absences.absencetype,
DCount("[absencedate]","[absences]","[absencetype]='w' and
[absencedate]<[absencedate]")+1 AS Position
FROM absences;
.... but this obviously returns a Position of 0 for all records (because of
the criteria [absencedate]<[absencedate]), so I amended it to:
SELECT absences.absencedate AS thisabsencedate, absences.absencetype,
DCount("[absencedate]","[absences]","[absencetype]='w' and
[thisabsencedate]<[absencedate]")+1 AS Position
FROM absences;
.... but now I get an error that access cannot find the name 'absencedate'.
I'm now stuck, and hope someone can help!
Many thanks
Leslie Isaacs