HI,
I am trying to create a report involving a left outer join. I couldn't figure it out in 8.5 so I finally upgraded to 9, but I still can't get it to work. Here is the situation:
I have 3 tables with the following fields
subscriber - each subscriber has one record
subnum
subname
etc...
subaccount - each subscriber will have at least one, but can have many - (must add up all 3060's for one subnumber)
subnum
3060
6090
90
subadjustment - can have none or many - add up adjAmt+TaxAmt on all records for one subscriber
subnum
adjAmt
TaxAmt
This query should result in the total past due amounts for each subscriber taking into account any adjustment amount. The adjustment amount needs the left outer join.
subscriber table
100 JOhn Smith
200 Barb Smith
300 Alex Carter
subAccount table
subnum 3060 6090 90
100 20.00 0 0
100 5.00 25.00 0
200 0 0 0
300 23.00 1.00 45.00
300 0 23.00 0
300 10.00 1.00 5.00
400 60.00 0 0
subAdjustment table
subnum adjAmt taxAmt
300 2.00 0
300 -10.00 -1.00
300 -2.00 0
400 -20.00 -10.00
400 -10.00 0
700 -20.00
When I run my query I want all subscribers that have a past due balance of > 25.00. A past due balance is defined as all 3060,6090,90 past due records for each subnum + all negative adjAmt's (only select adjAmt's that are negative and add in taxAmt) for that subscriber.
The result for the 3 above tables would be:
subnum 3060 6090 90 adjAmt PastDueAmount
100 25.00 25.00 0 0 50.00
300 33.00 25.00 50.00 -13.00 37.00
400 will not be in the list because the adjAmt brings this subscriber below 25.00.
I have tried the following:
COMMAND
SELECT
SUM(ADJAMT) + SUM(TAXAMT) AS adjamt
FROM
subAdjustment
WHERE
ADJAMT < 0
GROUP BY SUBNUM
Then I link the other two tables - subscriber -> subaccount inner join
subscriber -> subAdjustment left outer join
This will run forever and when I stop it - it stops on the 1st record with an adjAmt.
I have also tried 2 commands and that takes to long.
I have also tried one big query with an inner join on subscriber and subaccount and then left outer to bring in the subAdjustment, but it doesn't work. I only get subscribers that have an adjustment amount - cr treats it like an inner join.
I'm sorry this is so long. Thanks for any help.
Barb Wrede
I am trying to create a report involving a left outer join. I couldn't figure it out in 8.5 so I finally upgraded to 9, but I still can't get it to work. Here is the situation:
I have 3 tables with the following fields
subscriber - each subscriber has one record
subnum
subname
etc...
subaccount - each subscriber will have at least one, but can have many - (must add up all 3060's for one subnumber)
subnum
3060
6090
90
subadjustment - can have none or many - add up adjAmt+TaxAmt on all records for one subscriber
subnum
adjAmt
TaxAmt
This query should result in the total past due amounts for each subscriber taking into account any adjustment amount. The adjustment amount needs the left outer join.
subscriber table
100 JOhn Smith
200 Barb Smith
300 Alex Carter
subAccount table
subnum 3060 6090 90
100 20.00 0 0
100 5.00 25.00 0
200 0 0 0
300 23.00 1.00 45.00
300 0 23.00 0
300 10.00 1.00 5.00
400 60.00 0 0
subAdjustment table
subnum adjAmt taxAmt
300 2.00 0
300 -10.00 -1.00
300 -2.00 0
400 -20.00 -10.00
400 -10.00 0
700 -20.00
When I run my query I want all subscribers that have a past due balance of > 25.00. A past due balance is defined as all 3060,6090,90 past due records for each subnum + all negative adjAmt's (only select adjAmt's that are negative and add in taxAmt) for that subscriber.
The result for the 3 above tables would be:
subnum 3060 6090 90 adjAmt PastDueAmount
100 25.00 25.00 0 0 50.00
300 33.00 25.00 50.00 -13.00 37.00
400 will not be in the list because the adjAmt brings this subscriber below 25.00.
I have tried the following:
COMMAND
SELECT
SUM(ADJAMT) + SUM(TAXAMT) AS adjamt
FROM
subAdjustment
WHERE
ADJAMT < 0
GROUP BY SUBNUM
Then I link the other two tables - subscriber -> subaccount inner join
subscriber -> subAdjustment left outer join
This will run forever and when I stop it - it stops on the 1st record with an adjAmt.
I have also tried 2 commands and that takes to long.
I have also tried one big query with an inner join on subscriber and subaccount and then left outer to bring in the subAdjustment, but it doesn't work. I only get subscribers that have an adjustment amount - cr treats it like an inner join.
I'm sorry this is so long. Thanks for any help.
Barb Wrede