Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Tue, 18 Jan 2012 @ 01:16:43 GMT

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

Subj:   Re: How to CAST a number without getting a decimal point.
From:   DUELL, BOB

This one works as well, but sorry Deiter, yours padded the result with blanks at the beginning (although using the negative sign rather than multiplying by -1 was a nice catch. To summarize the 3 replies:

     select  cast (cast(acct_id*-1 as bigint ) as char(29)) as Glenn
           , -acct_id (format '-(15)9') (char(29)) as Deiter
           , cast (cast(acct_id*-1 as format '-(15)9' ) as char(29)) as Fred
     from (
        select cast(123775780 as DECIMAL(15,0)) as acct_id
        ) xxx

And the explanation from Mahesh was useful and enlightening.

Thanks all!

  <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: 28 Jun 2020