日期:2014-05-17 浏览次数:20782 次
select (select busi_name from business b where b.busi_code = trim(t2.busi_code)) name, count(*), nvl(sum(t2.amount) / 100, 0), (select count(*) from trans_log t1, vip_log t where t.merch_phone = t1.phone_no and t1.term_trc = t.term_trc and t1.rsp_code = '00' and t1.busi_code = t2.busi_code ) sussess from trans_log t2, vip_log t3 where t3.merch_phone = t2.phone_no and t3.term_trc = t2.term_trc group by t2.busi_code
select to_char(t2.start_time, 'yyyy-MM-dd'), count(*), sum(t2.amount) / 100, (select count(*) from trans_log t1, vip_log t where t.merch_phone = t1.phone_no and t1.term_trc = t.term_trc and t1.rsp_code = '00' and to_char(t1.start_time, 'yyyy-MM-dd') = to_char(t2.start_time, 'yyyy-MM-dd')) sussess from trans_log t2, vip_log t3 where t3.merch_phone = t2.phone_no and t3.term_trc = t2.term_trc group by to_char(t2.start_time, 'yyyy-MM-dd')
--那個帖剛才就不是有人回你了嗎?用case when就可以了 count(case when t2.rsp_code='00' then 1 else null end) sussess