Can I do Union / Union ALL in Custom SQL Redshift?


Is UNION ALL / UNION not allowed in custom SQL for Redshift? I was testing with some sample codes but got errors as below:

I am good to run both queries separately in custom SQL. Appreciated for any advice!

Hi @Yuxiu_Gan First of all, welcome to the QuickSight community :slight_smile:

I am sorry but I dont see any errors in the screenshot you have shared. Am I missing something?

Also, as far as your question around using union / union all in custom SQL within QuickSight goes, I dont see why that would be a problem (assuming it is not hitting the number of rows / size limits) as long as your query is correct and you’re able to run it on Redshift outside of QuickSight.

1 Like

Sorry I posted a wrong screenshot. Just updated the image!

I am also thinking if this is due to the row/size limits. However, I was good to run both separately in QS.

1 Like

@Yuxiu_Gan in the screenshot you updated, I can see there is a syntax error in the second “selct” statement… Also, can you click on show details to see what additional error info is provided?

Whats the total number of rows when you run the 2 queries separately?


Hi @Yuxiu_Gan

A union all requires the same columns to be in the same positions for both queries.

For example you might look to do

select customer_id,date from table1 
select customer_id,date from table2

If the names are different you would need to rename them to a similar name.

I’m assuming that’s the issue.

Hi @Yuxiu_Gan Checking in. We have not heard back from you regarding your question. We’d still like to help. If we do not hear back in the next 7 days, we will archive the question.