数据处理
- 判断是否超时,时间是否大于当前时间
- 计算分钟数
- 时间格式化处理
- 如果数值类型进行转换字符类型
- 字符拼接
- case-when代替if-else
- 判断数据空(特殊:含空数据、空字符处理)
select
case when cc.OVERTIME > NOW() then '1' else '0' end as is_timeout,
TIMESTAMPDIFF(MINUTE, cc.CREATE_TIME,cc.ARCHIVE_DATE) AS FLOW_TIME,
CASE WHEN TPP.FLAG IS NULL THEN '-1' WHEN LENGTH(TPP.FLAG )=0 THEN '-1' ELSE TPP.FLAG END AS SHEET_TYPE,
CASE cc.P_STATE when '70010004' or '70010006' then '1' ELSE '0' END as SHEET_STATUS,
CASE cc.cont_level WHEN '一级' THEN '1' WHEN '二级' THEN '2' ELSE '3' END as sms_level,
IFNULL(CAST(cc.CONTENT AS CHAR),'-1') as cmplnt_desc,
DATE_FORMAT(ftr.SIGN_DATE,'%Y%m%d') as sent_date,
from table_name cc
WHERE 1=1
and cc.CREATE_DATE BETWEEN '2023-12-24 00:00:00' and '2023-12-26 00:00:00'