亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        跪求sql server2012行轉(zhuǎn)列方案

        字號(hào):


            下面為表創(chuàng)建代碼:
            create table [dbo].[productauditrecord]([parid] [nchar](12)
            not null,[moid] [nchar](12)
            not null,[lotsn] [nvarchar](50)
            not null,[cosmeticinspection] [nchar](12)
            not null,[functionaltest] [nchar](12)
            not null,[unumber] [nchar](50)
            null,[leadwire] [nchar](50)
            null,[resourceid] [nchar](12)
            not null,[userid] [nchar](12)
            not null,[remark] [nvarchar](100)
            null,[creatdate] [datetime] not null,[productid] [nchar](12)
            not null,[nextid] [int] not null, constraint [pk_productauditrecord] primary key clustered
            ([parid] asc)with
            (pad_index = off, statistics_norecompute = off,
            ignore_dup_key = off, allow_row_locks = on,
            allow_page_locks = on) on [primary])
            on [primary]goalter table [dbo].[productauditrecord] add
            constraint [df_productauditrecord_parid] default
            (substring(convert([char](36),
            newid(),(0)),(1),(12)))
            for [parid]goalter table [dbo].
            [productauditrecord] add constraint
            [df_productauditrecord_nextid] default
            ((0))
            for [nextid]go
            下面為自己測(cè)試數(shù)據(jù)得到的結(jié)果:上面為原始數(shù)據(jù),下面為轉(zhuǎn)換后的數(shù)據(jù):轉(zhuǎn)換代碼
            測(cè)試表代碼:create table [dbo].[test](
            [月份] [varchar](4) null,
            [工資] [int] null,
            [福利] [int] null,
            [獎(jiǎng)金] [int] null
            ) on [primary]
            1:月份 工資 福利 獎(jiǎng)金
            1月 100 200 300
            2月 110 210 310
            3月 120 220 320
            4月 130 230 330
            2:考核月份 1月 2月 3月 4月
            福利 200 210 220 230
            工資 100 110 120 130
            獎(jiǎng)金 300 310 320 330
            select * from
            (
            select 考核月份,月份,金額 from
            (select 月份, 工資, 福利, 獎(jiǎng)金 from test) p
            unpivot
            (金額 for 考核月份 in (工資, 福利, 獎(jiǎng)金))as unpvt
            ) t
            pivot
            (max(金額) for 月份 in ([1月],[2月],[3月],[4月]))as pt