zoukankan      html  css  js  c++  java
  • 行转列

    select * from  (  select   case  

                                      when    A  then  a

                                      when    B  then  b

                                      when    C   then c

                            end    字段

                          from  表名

     )tb  pivot(max (字段) for  字段 in(a,b,c))a  order by 字段1 desc

    select * from (select Year,Time,ID1,Name,
    case
    when substring(ID,5,2) = '14' then 'A'
    when substring(ID,5,2) = '15' then 'A'
    when substring(ID,5,2) = '04' then 'B'
    when substring(ID,5,2) = '25' then 'C'
    when substring(ID,5,2) = '26' then 'D'
    end ID
    from census_Detail
    where Year=@strYear AND Time=@Times

    )tb pivot( max(ID) FOR ID IN (A,B,C,D))a order by ID1 desc

    ABCD可以根据需要在前台绑定只是一个栏位名

    111111
  • 相关阅读:
    20210603
    20210602
    20210601
    20210531-已编辑
    2021053101
    操作系统笔记(一)
    尘埃落定,扬帆起航
    RTL级低功耗设计
    关于毛刺
    电路级拾珍
  • 原文地址:https://www.cnblogs.com/whl4835349/p/5887498.html
Copyright © 2011-2022 走看看