zoukankan      html  css  js  c++  java
  • sqlServer数据库纵横表相互转化

    sqlServer  数据库纵横表相互转化

    一.纵表转横表:

    1.纵表:

    2.横表:

    3. 代码:

    select Name as '姓名',
    sum(case Course when '语文' then Score else 0 end) as '语文',
    sum(case Course when '数学' then Score else 0 end) as '数学',
    sum(case Course when '英语' then Score else 0 end) as '英语'
     from Score group by Name

    二.横表转纵表:

    1.横表:

    2.竖表:

    3.代码:

    select * from(
    select Name as '姓名','语文' as '语文',Chinise as '分数' from Score1 union all
    select Name as '姓名','数学' as '数学',Math as '分数' from Score1 union all
    select Name as '姓名','英语' as '英语',English as '分数' from Score1)as s order by s.姓名
  • 相关阅读:
    Flask——session
    UISB ScrollView
    UISB 登陆
    UISB TextField
    UISB 进步器 分栏控制器
    UISB UISlider ProgressView
    UISB Switch
    UISB 定时器
    Django-Celery文档
    UISB UIViewController
  • 原文地址:https://www.cnblogs.com/zlp520/p/3602198.html
Copyright © 2011-2022 走看看