I’m trying to write a report using the following query:
SELECT
DATE_FORMAT(date, '%Y-%m-%d') AS 'Date',
CONCAT(UCASE(MID(name,1,1)),MID(name,2)) AS 'Username',
COUNT(admin_id) AS 'Surveys Carried Out'
FROM
`customer_surveys`
LEFT JOIN `admin` ON customer_surveys.admin_id = admin.adminid
GROUP BY DATE_FORMAT(date, '%Y-%m-%d')
It needs to group by the date (as it’s a day by day report) and the admin_id (as it’s a count of how many surveys have been carried out by that ID)
This in theory, should work. But look at what it returns, and comparing it to the actual data, it’s displaying it day by day but merging the admin_ids so the first occuring one on that day is the one that displays. Any help?
if you want to display records of dates for every admin, you should have to group it by date and by admin_id atleast