我遇到的问题是将TOT_MGCV_USE_QTY分为60。我的英语不太好。伙计们帮我
COUNT(CASE
WHEN SERVICE_TYPE IN (0, 100)
AND TOT_MGCV_USE_QTY / 60
THEN RECIPIENT END) AS MOC_VOICE_CHARGED_DURATION
答案 0 :(得分:1)
根据提供的sql,以下是我的理解: 您只希望在(0,100)中输入服务类型并且TOT_MGCV_USE_QTY除以60即表示接收者计数,即其余数为零... 如果是这种情况,则可以将需求用作where条件,如下所示...(可以根据需要在case语句中进行更改)
select count(receipient)
from ...
...
where
....
service_type in (0,100)
and mod(TOT_MGCV_USE_QTY,60) = 0
....;
答案 1 :(得分:0)
您尚未(TOT_MGCV_USE_QTY / 60)
选中任何值
COUNT (CASE
WHEN SERVICE_TYPE IN (0, 100)
AND (TOT_MGCV_USE_QTY / 60)=some_value
THEN RECIPIENT END
) AS MOC_VOICE_CHARGED_DURATION
我会像下面那样重写您的查询
sum (CASE
WHEN SERVICE_TYPE IN (0, 100)
AND (TOT_MGCV_USE_QTY / 60)=some_value
THEN 1 else 0 END
) AS MOC_VOICE_CHARGED_DURATION