SQL SERVER 資料排序編號

處理資料時,很常需要排序後編號,再進行資料的呈現,
ROW_NUMBER() OVER (Partition By GroupCol  ORDER BY OrderCol) AS RowNumber
ORDER BY OrderCol就是要白續的欄位,可以多個欄位,也可以下DESC。
Partition By GroupCol則是用來做分群的欄位,也就是A組編號1234,B組編號1234…
,很好用的語法。

by mhchen15 on 5 12 月, 2015 in SQL SERVER - Tags:
Tags:

There are no comments.

Name*: Website: E-Mail*:
XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>