分组统计:
1、使用count+case来用字段的值来做统计标准
2、使用"$"来填充日期格式,将日期格式直接拼接到sql中
3、循环拆分带“,”的字符串,最好在代码中变为list,在sql中循环
if (this.type.equals("1")){
this.sqlType = "'yyyy-MM-dd hh24'";
}
if (this.type.equals("2")){
this.sqlType = "'yyyy-MM-dd'";
}
if (this.type.equals("3")){
this.sqlType = "'yyyy-MM'";
}
for example :
select TO_CHAR(in_ivr,${sqlType}) in_ivr,
count(case
when call_type = '1' then
'call_in'
end) as call_in,
count(case
when call_type = '2' then
'call_out'
end) as call_out
FROM comm_call_log
group by TO_CHAR(in_ivr,${sqlType})