SQL Server throwing divide by zero in a union query but individual queries working fine

877 views Asked by At

I have a complex query. Simplified, it looks like

select x,y... from table1 
UNION 
select x,y... from table2 
UNION 
select x,y... from table3 
UNION 
select x,y... from table4
UNION 
select x,y... from table5 
UNION 
select x,y... from table6

All these queries work fine when I run them individually. They even work fine when I use first 3 and last 3 queries in separate unions but it starts throwing divided by zero error when I run all of them together. Is there any workaround for this. It is just a temporary query for my research and analysis. So even an inefficient solution will work for now

0

There are 0 answers