把多行轉成一行 用空格分開

2022-03-08 14:23:01 字數 675 閱讀 8158

select

t1.id as 銷售合同標識,

t1.billno as 單據號,

t1.orderno as 合同編號,

(select distinct '【' + salesorderno+'】'+' ' from salescompactorder where parentid = t1.id for xml path('')) 銷售訂單號,

t1.purchase as 購貨單位,

t1.orderpurchase as 訂單購貨單位,

t1.summoney as 合同總金額,

t1.industry as 行業,

t1.area as 區域,

t1.receipttype as 收款方式,

t1. paytime as 付款時間,

t1. maketime as 製單時間,

t1. employer as 業務員,

t1. salestime as 合同簽訂日期,

t1. sumcount as 合同總數量,

t1. passcount as 合同已勾數量,

t1. count as 合同未勾數量,

t1. salestype as 合同型別,

t1. zhaiyao as 摘要

from salescompact t1

sql 多行轉成一行

例如表a id data 1 a 1 b 1 c 2 d 2 f 轉換成表b 1 a b c 2 d e smerg是自定義函式 建立乙個函式smerg create function smerg id int returns varchar 8000 asbegin declare str var...

mysql多行合併一行,一行拆分多行

資料 建表語句 drop table if exists 品牌 create table 品牌 id int 0 not null,品牌 varchar 255 character set utf8 collate utf8 general ci null default null engine i...

pandas實現多行合併一行 一行拆分多行

import pandas as pd 構造資料 data pd.dataframe 合併資料 合併前 合併後 import pandas as pd 構造資料 data pd.dataframe 拆分資料 data pinpai data 品牌 str.split expand true data...