Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 19 Nov 2003 @ 15:57:45 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: 2616 error with UNION
 
From:   Jason Fortenberry

With a union, the results of the first select statement determine the datatype for the entire resulting union set. So if one of the following select statements return a value larger than the datatype supports from your first select statement, you would get the 2616 error. Without knowing what type col_1 of tab_name_1 is, it is unclear what datatype is being used.

Try casting the SUMs in your first select statement as decimal (18,2) or something like that and hopefully that will support any results you get. So rewrite the first select as below....

SELECT 'tab_name_1' (VARCHAR (100)) AS Tab
                , col_g as COMPANY
                , cast (SUM (col_1) as decimal(18,2))    AS sum_1
                , cast (SUM (col_2) as decimal(18,2))    AS sum_2
                , cast (SUM (col_3) as decimal(18,2))    AS sum_3
                , cast (SUM (col_4) as decimal(18,2))    AS sum_4
                , cast (SUM (col_5) as decimal(18,2))    AS sum_5
          FROM tab_name_1
          WHERE col_6 <> 0
          GROUP BY 2

--Jason



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023