Search code examples
sqlhadoopplsqlhiveimpala

Do Impala or Hive have something like an IN clause in other SQL syntaxes?


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.


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;