Home > other >  Average by day SQL
Average by day SQL

Time:06-06

I need to have a table with the average by hour or by day of a table. The problem is the average is made by hour/min/sec

Here's the query: enter image description here

CodePudding user response:

For SQL you need to CONVERT the date

SELECT CONVERT(VARCHAR(10), DATE_PEREMPTION, 112) AS TIME_PERIOD, AVG(MESURE) AS MESURE
...
GROUP BY TIME_PERIOD
ORDER BY TIME_PERIOD

This might be a useful reference : https://www.sqlservertutorial.net/sql-server-system-functions/convert-datetime-to-string/

CodePudding user response:

i solved using this code. enter image description here

  • Related