group by date_format for each day

233
October 27, 2018, at 1:30 PM

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

Answer 1

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');
Rent Charter Buses Company
READ ALSO
mysql query - how to merge tables in another table

mysql query - how to merge tables in another table

I have a problem joining tables in the result columni have a working query which combine different tables using UNION but when i'm extending another table i got an error saying 'The used SELECT statements have a different number of columns'

135
Does InnoDB lock the whole table for a delete which uses part of a composed key?

Does InnoDB lock the whole table for a delete which uses part of a composed key?

I have a MySQL table (call it 'my_table') with a composed primary key with 4 columns (call them 'a', 'b', 'c' and 'd')

122
media_handle_upload function produces blank page

media_handle_upload function produces blank page

So currently I am using a customized form that allows logged-in users to upload imagesI am using the Wordpress media_handle_upload function to handle this task

168