1,case when 的利用,清洗诸如评分等的内容,用例如下。

case
when new.comment_grade = '五星商户' then 50
when new.comment_grade = '准五星商户' then 45
when new.comment_grade = '四星商户' then 40
when new.comment_grade = '准四星商户' then 35
when new.comment_grade = '三星商户' then 30
when new.comment_grade = '准三星商户' then 25
when new.comment_grade = '二星商户' then 20
when new.comment_grade = '准二星商户' then 15
when new.comment_grade = '一星商户' then 10
when new.comment_grade = '准一星商户' then 5
when new.comment_grade = '该商户暂无星级' then 0
when new.comment_grade is NULL then old.comment_grade
else new.comment_grade
END as `new.comment_grade`,

2, 替换字符串中的一些内容。

regexp_replace(new.avg_price, '-', '')
替换 avg_price 中的中划线。

3, 字符串切分函数

split(a.tag_flag, '>')[1],
具体例子:
select split('a,b', ',')[0] ===> 结果 a

4, 字符串拼接函数

SELECT concat('1', '2');     ====》 结果 12
SELECT concat('1', '2', '3'); ===> 结果 123 ### 5, 去除字符串两端空格

trim(a.city)



6, 使用left join 或者 right join 补全数据

例如根据两张表,其中一张表格table2含有省份和城市的信息,
其中一张表table1只有城市信息,需要补全table1 中的省份信息,可以像如下做法:
select
a.name,
b.province,
a.city
from table1 a left join table2 b on a.city = b.city;

7,其他:清除一些不符合条件的数据

可以使用等值判断来处理数据
清除一些不符合条件的数据。
INSERT OVERWRITE table ods.js_beauty_tmp
SELECT *
from ods.js_beauty_tmp
WHERE map_lat != ''
AND map_lng != ''
AND map_lat IS NOT NULL
AND map_lng IS NOT NULL
AND map_lat != 0
AND map_lng != 0
AND map_lat not like '-%'
AND map_lng not like '-%'
and city != '其他城市'
and city != '点评实验室';

最新文章

  1. C# 委托及各种写法
  2. HttpWebResponse远程服务器返回错误: (500) 内部服务器错误。
  3. android自定义控件(3)-自定义当前按钮属性
  4. 从头开始linux-centos
  5. gauss消元
  6. Sql Server Analysis Service 处理时找到重复的属性键、找不到属性键错误(转载)
  7. asm单机dg dbca报错ORA-01031 CRS-2676,rman restore主库控制文件报错ORA-15081
  8. 【转】iOS开发UITableViewCell的选中时的颜色设置
  9. c/c++ void 指针
  10. 开发XMPP IM
  11. 将选择的图片显示在listview中,并显示filename,path和type
  12. 基础总结篇之二:Activity的四种launchMode
  13. 在windows中,使用SSH登录VMware ubuntu linux虚拟机
  14. UESTC 1599 wtmsb【优先队列+排序】
  15. ssh 端口转发实践
  16. ubuntu hadoop环境搭建
  17. 016_把普通用户免秘钥加入root用户的几种方式
  18. Maven的pom.xml文件结构之基本配置parent和继承结构[转]
  19. [图解tensorflow源码] [原创] Tensorflow 图解分析 (Session, Graph, Kernels, Devices)
  20. User类 新增共有属性Current ID

热门文章

  1. java实现12306的45分钟内支付,45分钟后取消订单功能?
  2. siebel 界面搭建
  3. Struts2学习-拦截器
  4. 查看锁定的session信息脚本
  5. Vim中 ctags 跳转直接跳到第一个匹配行的问题
  6. 什么是Load Average?
  7. ZJOI2019Day1镇海中学游记(3.24~3.27)
  8. Intellij IDEA 报错java.lang.NoClassDefFoundError
  9. 【洛谷P2324】[SCOI2005]骑士精神
  10. Android学习笔记_53_Android界面的基本属性