1,不写函数实现split截取
场景:dayNewStat+meilishuo+ipad+2003 (dayNewStat+meilishuo+iphone+2003)(dayNewStat+meilishuo+android+2003) 只取最后一位
设想:split('+')[-1] (python写法)
实现:有严格的格式要求,取巧方法,无技术含量
场景:只要status是ok的,且id最小
id type status
001 aaa ok
002 aaa error
010 aaa ok
003 bbb ok
实现:去重 & 按条件筛选:
select stat_date,record_tag,substring(record_tag,locate('+',replace(record_tag,'dayNewStat+meilishuo+',' dayNewStat-meilishuo-'))) as client_id,attr_value
from t_stat_daynew_classify_201306
where record_type='dayNewStat+app+device+clientID' and record_tag like 'dayNewStat+meilishuo+%' and attr_name ='totalDID' and attr_name_hash = 1380872519 and record_type_hash = 2039497004
group by stat_date,record_tag
having min(id) and if( (client_id>10000 and record_tag like 'dayNewStat+meilishuo+android%') or (client_id>2000 and client_id<5000 and record_tag like 'dayNewStat+meilishuo+ipad%') or (client_id>5000 and client_id<10000),'ok','del' ) = 'ok' order by stat_date,client_id
语法是够长的,不过也算是长见识了,毕竟不用自定义split函数来实现字符串的截取。