当前位置:网站首页>lateral view explode的另一种实现方式
lateral view explode的另一种实现方式
2022-08-09 09:12:00 【不爱研究的研究僧】
lateral view explode实现结果:
如果不用lateral view explode,可以这样实现:
步骤:
1.将一条记录变成n条一样的记录,即
前面再带上序号值,num是key,answers[num]即为所要的value,
2. 上图的实现通过两表连接的方式,
3.B表的实现就是生成递增数字,利用space得到n个空格,在对应空格前加上序号
--方法1
select
row_number() over() as id
from
(select split(space(299), ' ') as x) t
lateral view explode(x) ex;
--方法2
select pos + 1
from
(select 1 as id_start, 300 as id_end) t
lateral view posexplode(split(space(id_end - id_start), ' ')) ex as pos, blank;
posexplode(数组) t as pos, blank,只有第一个字段有值,是位置,第二个为空,如果是map就有值
边栏推荐
猜你喜欢
随机推荐
TestNG使用教程详解
RESTful
epoll LT和ET 问题总结
政务中心导航定位系统,让高效率办事成为可能
Anaconda4.8.3介绍、安装及使用教程安装(win10)并修改Jupyter默认工作目录
Redis缓存设计
多维度LSTM(长短期记忆)神经网络预测未来存款余额走势
运行flutter项目时遇到的问题
MySQL Checking and Filling Leaks (5) Unfamiliar Knowledge Points
数理逻辑MOOC+知识点总结(未完无待续)
js在for循环中按照顺序响应请求
学习栈的心得和总结(数组实现)
Getting started with ctfshow-web Part of the file upload part solution
HD Satellite Map Browser
MySQL查漏补缺(二)排序检索、过滤数据、模糊查询、正则表达式
【场景化解决方案】OA审批与金智CRM数据同步
绝了,这套RESTful API接口设计总结
【环境搭建】tensorrt
【培训课程专用】RPC模型:代码导读
gin中改进版curd接口例子