sql语句收藏
收集自網(wǎng)絡(luò),方便自己,方便他人
1 if object_id('[aaa]') is not null drop table [aaa] 2 go 3 create table [aaa]([地區(qū)] varchar(4),[內(nèi)容] varchar(45)) 4 insert [aaa] 5 select '中國(guó)','021sp.html|管材|4355;028sp.html|建筑材料|3209' union all 6 select '中國(guó)','023sp.html|材|4356;025sp.html|建|9209' 7 go 8 9 select a.地區(qū), 10 內(nèi)容=substring(a.內(nèi)容,b.number,charindex(';',a.內(nèi)容+';',b.number)-b.number) 11 from [aaa] a 12 join master..spt_values b on b.type='P' 13 where charindex(';',';'+a.內(nèi)容,b.number)=b.number 14 15 /** 16 地區(qū) 內(nèi)容 17 ---- --------------------------------------------- 18 中國(guó) 021sp.html|管材|4355 19 中國(guó) 028sp.html|建筑材料|3209 20 中國(guó) 023sp.html|材|4356 21 中國(guó) 025sp.html|建|9209 22 23 (4 行受影響) 24 **/ 按分隔符拆分記錄 1 select id, len(nr) - len(replace(nr,'a' , '')) from temp 字段中字符串出現(xiàn)次數(shù)?
轉(zhuǎn)載于:https://www.cnblogs.com/knightyj/p/5888824.html
總結(jié)
- 上一篇: C#全屏随机位置显示图片的小程序
- 下一篇: spark on yarn :state