create table author(
創(chuàng)新互聯(lián)公司主營辰溪網站建設的網絡公司,主營網站建設方案,成都app軟件開發(fā)公司,辰溪h5成都微信小程序搭建,辰溪網站營銷推廣歡迎辰溪等地區(qū)企業(yè)咨詢
id int identity,
author nvarchar(20)
)
insert into author values('張三')
insert into author values('張三,李四')
insert into author values('王五')
insert into author values('李四')
insert into author values('張三,李四,王五')
select * from author
select OneTitle,COUNT(OneTitle) as count
from
(
select id,
Author=convert(xml, 'rootv' + replace(Author,',','/vv') + '/v/root')
from Author
)a
outer apply
(
select OneTitle = C.v.value('.', 'nvarchar(100)')
from a.Author.nodes('/root/v')C(v)
) b
group by OneTitle order by count desc
因為主數(shù)據(jù)庫文件和次數(shù)據(jù)庫文件是同類型的文件,而日志文件是另一類型的文件,就像定義變量一樣,可以一次性定義很多相同類型的變量,變量名之間要用逗號隔開,而對于不同類型的變量則不能一次性聲明。原則很簡單,相同類型就用逗號隔開,以減少工作量
假設2016-01-01這話日期在單元格A1輸入公式B1=VALUE(TEXT(YEAR(A1)MONTH(A1)DAY(A1),0))問題搞定純手打,望采納
行內容以path或者層次元素列表的形式顯示出來。
取得一個表的所有字段名,用逗號分割。
select max(substr(SYS_CONNECT_BY_PATH(COLUMN_NAME, ','),2)) col from (
select COLUMN_NAME,column_id from user_tab_columns where table_name='表名')
start with column_id=1
connect by column_id=rownum;
從這點上講Oracle比SQLSERVER取字段要麻煩多了
在SQLSERVER里可以直接在SQL的查詢分析器中直接選中表右擊選select就可以自動生成表的所有字段名用逗號分割
意思要將帶有逗號的數(shù)據(jù)把逗號替換掉之后 重新保存到數(shù)據(jù)庫么!!!
創(chuàng)建表
create?table?t1
(str?varchar(100))
insert?into?t1?values?('61,62')
create?table?t2
(id?int,
部門?varchar(10))
insert?into?t2?values?(59,'采購部')
insert?into?t2?values?(56,'生產部')
insert?into?t2?values?(60,'業(yè)務')
insert?into?t2?values?(61,'系統(tǒng)')
insert?into?t2?values?(62,'測試')
執(zhí)行:
with?t?as
(select?s2.部門?from?
(select
SUBSTRING([str],number,CHARINDEX(',',[str]+',',number)-number)?as?[str]?
from
t1?a,master..spt_values
where
number?=1?and?number=len([str])??
and?type='p'?
and?substring(','+[str],number,1)=',')?s1,
t2?s2?where?s1.[str]=s2.id)
SELECT?STUFF((SELECT?','+[部門]?FROM?t?for?xml?path('')),1,1,'')
結果:
以上sqlserver2008R2下執(zhí)行
文章名稱:sqlserver逗號文,sql語句逗號
網站路徑:http://chinadenli.net/article20/hohpco.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供App設計、面包屑導航、網站營銷、網站制作、商城網站、營銷型網站建設
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)