我创建了这个查询以查找行驶里程的AVG,但是我很难将数据格式化为3个小数点。
49.614112472330234
SELECT AVG(Mileage_Used)/SUM(time_to_sec(timediff(Lesson_Finish_Time,Lesson_Time))/3600) as Mileage_per_hour from LESSONS;
答案 0 :(得分:1)
将值转换为具有正确精度的十进制类型:
select cast(<yourvalue> as decimal(10,3))
在你的情况下:
SELECT cast(AVG(Mileage_Used)/SUM(time_to_sec(timediff(Lesson_Finish_Time,Lesson_Time))/3600) as decimal(10,3)) as Mileage_per_hour
from LESSONS