Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 11 Aug 2006 @ 21:56:11 GMT


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


Subj:   Request for help in converting the below query
 
From:   Pratheesh Venkataraman

Dear All,

I am trying to modifying the following query

     Select
                     CLM_LN_ADJMT_KEY, CLM_LN_SRVC_STRT_DT,
                     SRC_DW_CD, CLM_SRC_SYS_CD,
                     CLM_NBR, CLM_LN_NBR, MBR_KEY,
                     CLM_LN_ADJMT_NBR,
                     max (CLM_LN_ADJMT_NBR)
     OVER (PARTITION BY CLM_NBR, CLM_LN_NBR, SRC_DW_CD, CLM_SRC_SYS_CD, MBR_KEY
                     ORDER BY CLM_NBR,CLM_LN_NBR) MAX_ADJ_NBR
     From
                     DFLT_CLM_GTT
     Where
                     SRC_DW_CD = :src_dw_cd_in
                     and clm_disp_cd = 'READJ'

The above query needs to be modified to perform the following

It should test for the condition clm_disp_cd = 'READJ' only when there are duplicate adjustment number for the same claim line i.e.

If the below group by clause

     Group By Clause SRC_DW_CD, CLM_SRC_SYS_CD, CLM_NBR, CLM_LN_NBR,
     MBR_KEY, CLM_LN_ADJMT_NBR

returns more than 1 unique records, then use the following query

     Select
                     CLM_LN_ADJMT_KEY, CLM_LN_SRVC_STRT_DT,
                     SRC_DW_CD, CLM_SRC_SYS_CD,
                     CLM_NBR, CLM_LN_NBR, MBR_KEY,
                     CLM_LN_ADJMT_NBR,
                     max (CLM_LN_ADJMT_NBR)
     OVER (PARTITION BY CLM_NBR, CLM_LN_NBR, SRC_DW_CD, CLM_SRC_SYS_CD, MBR_KEY
                     ORDER BY CLM_NBR,CLM_LN_NBR) MAX_ADJ_NBR
     From
                     DFLT_CLM_GTT
     Where
                     SRC_DW_CD = :src_dw_cd_in
                     and clm_disp_cd = 'READJ'

If the group by clause return only one unique record, then use the following query

     Select
                     CLM_LN_ADJMT_KEY, CLM_LN_SRVC_STRT_DT,
                     SRC_DW_CD, CLM_SRC_SYS_CD,
                     CLM_NBR, CLM_LN_NBR, MBR_KEY,
                     CLM_LN_ADJMT_NBR,
                     max (CLM_LN_ADJMT_NBR)
     OVER (PARTITION BY CLM_NBR, CLM_LN_NBR, SRC_DW_CD, CLM_SRC_SYS_CD, MBR_KEY
                     ORDER BY CLM_NBR,CLM_LN_NBR) MAX_ADJ_NBR
     From
                     DFLT_CLM_GTT
     Where
                      SRC_DW_CD = :src_dw_cd_in

Sincere Thanks,

Pratheesh



     
  <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