gpt4 book ai didi

mysql - SEC_TO_TIME 函数在 case 函数内中断

转载 作者:行者123 更新时间:2023-11-29 10:04:45 25 4
gpt4 key购买 nike

我的选择查询中有一个 case 函数。在这种情况下,我想使用 SEC_TO TIME 函数将以秒为单位的“SongLength”转换为 mm:ss 格式。但是,将此函数放入其中时出现语法错误。

select SongTitle,Artist,SongLength
case
when SongLength < 600 then
sec_to_time(SongLength)
else
sec_to_time(SongLength)
end
from Songs, Artists where Songs.ArtistId = Artists.Id
order by SongTitle;

最佳答案

尝试 SongLength 将别名设置为:

select SongTitle,Artist,
(case
when SongLength < 600 then
sec_to_time(SongLength)
else
sec_to_time(SongLength)
end) as SongLength
from Songs join Artists
on ( Songs.ArtistId = Artists.Id )
order by SongTitle;

关于mysql - SEC_TO_TIME 函数在 case 函数内中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52137901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com