【发布时间】:2014-08-14 11:35:57
【问题描述】:
我想在特定条件下阻塞的情况下进行限制,有没有简单的方法;
我有一个这样的 sql ;我想限制条件 4,5,6 到 50K;
select SUBSCRIBER_KEY,
coalesce(
case when pct_1 >90 then
case when <condition_1> then 'L_1'
when <condition_2> then 'L_2'
when <condition_3> then 'L_3'
end
else null end,
case when pct_2<=90 and t.wk_dec_pct<=0.2
then
case when <condition_4> then 'L_4' --to limit output of this condition 50000
when <condition_5> then 'L_5' --to limit output of this condition 50000
when <condition_6> then 'L_6' --to limit output of this condition 50000
end
else null end,
case when pct_2<=90 and t.wk_dec_pct>=0.2 and t.acc_type='main'
then
case when <condition_7> then 'L_7'
when <condition_8> then 'L_8'
when <condition_9> then 'L_9'
end
else null end
)
from table_t t
where ...
【问题讨论】:
-
什么是“设置限制”?
-
我的意思是;我在 table_t 中有 10mio 订阅者,当我运行代码时,我在 L_4 (condition_4) 中得到 120K,我想得到的不是 120K,而是 50K
标签: sql sql-server tsql case-when