Hi,
I'm working on a database where I need to calculate some data that fits
certain sets of parameters, but I'd like it to give me more information
than I know how to get.
As an example, let's say I'm querying a table with the following fields:
pmt_no pmt_amt staff_id
pmt_no is unique, but isn't being used in these calculations.
I've done a query that counts the number of payments as long as the
payment is more than 50:
SELECT tbl_accounts.st aff_id, Count(tbl_accou nts.pmt_amt) AS no_of_payments
FROM tbl_accounts
WHERE (((tbl_accounts .pmt_amt)>=50))
GROUP BY tbl_accounts.st aff_id;
This works fine, as far as it's meant to: it gives me a list of all the
people who've had any payments >=50.
However, what I'd really like is maybe to link this with another table
that contains *all* staff_ids and, if they haven't had a payment of over
50, I'd like my query to give me a '0' next to that staff id.
Is this possible or am I hoping for too much? :)
(Please do let me know if anything is unclear - I tried to think of as
simple an example as possible; my real data is very slightly more
complex, but the principle is the same!)
Thank you for reading this far. ;)
-Jen (if you care to reply by email, remove the spork)
I'm working on a database where I need to calculate some data that fits
certain sets of parameters, but I'd like it to give me more information
than I know how to get.
As an example, let's say I'm querying a table with the following fields:
pmt_no pmt_amt staff_id
pmt_no is unique, but isn't being used in these calculations.
I've done a query that counts the number of payments as long as the
payment is more than 50:
SELECT tbl_accounts.st aff_id, Count(tbl_accou nts.pmt_amt) AS no_of_payments
FROM tbl_accounts
WHERE (((tbl_accounts .pmt_amt)>=50))
GROUP BY tbl_accounts.st aff_id;
This works fine, as far as it's meant to: it gives me a list of all the
people who've had any payments >=50.
However, what I'd really like is maybe to link this with another table
that contains *all* staff_ids and, if they haven't had a payment of over
50, I'd like my query to give me a '0' next to that staff id.
Is this possible or am I hoping for too much? :)
(Please do let me know if anything is unclear - I tried to think of as
simple an example as possible; my real data is very slightly more
complex, but the principle is the same!)
Thank you for reading this far. ;)
-Jen (if you care to reply by email, remove the spork)
Comment