jasonhuibers
Programmer
Results of query are presently like this:
Category Count Status
Books 20 Closed
Books 10 OPEN
I would like to have them on one line like this - where Created_Count= Closed + Open:
Category Closed_Count Created_Count
Books 20 30
SELECT
B.Category,
count(distinct A.ID) COUNT,
CASE WHEN A.STATUS = 'C' THEN
'CLOSED'
ELSE
'OPEN'
END STATUS
FROM
Table1 A ,
Table2 B
WHERE
B.CATEGORY = A.CATEGORY
AND B.DES= 'Books'
AND TRUNC(A.DATETIME_STAMP) >= to_date('01-01-2011','DD-MM-YYYY')
group by B.DES,a.STATUS;
Category Count Status
Books 20 Closed
Books 10 OPEN
I would like to have them on one line like this - where Created_Count= Closed + Open:
Category Closed_Count Created_Count
Books 20 30
SELECT
B.Category,
count(distinct A.ID) COUNT,
CASE WHEN A.STATUS = 'C' THEN
'CLOSED'
ELSE
'OPEN'
END STATUS
FROM
Table1 A ,
Table2 B
WHERE
B.CATEGORY = A.CATEGORY
AND B.DES= 'Books'
AND TRUNC(A.DATETIME_STAMP) >= to_date('01-01-2011','DD-MM-YYYY')
group by B.DES,a.STATUS;