hazelsisson
Programmer
Hi guys,
It's an SQL problem - the query works fine without the date bits in the where clause, but as soon as I put them in it stops working. I've searched through many similar threads on the forum but none have pinpointed my problem!
Tables:
TIS_LINES
Line
CALLS_SUMMARY
Ln Total
TIS_LINES is a list of telephone extension numbers, and CALLS_SUMMARY has call prices for SOME of these lines. I want all the numbers to show though, which is the problem at the moment.
Desired output:
LINE TTOTAL
1234 30
1220 0 <- Line has no entry in CALLS_SUMMARY.
Actual Output:
LINE TTOTAL
1234 30
i.e. lines with no entries in CALLS_SUMMARY are omitted.
Here's my query:
I can see that c.MIN_OF_START and c.MAX_OF_END are null if the line is in TIS_LINES and not in CALLS_SUMMARY, but I'm not sure how to overcome this in my query. It must be something simple!?
Thanks so much for your help, it's driving me crazy!
Hazel
It's an SQL problem - the query works fine without the date bits in the where clause, but as soon as I put them in it stops working. I've searched through many similar threads on the forum but none have pinpointed my problem!
Tables:
TIS_LINES
Line
CALLS_SUMMARY
Ln Total
TIS_LINES is a list of telephone extension numbers, and CALLS_SUMMARY has call prices for SOME of these lines. I want all the numbers to show though, which is the problem at the moment.
Desired output:
LINE TTOTAL
1234 30
1220 0 <- Line has no entry in CALLS_SUMMARY.
Actual Output:
LINE TTOTAL
1234 30
i.e. lines with no entries in CALLS_SUMMARY are omitted.
Here's my query:
Code:
SELECT t.LINE_NUMBER LINE, SUM(c.TOTAL) TTOTAL
FROM TIS_LINES t, CALLS_SUMMARY c
WHERE t.LINE_NUMBER(+) = c.LN
AND c.MIN_OF_START BETWEEN TO_DATE('18-Feb-2004','DD-MON-YYYY') AND TO_DATE('31-May-2004','DD-MON-YYYY')
AND c.MAX_OF_END BETWEEN TO_DATE('01-Mar-2004','DD-MON-YYYY') AND TO_DATE('01-Jun-2004','DD-MON-YYYY')
GROUP BY t.LINE_NUMBER
I can see that c.MIN_OF_START and c.MAX_OF_END are null if the line is in TIS_LINES and not in CALLS_SUMMARY, but I'm not sure how to overcome this in my query. It must be something simple!?
Thanks so much for your help, it's driving me crazy!
Hazel