Teradata : numeric flow while aggregating the data

Database
The Teradata Database channel includes discussions around advanced Teradata features such as high-performance parallel database technology, the optimizer, mixed workload management solutions, and other related technologies.
Enthusiast

Teradata : numeric flow while aggregating the data

HiAll,

Sel seq ,sum(cast (case when seq=1 then income1
When seq =2 then income2
End as decimal(18,2)) as col1
From table 1
Cross join (sel seq from seq table )

Like that we have 10 seq and income is huge ..just want to do the thing in one query .. While splitting its working but want to work in a one query.
I have extended the decimal length to 36,4 also.
Any suggestion will be much appreciated
3 REPLIES 3
Teradata Employee

Re: Teradata : numeric flow while aggregating the data

Are you certain the query is correct? Those must be truly huge numbers.

 

And why use (36,4)? Max precision available with native SQL types is 38 and there's no evident reason to double the scale. You could try DECIMAL(38,2) or NUMBER(*,2).

 

Enthusiast

Re: Teradata : numeric flow while aggregating the data

Thanks for replying .
But isn't it agrregated in that way
1 income1
2 income2
Then why its numeric overflow as its working fine while splitting
Teradata Employee

Re: Teradata : numeric flow while aggregating the data

Hard to say based on what you've provided so far. The query entered above isn't valid SQL.

 

If that's the result you want, it seems like you could do a simple SUM of each column, then "unpivot" the resulting single row to columns.