Select to_char(Contactdate,'HH24:MI:SS')
from CHSTAGING
我有这个sql查询,我想从时间戳中提取时间。但是,一旦我使用GROUP BY
,它就无法运作。
GROUP BY to_char(Contactdate,'HH24:MI:SS')
以下是数据集中时间戳的外观示例。我想在同一时间将行组合在一起。即。 HH:MI:SS
答案 0 :(得分:1)
如果正在播放,请将其放入CTE ......
with CTE as
(
select mt.*, to_char(contactdate, 'HH24:MI:SS') as ContactTime
from mytable mt
)
select ContactTime, count(somefield) as countedfield
from CTE
group by ContactTime
答案 1 :(得分:1)
试试这个: -
Select cast(contactdate as time) as Tim
from
INTERACT.UACI_CHSTAGING_MSISDN
group by cast(contactdate as time)
OR
Select tim from
(
Select to_char(Contactdate,'HH24:MI:SS') as tim
from INTERACT.UACI_CHSTAGING_MSISDN
) a
group by tim
希望这会有所帮助: - )