Convert SQL query to display output in time format
P粉704066087
P粉704066087 2024-04-04 21:02:02
0
1
434

This is the data I'm using in a 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 that I used 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 displays numbers instead of time format. How would you make the query display in time format?

Desired output (example):

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

P粉704066087
P粉704066087

reply all(1)
P粉321584263

What you are looking for is

SELECT Symbol, SEC_TO_TIME(AVG(TIME_TO_SEC(High_Time))) FROM data GROUP BY Symbol;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template