G
Glenn_H
I am looking for a query that will show the last two occurences (by date).
The date are within a range of the year 2000 through 2006.
The issue I am coming accross is if the patient has an occurance in 2007, it
is counted as one of the two.
Below are what I have so far
---------------------------------------------
Subquery Name (qry-Last2VL-2000-2006-SubQuery)
SELECT
cptViralLoad.RecordID,
cptViralLoad.PatientID,
cptViralLoad.ViralLoadDate,
cptViralLoad.ViralLoad
FROM
cptViralLoad
WHERE
(((cptViralLoad.ViralLoadDate)>=#1/1/2000# And
(cptViralLoad.ViralLoadDate)<=#12/31/2006#))
ORDER BY
cptViralLoad.ViralLoadDate DESC;
Main Query name (qry-Test-Last2VL)
SELECT
[qry-Last2VL-2000-2006-SubQuery].PatientID,
[qry-Last2VL-2000-2006-SubQuery].ViralLoadDate,
[qry-Last2VL-2000-2006-SubQuery].ViralLoad,
[qry-Last2VL-2000-2006-SubQuery].RecordID,
cptPatientDemographics.MedicalRecordID,
[lastname] & ", " & [firstname] AS Client
FROM
cptPatientDemographics INNER JOIN [qry-Last2VL-2000-2006-SubQuery] ON
cptPatientDemographics.PatientID = [qry-Last2VL-2000-2006-SubQuery].PatientID
ORDER BY [lastname] & ", " & [firstname];
---------------------------------------------
I am sure the answer is here. Ihave tried using the example found here:
http://allenbrowne.com/subquery-01.html#TopN
I'm missing something.
Thank for any help.
Glenn_H
The date are within a range of the year 2000 through 2006.
The issue I am coming accross is if the patient has an occurance in 2007, it
is counted as one of the two.
Below are what I have so far
---------------------------------------------
Subquery Name (qry-Last2VL-2000-2006-SubQuery)
SELECT
cptViralLoad.RecordID,
cptViralLoad.PatientID,
cptViralLoad.ViralLoadDate,
cptViralLoad.ViralLoad
FROM
cptViralLoad
WHERE
(((cptViralLoad.ViralLoadDate)>=#1/1/2000# And
(cptViralLoad.ViralLoadDate)<=#12/31/2006#))
ORDER BY
cptViralLoad.ViralLoadDate DESC;
Main Query name (qry-Test-Last2VL)
SELECT
[qry-Last2VL-2000-2006-SubQuery].PatientID,
[qry-Last2VL-2000-2006-SubQuery].ViralLoadDate,
[qry-Last2VL-2000-2006-SubQuery].ViralLoad,
[qry-Last2VL-2000-2006-SubQuery].RecordID,
cptPatientDemographics.MedicalRecordID,
[lastname] & ", " & [firstname] AS Client
FROM
cptPatientDemographics INNER JOIN [qry-Last2VL-2000-2006-SubQuery] ON
cptPatientDemographics.PatientID = [qry-Last2VL-2000-2006-SubQuery].PatientID
ORDER BY [lastname] & ", " & [firstname];
---------------------------------------------
I am sure the answer is here. Ihave tried using the example found here:
http://allenbrowne.com/subquery-01.html#TopN
I'm missing something.
Thank for any help.
Glenn_H