1

This is the data I'm working with in my SQL database:

Symbol |  High_Time
  AAPL   10:01:00.000        
  TSLA   09:45:00.000                
  AAPl   10:05:00.000
  AAPL   01:15:00.000        
  SPY    09:30:00.000                
  TSLA   09:48:00.000      
  SPY    09:30:00.000                
  AAPL   11:01:00.000          

SQL Query, I'm using to get the average of the HOD_time column:

SELECT Symbol, AVG(High_Time) FROM data GROUP BY Symbol;

Output (Example):

Symbol | (AVG)High_Time
  AAPL   33400.00000000        
  TSLA   107000.00000000                      
  SPY    120000.00000000                               

It's showing a number instead of in a time format. How would you go about getting the query to show it in a time format?

Desired Output (Example):

Symbol | (AVG)High_Time
  AAPL   8:05        
  TSLA   9:46                     
  SPY    9:30             

1 Answers1

1

What you are looking for is

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

justhere
  • 116
  • 8