sqlite - SQL query to obtain a count of how many items have each possible value for a given column -


Ok, so I have a logical (SQLite) table, in which a column (time) is a unix simultaneous timestamp (second).

columns are irrelevant to my purposes). These timestamp log entries are.

How many items I am logging per hour (all the time - I do not care to do this for only a given day or anything). I am trying to get an idea of ​​activity density across the average ). I have been successful in writing SELECT STRFTIME ('% H', DATETIME (time, 'unixepoch', 'localtime')) in the query by logging in ; , which then gives me a huge list of number 0-23 which I can run through the uniq -c to get the count of events per hour.

However (beyond any practical requirement, I accept), I want to count this step in SQL. My brain knew me as long as I wanted to know that to bring some kind of self-involvement, unique values ​​are received only for the hour-generated columns, but where does it come from? D: Any thoughts?

  SELECT STRFTIME ('% H', DATETIME (time, 'Unixpoke', 'local Time ')), COUNT (second field) STRFTIME from log group ('% H ', DATETIME (time,' UNIXPOK ',' local time ')); Note: I have not worked with SQLite, however, it supports  GROUP BY  and therefore, it should work. 


Comments