|
|
Archives of the TeradataForum
Message Posted: Thu, 21 Aug 2008 @ 16:48:37 GMT
Subj: | | How Can I Avoid Repeating an Expression? |
|
From: | | Pollack, Philip |
I am new to Teradata and the Forum.
How can I avoid repeating the expression "100 * (curr_bal - cl_amt) / cl_amt" below?
sel substr(date,1,7) Yr_Month,
Svc_Ownr_Cd,
Bucket,
case
when cl_amt = 0 and curr_bal > cl_amt then '(0) CL=0 & Bal>CL'
when curr_bal <= cl_amt then '(1) not OL'
else case
when 100 * (curr_bal - cl_amt) / cl_amt <= 10
then '(2) <= 10%'
when 100 * (curr_bal - cl_amt) / cl_amt <= 15
then '(3) <= 15%'
when 100 * (curr_bal - cl_amt) / cl_amt <= 20
then '(4) <= 20%'
when 100 * (curr_bal - cl_amt) / cl_amt <= 25
then '(5) <= 25%'
else '(6) > 25%'
end
end as OL_Pct,
count(1) Number
from Table
where ...
group by 1,2,3,4
Thanks.
Phil Pollack
| |