I am using an Access 2000 database. The following statement works well until I have 2 or more records with same WAGENO but different WRATE. The first record is skipped but the second is pulled ok.
What's curious is if I have only one record of a particular WAGENO it pulls ok. As soon as I add that second matching WAGENO and they have different WRATE's then only one of the two records is pulled.
The WAMT field should not be summed and records combined unless the WAGENO and WRATE match.
All the above is on a per EMPNO basis.
Can anyone tell me how I can pull both records that do not have matching WRATE's but the WAGENO's are matching ???
SELECT E.WAGENO,EMPNO,REGHRS,WRATE,OTHRS,WAMT,
(SELECT SUM(WAMT)
FROM EMPEARNPERWAGE
WHERE WAGENO=E.WAGENO AND EMPNO=E.EMPNO AND WRATE=E.WRATE
AND DATEPAID>"12/31/2004" AND PPS>"12/31/2004"
AND PPE>"12/31/2004") AS YTD_AMT
FROM EMPEARNPERWAGE AS E
WHERE PYRLNO=2317
ORDER BY EMPNO
If this needs any more explanation let me know. Thank You.
faxpay, Tom
What's curious is if I have only one record of a particular WAGENO it pulls ok. As soon as I add that second matching WAGENO and they have different WRATE's then only one of the two records is pulled.
The WAMT field should not be summed and records combined unless the WAGENO and WRATE match.
All the above is on a per EMPNO basis.
Can anyone tell me how I can pull both records that do not have matching WRATE's but the WAGENO's are matching ???
SELECT E.WAGENO,EMPNO,REGHRS,WRATE,OTHRS,WAMT,
(SELECT SUM(WAMT)
FROM EMPEARNPERWAGE
WHERE WAGENO=E.WAGENO AND EMPNO=E.EMPNO AND WRATE=E.WRATE
AND DATEPAID>"12/31/2004" AND PPS>"12/31/2004"
AND PPE>"12/31/2004") AS YTD_AMT
FROM EMPEARNPERWAGE AS E
WHERE PYRLNO=2317
ORDER BY EMPNO
If this needs any more explanation let me know. Thank You.
faxpay, Tom