目標:根據字段'DOCURL'和'ELEMENT'獲取不同的值。使用行號時選擇不同的行
注:(editted)以下爲不應該在SQL
問題在.aspx頁面上使用的:如果我作爲一個獨立的查詢,我得到14行,這是正確運行;
Select DISTINCT DOCURL, ELEMENT From TblReference Where Property= 'XYZ'
我的代碼拉起來34,我已經將Row_Number更改爲DENSE_RANK,但仍然不能下降到14;
Select * from(Select DISTINCT DOCURL, ELEMENT,
DENSE_RANK() over (order by id desc) As rn From TblReference
Where Property= 'XYZ') as t Where rn = 1
***該rn在一個可變循環中正常計數到10。
參考:sql query distinct with Row_Number -
SELECT distinct id, DENSE_RANK() OVER (ORDER BY id) AS RowNum
FROM table
WHERE fid = 64
MySQL不支持窗口功能! – sagi
代碼工作現場欄上刪除不同,在.NET代碼中,它通常是它開始...對於i = 1到10 sSQL =「Select * from(Select id,DOCURL,VFMDISCIPLINEELEMENT,row_number()over (order by id desc)As String From TblData Where UPRN ='「&Session.Item(」pUPRN「)。ToString&」')as t其中rn =「&i&」「 dsNames.SelectCommand = sSQL – indofraiser