I am trying to count the number of two types of transactions in a column and to return a value of 0 if there are none. The table is Transaction, the columns I want returned are the account number and a column for the count each of the two transactions listed. here's what I have, but it doesn't run:
SELECT
ACCTNBR,
COUNT(CASE when RTXNTYPCD='XDEP'then 1 else 0) AS Deposits,
COUNT(CASE when RTXNTYPCD='PWTH'then 1 else 0) AS Debits
FROM
TRANSACTION
WHERE
((POSTDATE BETWEEN TO_DATE('05-01-2014','MM-DD-YYYY')) AND TO_DATE('05-31-2014','MM-DD-YYYY'))
and ACCTNBR in ( 406, 1206, 1347, 4556, 6668, 9845)
GROUP BY
ACCTNBR
THENkeywords? Or maybe adding anENDto theCASE? ;)