SQLserver 一行拆多行答:select 1,'A', 2 union all select 2,'B',3 union all select 3,'C',1 ),t2(id,name,dqty) as (select id,name,1 from t1 union all select t2.id,t2.name,t2.dqty+1 from t1 join t2 on t1.id=t2.id and t1.name=t2.name where t2.dqty<t1.dqty )select id,nam...
sql一行拆分多行记录答:1 ab,ac,ad 1 cc,cf 2 bb,bc,be SQL> select * from (select id,regexp_substr(achar,'[^,]+',1,level) achar from t00 connect by level<=length(achar)-length(regexp_replace(achar,',',''))+1) group by id,achar order by id ;ID ACHAR --- --- 1 ab 1 ac 1...
SQL sever 按条件拆分每行数据怎么实现答:Price DECIMAL(10,2),StartDate DATE,EndDate DATE,Index INT,TotalDayDiff INT,CurrentMonthStart DATE,CurrentMonthEnd DATE DECLARE @Test TABLE (ID INT IDENTITY(1,1),Room INT,Category NCHAR(50),Price DECIMAL(10,2),StartDate DATE,EndDate DATE )INSERT...