Search
 
SCRIPT & CODE EXAMPLE
 

SQL

group by 15 minute interval sql server

SELECT   DATEADD(MINUTE, DATEDIFF(MINUTE, '2000', aa.[date]) / 10 * 10, '2000')
                                                             AS [date_truncated],
         COUNT(*) AS [records_in_interval],
         AVG(aa.[value]) AS [average_value]
FROM     [friib].[dbo].[archive_analog] AS aa
-- WHERE aa.[date] > '1900-01-01'
GROUP BY DATEADD(MINUTE, DATEDIFF(MINUTE, '2000', aa.[date]) / 10 * 10, '2000')
ORDER BY [date_truncated]
Comment

PREVIOUS NEXT
Code Example
Sql :: user privileges postgresql information_schema 
Sql :: mysql show tables in database 
Sql :: how to get the ddl for datafile in oracle tablespace 
Sql :: create table mysql example auto_increment 
Sql :: insert random numbers in columns postgress 
Sql :: last 6 months postgresql 
Sql :: remove spaces sql server 
Sql :: update select 
Sql :: oracle current date plus 1 month 
Sql :: oracle stop 
Sql :: drop table 
Sql :: select statement to print longest name 
Sql :: sql server drop table if exists 
Sql :: view linked servers sql 
Sql :: go install mysql 
Sql :: mysql select last row for each group 
Sql :: host is not allowed to connect to this mysql server 
Sql :: create mysql user on all hosts 
Sql :: oracle user privileges 
Sql :: reset identity column values in sql server 
Sql :: combine two columns using sql query 
Sql :: sql server format datetime 
Sql :: real world example of nosql 
Sql :: join to find results not in another table 
Sql :: mysql check auto increment value 
Sql :: start postgres server 
Sql :: grant read only privileges postgres user 
Sql :: media sql 
Sql :: postgresql alter table sequence 
Sql :: mysql order 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =