Hi,
I am having trouble figuring out how to get the data I need. I have 2 tables - a deliquint account table and an adjustment table. The deliquint account table can have multiple rows for one account. The adjustment table may or may not have 1 row for a subscriber if there is an adjustment on their account. I need to know every subscriber who has a delinquent account as defined:
Add up "3060" and "6090" rows for each subscriber (there may be multiple rows...) and then check the adjustment table and if there is an adjustment (type = 'A' and amount < 0) then subtract that amount from the "3060" + "6090" amount and if this is greater than 25 show record in report. Also, show records that are > 25 even if they don't have an adjustment.
Here is what I have so far.
SELECT
delAccount."3060", delAccount."6090", adjustment."amount"
FROM
delAccount LEFT OUTER JOIN adjustment ON delAccount."subid" = adjustment."subid#"
WHERE
adjustment."type" = 'A' AND adjustment."amount" < 0
ORDER BY
delAccount."subid" ASC
I haven't figured out how to sum the multiple rows for one subid in the delAccount table, but I can't even get this left join to work. It only gives me equal join records.
Any help is appreciated!
Thanks,
Barb
I am having trouble figuring out how to get the data I need. I have 2 tables - a deliquint account table and an adjustment table. The deliquint account table can have multiple rows for one account. The adjustment table may or may not have 1 row for a subscriber if there is an adjustment on their account. I need to know every subscriber who has a delinquent account as defined:
Add up "3060" and "6090" rows for each subscriber (there may be multiple rows...) and then check the adjustment table and if there is an adjustment (type = 'A' and amount < 0) then subtract that amount from the "3060" + "6090" amount and if this is greater than 25 show record in report. Also, show records that are > 25 even if they don't have an adjustment.
Here is what I have so far.
SELECT
delAccount."3060", delAccount."6090", adjustment."amount"
FROM
delAccount LEFT OUTER JOIN adjustment ON delAccount."subid" = adjustment."subid#"
WHERE
adjustment."type" = 'A' AND adjustment."amount" < 0
ORDER BY
delAccount."subid" ASC
I haven't figured out how to sum the multiple rows for one subid in the delAccount table, but I can't even get this left join to work. It only gives me equal join records.
Any help is appreciated!
Thanks,
Barb