select *
from table1
group by year(date1)select *
from table1
group by month(date1)

解决方案 »

  1.   

    如果我要统计其中的I_SUM字段:
    select i_sum
    from table1
    group by year(date1)
    就可以了吗?
      

  2.   

    select convert(char(4), date_col, 112), sum(...) from tab1 where convert(char(4), date_col, 112) = @year group by convert(char(4), date_col, 112)
    select convert(char(6), date_col, 112), sum(...) from tab1 where convert(char(6), date_col, 112) = @year group by convert(char(6), date_col, 112)
    select convert(char(8), date_col, 112), sum(...) from tab1 where convert(char(8), date_col, 112) = @year group by convert(char(8), date_col, 112)
      

  3.   

    不行啊,SELECT 后的字段名必须用SUM吗?
      

  4.   

    用group by 就必须用统计函数,如:sum(), count(), max(), min()等。