为什么在使用 Union All 和强制转换函数时出现错误?
我正在使用 union all 将不同的数据表组合在一起。在最后一行中,ride_length
是字符串类型,因此我决定使用强制转换函数将其更改为时间函数。
我收到一个错误:
无效的时间字符串“24:59:55”
SELECT ride_id, rideable_type, started_at,ended_at,ride_length,day_of_week,start_lat, start_lng, end_lat, end_lng, member_casual
FROM `cyclistic-case-study-340816.2021_11.nov`
UNION ALL
SELECT ride_id, rideable_type, started_at,ended_at,ride_length,day_of_week,start_lat, start_lng, end_lat, end_lng, member_casual
FROM `cyclistic-case-study-340816.2021_12.dec`
UNION ALL
SELECT ride_id, rideable_type, started_at,ended_at,CAST(ride_length AS TIME) AS ride_length,day_of_week,start_lat, start_lng, end_lat, end_lng, member_casual
FROM `cyclistic-case-study-340816.2021_01.jan`
I'm using union all to combine different data tables together. In the last line, the ride_length
is a string type so I decided to use the cast function to change it to a time function.
I received an error:
Invalid time string "24:59:55"
SELECT ride_id, rideable_type, started_at,ended_at,ride_length,day_of_week,start_lat, start_lng, end_lat, end_lng, member_casual
FROM `cyclistic-case-study-340816.2021_11.nov`
UNION ALL
SELECT ride_id, rideable_type, started_at,ended_at,ride_length,day_of_week,start_lat, start_lng, end_lat, end_lng, member_casual
FROM `cyclistic-case-study-340816.2021_12.dec`
UNION ALL
SELECT ride_id, rideable_type, started_at,ended_at,CAST(ride_length AS TIME) AS ride_length,day_of_week,start_lat, start_lng, end_lat, end_lng, member_casual
FROM `cyclistic-case-study-340816.2021_01.jan`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论