行列轉換之 多行轉多列,多列轉多行實踐版

2022-02-15 05:51:42 字數 2803 閱讀 8030

行列轉換之——多行轉多列,多列轉多行實踐版

參考:深入行列轉換----多行轉多列,多行的計算

參考:sql server動態行列轉換

要求:

實操演示:

--1.全表

select

*from

#temp2

--2.構造row_number()

select

*,row_number() over(partition by a order

by a) as'rn

'from

#temp2

--3.行轉列

SQL SERVER 多行轉多列

轉換結果如上圖 建立測試標 create table 成績表 編號 int identity 1,1 not null,姓名 varchar 50 null,語文 numeric 5,2 null,數學 numeric 5,2 null,英語 numeric 5,2 null on primary ...

hive多行轉多列

一 需求 需要將多行的資料,按照某個維度轉換為一行。轉換前 轉換後 db price area name 為 東北 的total price actual db qty area name 為 東北 的qty。二 解決方案 1 sql select brand,max case when area ...

oracle多行轉單行多列

需求 從a轉成b 需要用到以下函式 wm concat 多行轉成一列 case when then else end regexp substr sql如下 select material code,store id,case when regexp substr wm concat shippin...