select convert(char(6),日期,112),sum(数量)
from 表
group by convert(char(6),日期,112)

解决方案 »

  1.   

    SELECT year(日期)+'-'+month(日期),sum(數量) from 表
    group by year(日期)+'-'+month(日期)
      

  2.   

    select convert(varchar(6),convert(datetime,日期),120)as 日期,sum(数量) from table1
     group by convert(varchar(6),convert(datetime,日期),120)
      

  3.   

    SELECT convert(char(4),year(進廠日期))+'-'+convert(char(4),month(進廠日期)) from tblresume
    group by  convert(char(4),year(進廠日期))+'-'+convert(char(4),month(進廠日期))
      

  4.   

    SELECT convert(char(4),year(日期))+'-'+convert(char(4),month(日期))﹐sum(數量) from 表
    group by  convert(char(4),year(日期))+'-'+convert(char(4),month(日期))