Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLITE group by

I use the sql below in sqlite to group by time intervals. The first is group by day and the second group by hour:

select strftime('%Y-%m-%dT%00:00:00.000', date_time),line, count() from entry group by strftime('%Y-%m-%dT%00:00:00.000', date_time)

select strftime('%Y-%m-%dT%H:00:00.000', date_time),line, count() from entry group by strftime('%Y-%m-%dT%H:00:00.000', date_time)

How do I group by 10 minutes interval

like image 544
yaza Avatar asked Nov 30 '09 22:11

yaza


People also ask

What is GROUP BY in SQLite?

The SQLite GROUP BY clause is used in a SELECT statement to collect data across multiple records and group the results by one or more columns.

How does GROUP BY work in SQLite?

The GROUP BY clause a selected group of rows into summary rows by values of one or more columns. The GROUP BY clause returns one row for each group. For each group, you can apply an aggregate function such as MIN , MAX , SUM , COUNT , or AVG to provide more information about each group.

How do I group data in SQLite?

SQLite GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups. GROUP BY clause follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.

What is the use of GROUP BY?

The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country". The GROUP BY statement is often used with aggregate functions ( COUNT() , MAX() , MIN() , SUM() , AVG() ) to group the result-set by one or more columns.


1 Answers

 select ... from entry
 group by strftime('%Y%m%d%H0', date_time) + strftime('%M', date_time)/10;
like image 117
Alex B Avatar answered Sep 21 '22 05:09

Alex B