/*input*/
create table tab1( interval varchar(100));
insert into tab1 values( '44:46:00' );
insert into tab1 values( '5:04' );
/*Query*/
select case when charindex(':',interval,4) = 0 then interval
else left(interval,charindex(':',interval,4)-1) end from tab1
WITH formatted_time AS (
SELECT
player,
CAST(SUBSTRING(time_played, 1, 2) AS INT) * 60 + CAST(SUBSTRING(time_played, 4, 2) AS INT) AS time_in_seconds
FROM
your_table
)
SELECT
player,
time_in_seconds,
time_in_seconds / 60 || ':' || time_in_seconds % 60 AS time_played_formatted
FROM
formatted_time
2条答案
按热度按时间wgmfuz8q1#
brccelvz2#