|
6.含义有点不明白,
我根据平常赊账的情况来理解.按照某人最近的赊账日期,来划分帐龄,将其所有赊账金额相加.
select cust_id,
case when newest_time between 1 and 30 then '账龄范围1-30'
when newest_time between 31 and 60 then '账龄范围31-60'
when newest_time between 61 and 90 then '账龄范围61-90'
else '账龄大于90'
end ,
total_amt
from (select cust_id,min(trunc(sysdate-bill_date)) newest_time,
sum(pizza_amt) total_amt
from tab1
group by cust_id
)
order by 2,3 |
|