本帖最后由 WoCao_CSD_N 于 2012-01-18 13:02:26 编辑

解决方案 »

  1.   

    select 'NOU' as NAME,
    sum(case when day(TIME)=1 then NOU else 0 end) as [1],
    sum(case when day(TIME)=2 then NOU else 0 end) as [2],
    ......
    sum(case when day(TIME)=31 then NOU else 0 end) as [31]
    from STU
    union all
    select 'NOY' as NAME,
    sum(case when day(TIME)=1 then NOY else 0 end) as [1],
    sum(case when day(TIME)=2 then NOY else 0 end) as [2],
    ......
    sum(case when day(TIME)=31 then NOY else 0 end) as [31]
    from STU