0

i have a table which has fields like this:

id | created | action_type | value

Created is a timestamp in a varchar field. What i need to do is to calculate the average actions per day in one query. All need to be grouped by one day.

so i need something like this

2017-10-01 : 15 
2017-10-02 : 20

How can i achieve this? :)

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786

1 Answers1

1

Presumably, you just want a group by:

select date(created), count(*)
from t
group by date(created);
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • this gives me a null in the date(created) column? –  Oct 01 '17 at 19:24
  • i have found the solution my self. You have to convert the Timestamp with FROM_UNIXTIME and then pass it to the date function. Then it works :) –  Oct 01 '17 at 20:29