This Question have 1 answers right now.

sql join no results error in amazon redshift

By : Elm
Source: Stackoverflow.com
Question!

This seems like a simple join in amazon redshift that I have done countless times, but it gives me the following error:

'No results were returned by the query. [SQL State=02000]'

Here is the sql:

select   
    campaign_id as product_campaign_id,  
    count(*) as sends  
into table_1  
from customer_to_product_campaign  
group by  
    product_campaign_id  
;  

select  
    product_campaign_id,  
    count(*) as opens_total  
into table_2  
from product_action_oc  
where  
    product_action_type_paid = 'open'  
group by   
    product_campaign_id  
;  

select  
    t1.product_campaign_id,  
    t1.sends,  
    t2.opens_total      
into table_3   
from table_1 t1  
left join table_2 t2  
on t1.product_campaign_id = t2.product_campaign_id  

;  

Additional info:
-table 1 (which is created without error) is ~ 6K rows
-table 2 (which is created without error) is ~ 10K rows
-the tables do have common product_campaign_id's, not that it should matter

thanks

By : Elm


Answers

This isn't an error, just a friendly Red Shift notification that there are no results being returned to the GUI. Basically, the into statement is absorbing all the results, so nothing is being returned.

Here is an example. Consider:

select *
into dum
from (select 1 as col) t;

This returns the same notification. But the data is there. Just do:

select *
from dum;

to see the one row just inserted.

(Note: I just tested this on Red Shift.)



Video about sql join no results error in amazon redshift