|
|
Archives of the TeradataForum
Message Posted: Tue, 29 Apr 2008 @ 22:56:56 GMT
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
And
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.)
Dave
| |