mysql - How to count and group items by day of the week? -


i have following (mysql) table called "tweets":

tweet_id   created_at --------------------- 1          1298027046 2          1298027100 5          1298477008 

i want mysql returning number of tweets per day of week; taking above data should return:

wednesday 1 friday    2 

i have following query (which should return day of week index, not full name):

select    count(`tweet_id`),   weekday(from_unixtime(`created_at`)) tweets2  order weekday(from_unixtime(`created_at`)) 

this returns:

count(`tweet_id`)   weekday(from_unixtime(`created_at`)) 7377                4 

(there total of 7377 tweets in database). doing wrong?

select  count(`tweet_id`), dayname(from_unixtime(created_at)) day_name1 tweets2   group day_name1 order day_name1; 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -