SQL 从 SQL 查询中删除毫秒
SQL Removing Milliseconds from a SQL query
我的查询是:
SELECT Symbol, SEC_TO_TIME(AVG(TIME_TO_SEC(High_Time))) as AvgTime FROM data GROUP BY Symbol;
输出:
Symbol AvgTime
AAPL 03:34:00.0000
TSLA 10:50:00.0000
SHOP 03:40:00.0000
您将如何更改查询以使输出看起来像这样?
Symbol AvgTime
AAPL 03:34:00
TSLA 10:50:00
SHOP 03:40:00
您可以简单地将 ROUND 函数应用于要转换为时间字符串的值,例如:
SEC_TO_TIME(ROUND(AVG(TIME_TO_SEC(High_Time)))) as AvgTime
我的查询是:
SELECT Symbol, SEC_TO_TIME(AVG(TIME_TO_SEC(High_Time))) as AvgTime FROM data GROUP BY Symbol;
输出:
Symbol AvgTime
AAPL 03:34:00.0000
TSLA 10:50:00.0000
SHOP 03:40:00.0000
您将如何更改查询以使输出看起来像这样?
Symbol AvgTime
AAPL 03:34:00
TSLA 10:50:00
SHOP 03:40:00
您可以简单地将 ROUND 函数应用于要转换为时间字符串的值,例如:
SEC_TO_TIME(ROUND(AVG(TIME_TO_SEC(High_Time)))) as AvgTime