本帖最后由 rs100 于 2012-08-03 09:07:38 编辑

解决方案 »

  1.   

    SELECT count(1) FROM `articles` WHERE `pubtime` > 6月1号0点时间戳 and `postdate` < 7月1号0点时间戳
      

  2.   


    ...复制错了个单词SELECT count(1) FROM `articles` WHERE `pubtime` > 6月1号0点时间戳 and `pubtime` < 7月1号0点时间戳查文章 就select * 
      

  3.   

    >select count(1), date(pubtime) from articles group by date(pubtime);
      

  4.   

    先把几个点的时间戳取出来.如2012年8月、2012年6月。
    然后在拼接sql查询,应该很容易的。  
    别着急,你试试
      

  5.   

    1、
    select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')
      

  6.   

    这是每个月:
    >select count(1), extract(year_month from pubtime) from articles  group by extract(year_month from pubtime);
      

  7.   

    有个问题,在sql中使用函数会影响sql的执行效率,被用字段的主键什么的,有时候也没效果
      

  8.   

    你写个函数就行了,把开始时间和结束时间作为参数就OK,jquery有很多时间插件的,你想得到6.01-7.15的信息都行
    你想一次性得到6月和8月的文章,你就要多写个函数,6,8作为数组array(6,8)传进去,这样你就可以查几个月的文章,然后生成时间戳查询就OK了,我sql不咋个样,不清楚sql可以直接查处不...
      

  9.   

    select count(1), extract(year_month from pubtime) from articles  group by extract(year_month from pubtime);我这个不行吗?
      

  10.   

    1.select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')2.select count(1), extract(year_month from pubtime) from articles  group by extract(year_month from pubtime);这两句sql得到的结构不一样?领教了
      

  11.   


    SELECT
    SUM(CASE when MONTH( FROM_UNIXTIME(pubtime, '%Y-%m-%d'))=6 THEN 1 ELSE 0 END)AS sum_6,
    SUM(CASE when MONTH( FROM_UNIXTIME(pubtime, '%Y-%m-%d'))=8 THEN 1 ELSE 0 END)AS sum_8
    FROM dc_admin
    数字表示是 哪个月份的