I
iliace
This one has me stumped. My question is, basically: "For the two
departments in question, list all employees who (a) got paid on
11/27/2006, and (b) had one of two particular deductions on that
paycheck." I replaced names of actual tables with more readable ones.
I also broke out each where condition on a separate line.
SELECT chkVwDeduction.chkVwHOMEDEPT, chkVwDeduction.[FILE#],
chkVwDeduction.NAME, chkVwDeduction.chkVwDEDCODE,
chkVwDeduction.chkVwDEDAMT, chkVwDeduction.chkVwPAYDATE
FROM chkVwDeduction
WHERE
(((chkVwDeduction.chkVwHOMEDEPT) In ('600000','700000'))
AND
((chkVwDeduction.[FILE#]) In
(SELECT DISTINCT chkVwDeduction.[FILE#]
FROM chkVwDeduction
WHERE chkVwDeduction.chkVwPAYDATE=#11/27/2006# AND
chkVwDeduction.chkVwDEDCODE IN ('W','X','Y','Z')))
AND
((chkVwDeduction.chkVwDEDCODE) In ('1','2'))
AND
((chkVwDeduction.chkVwPAYDATE)=#11/27/2006#))
ORDER BY chkVwDeduction.chkVwHOMEDEPT;
I am using a linked table from the payroll software, which has a table
called chkVwDeduction. Each record is a deduction taken on the
paycheck. File number uniquely identifies each record.
So, I need these criteria:
* home department is either 600000 or 700000
* employees who had a deduction of either (W X Y or Z) which indicate
direct deposit, meaning hours worked and paid, on the pay date in
question
* deduction code and amount if the employee paid had a deduction code
of either (1 or 2)
* pay date 11/27/2006
For some reason, the inner query performs the required filter by date.
In other words, this by itself does what it's supposed to (it's the IN
SELECT from the WHERE condition above):
SELECT DISTINCT chkVwDeduction.[FILE#]
FROM chkVwDeduction
WHERE chkVwDeduction.chkVwPAYDATE=#11/27/2006# AND
chkVwDeduction.chkVwDEDCODE IN ('W','X','Y','Z'))
However, the larger query ignores this condition and returns a few
random pay dates earlier this year.
Can anyone see where the issue is? I tried just about everything.
Technically, I could just match on check sequence number, but it should
be working as is, correct?
departments in question, list all employees who (a) got paid on
11/27/2006, and (b) had one of two particular deductions on that
paycheck." I replaced names of actual tables with more readable ones.
I also broke out each where condition on a separate line.
SELECT chkVwDeduction.chkVwHOMEDEPT, chkVwDeduction.[FILE#],
chkVwDeduction.NAME, chkVwDeduction.chkVwDEDCODE,
chkVwDeduction.chkVwDEDAMT, chkVwDeduction.chkVwPAYDATE
FROM chkVwDeduction
WHERE
(((chkVwDeduction.chkVwHOMEDEPT) In ('600000','700000'))
AND
((chkVwDeduction.[FILE#]) In
(SELECT DISTINCT chkVwDeduction.[FILE#]
FROM chkVwDeduction
WHERE chkVwDeduction.chkVwPAYDATE=#11/27/2006# AND
chkVwDeduction.chkVwDEDCODE IN ('W','X','Y','Z')))
AND
((chkVwDeduction.chkVwDEDCODE) In ('1','2'))
AND
((chkVwDeduction.chkVwPAYDATE)=#11/27/2006#))
ORDER BY chkVwDeduction.chkVwHOMEDEPT;
I am using a linked table from the payroll software, which has a table
called chkVwDeduction. Each record is a deduction taken on the
paycheck. File number uniquely identifies each record.
So, I need these criteria:
* home department is either 600000 or 700000
* employees who had a deduction of either (W X Y or Z) which indicate
direct deposit, meaning hours worked and paid, on the pay date in
question
* deduction code and amount if the employee paid had a deduction code
of either (1 or 2)
* pay date 11/27/2006
For some reason, the inner query performs the required filter by date.
In other words, this by itself does what it's supposed to (it's the IN
SELECT from the WHERE condition above):
SELECT DISTINCT chkVwDeduction.[FILE#]
FROM chkVwDeduction
WHERE chkVwDeduction.chkVwPAYDATE=#11/27/2006# AND
chkVwDeduction.chkVwDEDCODE IN ('W','X','Y','Z'))
However, the larger query ignores this condition and returns a few
random pay dates earlier this year.
Can anyone see where the issue is? I tried just about everything.
Technically, I could just match on check sequence number, but it should
be working as is, correct?