UNION ALL results


UNION ALL results

OK.  I'm stumped on this one.  I run a query in Teradata, and I get the following results:

Measure      Group  Count

Measure 1   XXX     33450

That's all good.  However, when I include that query as part of a UNION ALL query that, that particular row now looks like this

Measure      Group  Count

Measure 1   XXX     33580

Measure 2   YYY      25810

I know there is no overlap in the data.

What would cause the number to change like that by simply adding a UNION ALL and another query to this?

Any suggestions would be much appreciated

Tags (1)
Junior Contributor

Re: UNION ALL results

Could you shou the query or at least the basic syntax?

A common problem when using set operators:

The data type of a column is determined by the first select.

When the column is a VARCHAR(20) in the 1st select and a VARCHAR(30) in the 2nd, the data from the 2nd will be silently truncated to 20 chars.

To avoid that you have to cast the column in the 1st select to a VARCHAR(30).