我正在尝试根据以下查询获取记录: -
select distinct type, count(type), created_at from study_aids where date(created_at) = '2015-09-02'
GROUP BY type
我按照以下方式得到结果
type count(type) created_at
FlashCardDeck 752 2015-09-02T15:29:34.000Z
MindMap 6692 2015-09-02T13:52:38.000Z
我需要手动去替换日期,而我需要查询按照以下方式自动显示结果: -
type count(type) created_at
FlashCardDeck 752 2015-09-02T15:29:34.000Z
MindMap 6692 2015-09-02T13:52:38.000Z
XYZ 1234 ****2015-09-03T13:52:38.000**Z**
PS - 我不需要总和,我需要特定日期的每种记录的计数。
由于
答案 0 :(得分:2)
猜测这一定是mysql。包含created_at日期的查询将是这样的。
select type
, count(type)
, date(created_at)
from study_aids
where created_at >= '2015-09-02'
AND created_at < '2015-09-03'
GROUP BY type
, date(created_at)