NoLimitLondon
NoLimitLondon

Reputation: 91

SQL Removing Milliseconds from a SQL query

My Query is:

SELECT Symbol, SEC_TO_TIME(AVG(TIME_TO_SEC(High_Time))) as AvgTime FROM data GROUP BY Symbol;

Output:

Symbol    AvgTime   
 AAPL  03:34:00.0000
 TSLA  10:50:00.0000
 SHOP  03:40:00.0000

How would you change the query so the output looks like this?

Symbol  AvgTime 
 AAPL  03:34:00
 TSLA  10:50:00
 SHOP  03:40:00

Upvotes: 0

Views: 125

Answers (1)

Kate
Kate

Reputation: 1836

You could simply apply the ROUND function on the value being converted to a time string eg:

SEC_TO_TIME(ROUND(AVG(TIME_TO_SEC(High_Time)))) as AvgTime

Upvotes: 1

Related Questions