hive - 根据 Hive 中的大小进行过滤
问题描述
我想根据大小过滤配置单元中的记录,如何实现?请帮忙。
询问
SELECT
t1.member_id,
t2.first_name,
t2.date_of_birth_sk,
COLLECT_LIST(t3.measure_title) as all_measure_desc,
size( COLLECT_LIST(t3.measure_title)) as ps
FROM qms_gic_lifecycle t1
INNER JOIN dim_member t2
on t1.member_id = t2.member_id
INNER JOIN dim_quality_measure t3
on t1.quality_measure_id = t3.quality_measure_id
where t1.status <> 'closed'
GROUP BY
t1.member_id,
t2.first_name,
t2.date_of_birth_sk;
解决方案
由于您拥有具有大小值的ps字段,因此将您的查询用作子查询,然后将 where 子句与ps字段一起使用以仅过滤匹配的行。
hive> Select * from (
SELECT
t1.member_id,
t2.first_name,
t2.date_of_birth_sk,
COLLECT_LIST(t3.measure_title) as all_measure_desc,
size( COLLECT_LIST(t3.measure_title)) as ps
FROM qms_gic_lifecycle t1
INNER JOIN dim_member t2
on t1.member_id = t2.member_id
INNER JOIN dim_quality_measure t3
on t1.quality_measure_id = t3.quality_measure_id
where t1.status <> 'closed'
GROUP BY
t1.member_id,
t2.first_name,
t2.date_of_birth_sk) s
where s.ps >= <size_value>;
推荐阅读
- c# - Microsoft ReportViewer - 调用 pdf 渲染时缺少 pdb 错误
- laravel - Socket.io laravel,ERR_CONNECTION_REFUSED
- c# - Bot Framework 自适应对话框。如何更改生成器(.lg 文件)?
- python - 删除pickle中的数据
- javascript - 如何制作仅用于水平滚动的粘性导航栏?
- python - 使用 Django 重置密码
- android-studio - gradle 是否在 Windows 上与 Android Studio 一起安装?
- excel - Excel VBA:如何根据数据库名称对行进行分组并根据特定的组名添加值?
- kivy - 使用带有实例化 Screen 类和 MDFloatingActionButtonSpeedDial 的 kivy ScreenManager 时出现问题
- javascript - 使用 JS 放大 SVG 的特定路径