I am trying to write a join using temporary table in hive I am trying to write a join using subquery/ temporary table in hive but it doesn't seem to be working:
create temporary table  q as select server, max(time) as time from ghs group by header.server;

create temporary table new_joined as 
select q.server,ghs.proccount, ghs.net from ghs right outer join 
q on ghs.server = q.server;


the first query gives me around 23k rows, I want the joined table also to give me only 23k rows but I see that this is joining with each row in ghs.
ghs table is like superset having 1.2 million records.
Can someone help me understand what I am doing wrong?
I just had to add time also to my join condition on clause and I got the desired reult.