简体   繁体   中英

group by date_format for each day

My I'm having problems with a query. Here is what I have

SELECT COUNT(id) as Counted
    FROM referral_code_logs
        GROUP BY DATE_FORMAT(time_stamp, '%c/%e/%y');

I am trying to see the amount of referrals each day has. The part I'm having problems with is the date_format.

Table layout

表格布局

Here are how the time_stamps are entered in the Table: (month/day/year) month is 1-12 day is 0-31 year is YY

Time_stamps

时间戳

You just need to add in the date to the select part:

SELECT DATE_FORMAT(STR_TO_DATE(time_stamp, '%c/%e/%y'), '%c/%e/%y') as DT
       ,COUNT(id) as Counted
    FROM referral_code_logs
        GROUP BY DATE_FORMAT(time_stamp, '%c/%e/%y');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM