我是SQL方面的新手,在工作中我正在编写一些SQL查询。我遇到了一个拦截器,你们能帮我找到一个解决方案或者一个替代方案吗?
下面是我使用的查询(仅使用1行作为引用):
Select
USER_NAME,
TIME(CONVERT_TZ(START_TIME, '+00:00','America/Los_Angeles')) as 'PST Start',
TIME(CONVERT_TZ(END_TIME, '+00:00','America/Los_Angeles')) as 'PST End',
name as 'Type',
date(start_time) as 'Date',
WORKGROUP_NAME
from USER_SCHEDULE_INSTANCES
where user_name = 'prateeth'
and date(START_TIME) = '2018-01-01'
limit 1这是输出
USER_NAME PST Start PST End Date Type WORKGROUP_NAME
prateeth 06:00:00 09:00:00 2018-01-01 Work NACS Command Center如果不使用宏并接收这样的输出,该如何将其分割成半个小时的间隔:
USER_NAME PST Start PST End Date Type WORKGROUP_NAME
prateeth 06:00:00 06:30:00 2018-01-01 Work NACS Command Center
prateeth 06:30:00 07:00:00 2018-01-01 Work NACS Command Center
prateeth 07:00:00 07:30:00 2018-01-01 Work NACS Command Center
prateeth 07:30:00 08:00:00 2018-01-01 Work NACS Command Center
prateeth 08:00:00 08:30:00 2018-01-01 Work NACS Command Center
prateeth 08:30:00 09:00:00 2018-01-01 Work NACS Command Center发布于 2018-01-23 17:18:55
评论回答。创建一个时间表,并填充您要寻找的时间框架。类似于这样的东西:
Table Name: Dim_Time
example data:
ID starttime endtime
1 06:00 06:30
2 06:30 07:00
etc当您需要拆分到时间框架时,在from语句交叉连接到此表中。
From USER_SCHEDULE_INSTANCES
join dim_time on 1=1您可以在这个时刻表中添加第二个ID列,这将允许您对这个时间进行多个“版本”的分解。
希望这是明确的,如果你需要更多的评论。
https://stackoverflow.com/questions/48407006
复制相似问题