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
  • 相关阅读:
    React之React.cloneElement
    HTB-靶机-Vault
    HTB-靶机-Curling
    HTB-靶机-Zipper
    HTB-靶机-Frolic
    HTB-靶机-Carrier
    HTB-靶机-Oz
    HTB-靶机-Dab
    HTB-靶机-Waldo
    HTB-靶机-Reddish
  • 原文地址:https://www.cnblogs.com/whl4835349/p/5887498.html
Copyright © 2011-2022 走看看