zoukankan      html  css  js  c++  java
  • SQL Server中的行转列

    with tt as(select s.MorOrAftOrEve, case s.MorOrAftOrEve when 1 then '上午' when 2 then '下午' else '晚上' end as MAE ,'第'+cast(s.Section as varchar(10))+'节' as JC,
    (CASE s.WeekDay when '星期一' then s.ProjectID else 0 end) as week1,
    (CASE s.WeekDay when '星期二' then s.ProjectID else 0 end) as week2,
    (CASE s.WeekDay when '星期三' then s.ProjectID else 0 end) as week3,
    (CASE s.WeekDay when '星期四' then s.ProjectID else 0 end) as week4,
    (CASE s.WeekDay when '星期五' then s.ProjectID else 0 end) as week5,
    (CASE s.WeekDay when '星期六' then s.ProjectID else 0 end) as week6,
    (CASE s.WeekDay when '星期日' then s.ProjectID else 0 end) as week7
    from dbo.EDU_ScheduleManager s where s.ClassID=#ClassID# and s.SchoolID=#SchoolID#)
    select mae,jc,
    (select CourseName from dbo.EDU_Course where id=sum(week1)) as w1,
    (select CourseName from dbo.EDU_Course where id=SUM(week2)) as w2,
    (select CourseName from dbo.EDU_Course where id=SUM(week3)) as w3,
    (select CourseName from dbo.EDU_Course where id=SUM(week4)) as w4,
    (select CourseName from dbo.EDU_Course where id=SUM(week5)) as w5,
    (select CourseName from dbo.EDU_Course where id=SUM(week6)) as w6,
    (select CourseName from dbo.EDU_Course where id=SUM(week7)) as w7 from tt
    group by mae,jc,MorOrAftOrEve order by MorOrAftOrEve asc

    更多技术交流+QQ:318617848
  • 相关阅读:
    搭建angularjs API文档站点
    Web网站数据”实时”更新设计
    3kb jQuery代码搞定各种树形选择。
    阿里妈妈自动登录程序
    Android中RelativeLayout属性详细说明
    jQuery选择器总结
    ajax页面加载进度条插件
    jquery ajax 方法及各参数详解
    使用jQuery加载html页面到指定的div
    C#中无边框窗体移动
  • 原文地址:https://www.cnblogs.com/huyaguang/p/5763722.html
Copyright © 2011-2022 走看看