Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

correlated subquery in hive

avatar
Expert Contributor

How to use data from outer query in the inner query or subquery in hive?I am trying to use ndo.FromDate and ndo.ToDate in the second JOIN but that would not work

LEFT JOIN 
Temp.NumberOfDaysOnline ndo
ON
ndo.sku = nr.sku
JOIN
gadb.gasessiondata gasessiondata
ON 
1=1
LEFT JOIN 
(
 SELECT SUM(gasessiondata.sessions) As visitsOnDaysSKUWasLive
 FROM 
 gadb.gasessiondata gasessiondata
 WHERE 
 gasessiondata.date >= ndo.FromDate
 AND 
 gasessiondata.date < ndo.ToDate
 ) AS visits
1 ACCEPTED SOLUTION

avatar
Super Guru

@Simran Kaur

You need to use a join or a sub-query within the sub-query. You can access out query from inner query. It is the other way around and by design for any SQL-like language.

View solution in original post

1 REPLY 1

avatar
Super Guru

@Simran Kaur

You need to use a join or a sub-query within the sub-query. You can access out query from inner query. It is the other way around and by design for any SQL-like language.