hey everyone,
Just wondering if you could give me a little insite on this query, which seems to be very simple, yet not returning the respected results
The locations table has 99 locations, however only 53 locations had accounts in Jan 2007. I am doing a left outer join to hopefully have all the locations listed and the number of accounts for each location. if the location has 0, I would still like it listed.
Here is an example of the query. I have tried it a few different ways, all with the same results
Just wondering if you could give me a little insite on this query, which seems to be very simple, yet not returning the respected results
The locations table has 99 locations, however only 53 locations had accounts in Jan 2007. I am doing a left outer join to hopefully have all the locations listed and the number of accounts for each location. if the location has 0, I would still like it listed.
Here is an example of the query. I have tried it a few different ways, all with the same results
Code:
SELECT
L.loccpcode,
count(A.acctcode) MnthTotal
FROM
locations L
LEFT OUTER JOIN ACCOUNT A ON (L.loccpcode = A.acctcpcode)
WHERE
TO_CHAR(TO_DATE(A.ACCTLOGDATE,'J'),'YYYY') = '2007'
AND TO_CHAR(TO_DATE(A.ACCTLOGDATE,'J'),'mm') = '01'
AND (A.ACCTDEACTIVE IS NULL)
GROUP BY
L.loccpcode