我已经构建了这样的查询
select IP,
(case when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)>60 then
hour_24_hour_format_num+1
end) as end_hr,
(case when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)<60 then MINUTE_NUM+
(SEGMENT_DURATION_TIME_SEC_QTY/60)
end)as end_min
from a608232_new_calls_with_tmst;
我想知道我可以在查询的then
部分执行2个操作。
像这样的东西
select IP,
(case when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)>60 then
hour_24_hour_format_num+1 and minute_num=0
end) as end_hr,
当我尝试这样做时,会在and
附近抛出语法错误。有没有办法实现这个目标?
更新:
This one worked for me.
select
IP,hour_24_hour_format_num,MINUTE_NUM,SEGMENT_DURATION_TIME_SEC_QTY/60
min_duration,
(case when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)>60 then
hour_24_hour_format_num+1
when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)<60 then
hour_24_hour_format_num
end) as end_hr,
(case when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)>60 then 0
when MINUTE_NUM+(SEGMENT_DURATION_TIME_SEC_QTY/60)<60 then MINUTE_NUM+
(SEGMENT_DURATION_TIME_SEC_QTY/60)
end)as end_min
from a608232_new_calls_with_tmst;
答案 0 :(得分:0)
CASE
表达式计算条件列表并返回多个可能的结果表达式之一。 由于它返回单个值,因此无法用于更新多个列或操作。