我正在使用3列表,试图获取过去30天每天的唯一条目计数。
|RecordNumber|extension|date|
我以为我在这方面取得了进步
SELECT DATE_FORMAT(date, '%m/%d/%Y') AS Dates, extension
FROM API_phones
WHERE date LIKE '%' AND date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
ORDER BY Dates ASC
但是我不确定如何完成它。
过去30天内每天有多少个条目。
答案 0 :(得分:0)
如果您需要每天输入的条目数,则应使用count(*)并按
分组2018-07-09 08:00:00
答案 1 :(得分:0)
08
答案 2 :(得分:0)
如果您只需要每天计数,请使用以下内容:
SELECT DATE_FORMAT(date, '%m/%d/%Y') AS Dates, count(*) as count
FROM API_phones
WHERE date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
Group by
Dates
ORDER BY Dates ASC
如果每个扩展程序每天需要它,可以尝试以下操作:
SELECT DATE_FORMAT(date, '%m/%d/%Y') AS Dates, extension, count(*) as count
FROM API_phones
WHERE date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
Group by
Dates, extension
ORDER BY Dates ASC