如何编写查询
select MC_HOST_ADDRESS, LOCATION_TYPE , MC_LOCATION, MSG, STREET/SUBLOCATION, DURATION/( CLOSED_TIME - MC_ARRIVAL_TIME)
if ( MC_ARRIVAL_TIME < Start Date ) then use Start Date else use End Date
where
MC_Object = ‘Camera’ AND
MC_Parameter= ‘CameraFeed’ AND
(MC_ARRIVAL_TIME between Start Date and End Date) OR
( CLOSED_TIME between Start Date and End Date) OR
( MC_ARRIVAL_TIME <= Start Date and CLOSED_TIME >= End Date) OR
( MC_ARRIVAL_TIME <= Start Date and CLOSED_TIME == NULL)enter code here`
答案 0 :(得分:0)
在查询中使用CASE语句而不是IF子句。
CASE WHEN MC_ARRIVAL_TIME < StartDate THEN StartDate ELSE EndDate END