Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 21 Apr 2009 @ 09:32:06 GMT


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


Subj:   Re: SELECT Subquery
 
From:   Carpenter, Angela

Put your subquery as a table, and try using RANK.

Something like this (untested):

     SELECT
     Loan.LoanID,
     Tran_Amount.Amount
     FROM
     Loan,
     (SELECT LoanID, Amount, RANK() OVER (PARTITION BY LoanID ORDER BY PostDate DESC) as
     rank_amount FROM Tran WHERE tran_Type = 'D'
     and rank_amount = 1 ) Tran_Amount
     where Tran_Amount.LoanID = Loan.LoanID
     ;

Angela Carpenter



     
  <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