Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 06 Feb 2008 @ 21:11:00 GMT


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


Subj:   Re: How to code a join or restructure table?
 
From:   Pugliesi, Anthony J

Michele:

You need to join the table to its self in order to get lower and upper amounts, see below.

     CREATE SET TABLE adhoc.rates ,NO FALLBACK ,
           NO BEFORE JOURNAL,
           NO AFTER JOURNAL,
           CHECKSUM = DEFAULT
           (
            RateID integer,
            Name  CHAR(6) CHARACTER SET LATIN NOT CASESPECIFIC,
            Amount decimal(6,4),
            Rate decimal(6,4)
            )
     UNIQUE PRIMARY INDEX ( RateID );


     insert into adhoc.rates values (65,'SCHDLA',0.1399,0.0430);

     insert into adhoc.rates values (66,'SCHDLA',0.1499,0.0470);

     insert into adhoc.rates values (67,'SCHDLA',0.1599,0.0500);

     insert into adhoc.rates values (68,'SCHDLA',0.1699,0.1000);


     SEL B.*
     FROM ADHOC.RATES A
     INNER  JOIN ADHOC.RATES B
     ON A.RATEID = B.RATEID - 1
     WHERE .1653 BETWEEN A.AMOUNT AND B.AMOUNT
     ;

Returns:

     RateID   Name     Amount   Rate
       68     SCHDLA   0.1699   0.1000


     
  <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