Presto SQL/Hive子查询还是加入?

发布于 2025-02-11 21:07:35 字数 723 浏览 1 评论 0原文

我正在研究一个需要使用另一个Hive表的查询,以使用用户ID号来绘制用户名。仅仅是为了该用户名的结果,还是可以写一个子查询,还是我应该加入?

表1:分配的_tasks具有用于task_number,所有者,标题,描述,进度,ds

表2的列:员工_INFO具有formemeree_id,雇用employee_name,lighteree_team的列

SELECT task_numb,
owner_id,
title,
description,
progress
WHERE ds = 'DATEID'
AND progress != 'FINISHED' 

,我需要使用aslore_id(int)从另一个Hive表中获取lighteee_name(string)。加入另一个表或使用子查询并在所有者_ID列中显示结果是有意义的吗?这将如何结构?

例子:

SELECT
task_numb,
(SELECT employee_name
FROM employee_info 
WHERE employee_id = owner_id) as Owner
title,
description,
progress
WHERE ds = '<today>'
AND progress != 'FINISHED' 

I am working on a query that requires I join with another hive table to pull a username using a user ID number. Is it possible to write a sub-query just for the result of that user name or should I do a Join?

Table 1: Assigned_Tasks has columns for task_number, owner_id, title, description, progress, ds

Table 2: Employee_info has columns for employee_id, employee_name, employee_team

SELECT task_numb,
owner_id,
title,
description,
progress
WHERE ds = 'DATEID'
AND progress != 'FINISHED' 

I need to use the owner_id(int) to get employee_name(string) from another hive table. Does it make sense to join with the other table or use a subquery and display the result in the owner_id column? How would that be structured?

Example:

SELECT
task_numb,
(SELECT employee_name
FROM employee_info 
WHERE employee_id = owner_id) as Owner
title,
description,
progress
WHERE ds = '<today>'
AND progress != 'FINISHED' 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与酒说心事 2025-02-18 21:07:35

为什么不使用EMP tbale的简单加入?

SELECT
task_numb,
e.employee_name as Owner
title,
description,
progress
from Assigned_Tasks 
join employee_info e on  employee_id = owner_id  -- join emp table.
WHERE ds = '<today>'
AND progress != 'FINISHED' 

如果EMP ID在Employee_Info表中是唯一的,则不应该有任何问题。

why not use simple join with emp tbale ?

SELECT
task_numb,
e.employee_name as Owner
title,
description,
progress
from Assigned_Tasks 
join employee_info e on  employee_id = owner_id  -- join emp table.
WHERE ds = '<today>'
AND progress != 'FINISHED' 

if emp id is unique in employee_info table, there shouldnt be any issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文