cast()和convert()的用法
cast()和convert()是用来做类型转换的
语法结构
cast(values as type)
convert(values,type)
select cast(sum(distance) as signed) as distance, cast(sum(duration) as signed) as duration, cast(sum(calorie) as signed) as calorie from rowing_machine_record where hu_id = 1
支持的转换类型如下:
二进制,同带binary前缀的效果 : BINARY
字符型,可带参数 : CHAR()
日期 : DATE
时间: TIME
日期时间型 : DATETIME
浮点数 : DECIMAL
整数 : SIGNED
无符号整数 : UNSIGNED