Question

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.

Était-ce utile?

La solution

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;

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top