Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Tue, 29 Apr 2008 @ 22:56:56 GMT

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

Subj:   Re: Case Statement and Crystal Reports
From:   Curley, David

The case statement should return a value, not a chunk of a WHERE clause.

Try something like

     SNPSHT_DT between
     Case when extract(day from current_date)) = 1 then
     add_months(current_date, -1) else cast(current_date/100 * 100 + 1 as
     date) end
     Case when extract(day from current_date)) = 1 then current_date - 1 else
     SNPSHT_DT end

(Note that if your table is partitioned on SNPSHT_DT, that last bit would probably stop it from using partition elimination. If SNPSHT_DT is always <= current_date, you can use current_date there. I don't know that it will use partition elimination if you use current_date, but at least there's the chance since all values in the two case statements can be determined by the optimizer before execution.)


  <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: 27 Dec 2016