0
在我的SQL表我有一些數據如下,SQL Server查詢得到的值按字母順序排列
ItamName
-----
Småsenter (Sandvika Småsenter)
Brilleland
Game
Name It
我寫了下面的查詢,
SELECT
(Select I.ItamName from ItemMaster I where I.ItemId=A.ItemName and I.LanguageId='no'
and I.SiteId='sandvikas') as elementname,
sum(clicks) as click from Analytics A
where ItemType='Shop' and DateOfEvent >='2013-10-01' and DateOfEvent<='2013-10-31'
and SiteName='sandvikas'
group by ItemName order by click desc, ItemName Asc FOR XML RAW('Table'),ROOT('NewDataSet')
這給了我輸出
<NewDataSet>
<Table elementname="Brilleland" click="2" />
<Table elementname="Name It" click="2" />
<Table elementname="Småsenter (Sandvika Småsenter)" click="1" />
<Table elementname="Game" click="1" />
</NewDataSet>
數據中還有一些特殊字符。我希望我的xml數據按字母順序排列如下,
<NewDataSet>
<Table elementname="Brilleland" click="2" />
<Table elementname="Game" click="1" />
<Table elementname="Name It" click="2" />
<Table elementname="Småsenter (Sandvika Småsenter)" click="1" />
</NewDataSet>
問候 桑傑塔