I have an oracle SQL query that selects the count of the company from different department.
select
a.cust_nm,
a.cust_acct_nb,
a.cust_company_nb,
to_char(b.case_receive_dt, 'YYYYMM'),
count(*)
from
customer a, case b
where
a.cust_nb = b.case_cust_nb
and a.cust_company_nb in
('01062','01602','01603','01604','01605','01606')
and b.case_receive_dt > sysdate -365
and b.case_status_cd = 'CC'
group by
a.cust_nm,
a.cust_acct_nb,
a.cust_company_nb,
to_char(b.case_receive_dt, 'YYYYMM')
order by
a.cust_nm,
a.cust_acct_nb,
a.cust_company_nb,
to_char(b.case_receive_dt, 'YYYYMM')
This return the count of a.cust_nm, a.cust_acct_nb, a.cust_company_nb, to_char(b.case_receive_dt, 'YYYYMM')
In the same query, I need one more count of all cust_acct_nb
Eg:-
cust_acct_nb cust_acct_nb cust_acct_nb cust_acct_nb count(*) Final_Total
KFC 1 12 09-10-1991 12
KFC 1 12 10-10-1991 10
KFC 1 12 11-10-1991 10 32
KFC 2 12 09-10-1991 12
KFC 2 12 10-10-1991 10
KFC 2 12 11-10-1991 15 37
How can I get Final_Total in same query ?
Please help!!
Jitterbit, it will just return you the result and loop it through.