hive - How to properly use parentheses in a complex SQL query -


i have confusion regarding how use parentheses in sql query.

the query below throws error

error while compiling statement: failed: parseexception cannot recognize input near '(' '(' 'select' in source

query:

select      customer_id, order_id, city,       ((query_1 )      join     (query_2 ) b on a.customer_id = b.customer_id) c 

but on other hand query below works

select      customer_id, order_id, city,       (query_1)  join     (query_2) b on a.customer_id = b.customer_id 

update: i'm running on hive

the first query throws error because nested query has no output fields. fix adding 'select * from' or 'select [list_the_fields] from':

select  c.customer_id, c.order_id, c.city,   (select * (query_1 )  join (query_2 ) b on a.customer_id = b.customer_id) c 

but second query better


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -