栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

hive依据指定条件设置别名

hive依据指定条件设置别名

使用case… when 语法来操作,when后的条件可以是某个值,也可以是表达式

-- 条件是具体的值
select 
	case col_name1
	when 1 then '别名1'
	when 2 then '别名2'
	else '别名3'
	end col_name1,
	col_name2
from table_name


-- 条件是表达式
select 
	case col_name1
	when col_name1 <1000 then '别名1'
	when col_name1 <2000 then '别名2'
	else '别名3'
	end col_name1,
	col_name2
from table_name
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/439172.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号