select cast(chirp.timestamps as date),count(chirp.cid)
from chirp
where chirp.timestamps > (select  now() - interval 1 month)
group by cast(chirp.timestamps as date) 
order by chirp.timestamps desc'1 month' 去掉单引号,group by 和order by 互换位置就可以了

解决方案 »

  1.   

    问题貌似不是出在这里,引号没错误,按照你说的,select cast(chirp.timestamps as date),count(chirp.cid)
    from chirp
    where chirp.timestamps > (select  now() - interval '1 month')
    group by cast(chirp.timestamps as date) 
    order by chirp.timestamps desc错误:  字段 "chirp.timestamps" 必须出现在 GROUP BY 子句中或者在聚合函数中使用
    LINE 5: order by chirp.timestamps desc
                     ^
      

  2.   

    select cast(chirp.timestamps as date), count(cid) from chirp where timestamps > (select now() - interval '1 month') group by cast(chirp.timestamps as date) order by cast(chirp.timestamps as date) desc;
      

  3.   

    select cast(chirp.timestamps as date),count(chirp.cid)
    from chirp
    where chirp.timestamps > (select  now() - interval '1 month')
    group by cast(chirp.timestamps as date)
    order by 1 desc