문제

Do Impala or Hive have something similar to PL/SQL's IN statements? I'm looking for something like this:

SELECT * 
FROM employees
WHERE start_date IN
(SELECT DISTINCT date_id FROM calendar WHERE weekday = 'MON' AND year = '2013');

This would return a list of all the employees that started on a Monday in 2013.

도움이 되었습니까?

해결책

I should mention that this is one possible solution and my preferred one:

SELECT * 
FROM employees emp
INNER JOIN 
    (SELECT 
    DISTINCT date_id
    FROM calendar 
    WHERE weekday = 'FRI' AND year = '2013') dates
ON dates.date_id = emp.start_date;

다른 팁

select * 
from employees emp, calendar c 
where emp.start_date = c.date_id 
and weekday = 'FRI' and year = '2013';

Nested queries with expressions are not currently supported in hive 0.10 and below. What version on hive/impala are you running

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top