SELECT b.c_code
, b.dept_code
, f_tec_getdeptname('2000',dept_code) dept_code_2000
, f_tec_getdeptname('3000',dept_code) dept_code_3000
, COUNT(*) cnt_total
, NVL(SUM(a.summ_char_amou),0) amt_total
, COUNT(DECODE(a.mana_proc_stat,'800',1)) cnt_sign
, NVL(SUM(DECODE(a.mana_proc_stat,'800',a.summ_char_amou)),0) amt_sign
, COUNT(DECODE(a.mana_proc_stat,'200',1)) cnt_note
, NVL(SUM(DECODE(a.mana_proc_stat,'200',a.summ_char_amou)),0) amt_note
, COUNT(DECODE(a.mana_proc_stat,'800',1,'200',1)) cnt_sign_note
, NVL(SUM(DECODE(a.mana_proc_stat,'800',a.summ_char_amou,'200',a.summ_char_amou)),0) amt_sign_note
, COUNT(DECODE(b.yn_acc,'Y',1)) cnt_acc
, NVL(SUM(DECODE(b.yn_acc,'Y',a.summ_char_amou)),0) amt_acc
, COUNT(CASE WHEN a.mana_proc_stat IN ('100','550','900') THEN 1 END) cnt_nosign
, NVL(SUM(CASE WHEN a.mana_proc_stat IN ('100','550','900') THEN a.summ_char_amou END),0) amt_nosign
FROM tex_master a
, tex_pre_master b
WHERE a.mana_bill_numb = b.mana_bill_numb
-- AND a.head_docu_date >= '20080101'
-- AND a.head_docu_date <= '20080131'
GROUP BY b.c_code, b.dept_code
ORDER BY dept_code