日期:2014-05-16 浏览次数:20633 次
--1)
select * from fact_xs_week_code t where not exists(
select * from fact_xs_week_code where key_code=t.key_code and amount=0
)
--2)
select *,row_number() over(partition by key_code order by total) number
from (select *,sum(amount) over(partition by key_code) total
from fact_xs_week_code) t
with t
as
(
select key_code, the_week, sum(amount) as amount, sum(amount_add) as amount_add
from fact_xs_week_code a
where a.the_week>=201301 and a.the_week<=201304
group by key_code, the_week
)
select t.*
from t
inner join
(
select key_code
from t
group by key_code
having COUNT(*) = COUNT(case when amount = 0 then 1 else null end)
)tt
on t.key_code <> tt.key_code