Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 从时段中删除假日间隔_Sql_Intervals_Teradata_Period_Hour - Fatal编程技术网

Sql 从时段中删除假日间隔

Sql 从时段中删除假日间隔,sql,intervals,teradata,period,hour,Sql,Intervals,Teradata,Period,Hour,以下查询计算在收到请求和响应请求之间经过的工作时间。工作时间为周一至周五的9点至5点 select tmp.Request_Id, sum (tmp.hhmmss) as WorkHoursElapsed from (select Request_Id, period(cast(c.calendar_date as timestamp(6)) + INTERVAL '0000 09:00:00.00000' DAY TO SECOND,cast(calendar_date a

以下查询计算在收到请求和响应请求之间经过的工作时间。工作时间为周一至周五的9点至5点

select tmp.Request_Id, 
sum (tmp.hhmmss) as WorkHoursElapsed
from

    (select Request_Id,
    period(cast(c.calendar_date as timestamp(6)) + INTERVAL '0000 09:00:00.00000' DAY TO SECOND,cast(calendar_date as timestamp(6)) + INTERVAL '0000 17:00:00.000000' DAY TO SECOND) as p, 
    p P_INTERSECT b.ref as i, 
    (end(i) - begin(i)) Hour(4) to MINUTE as hhmmss 
    from calendar c 
    Cross join

        (select Request_Id, period(LocalTime_Received_RTA ,LocalTime_Responded_RTA) as ref 
        from Responded_Requests 
         WHERE LocalTime_Received_RTA<LocalTime_Responded_RTA 
        group by 1,2
        ) as b 

    where p overlaps b.ref
    and c.day_of_week between 2 and 6  

    ) as tmp

group by 1
我有另一张表,有开始和结束的时间间隔

开始时间:2014年1月1日12:00:00上午结束时间:2014年1月1日11:59:00下午


如何联接假日表以排除假日间隔?

您需要将其转换为Teradata SQL systax,在T-SQL中,您只需添加另一个联接和排除值,如下所示

SELECT m.*
    FROM mytable AS m
    JOIN othertable AS o
        ON m.date NOT BETWEEN o.StartDate AND o.EndDate

SELECT m.*
    FROM mytable AS m
    JOIN othertable AS o
        ON m.date < o.StartDate
           AND m.date > o.EndDate