比如: DECLARE @t AS TABLE([Datas] NVARCHAR(40)) INSERT INTO @t ([Datas]) VALUES(N'DF'),(N'W4F'),(N'EYY'),(N'ER'),(N'GFF'),(N'A445') SELECT [Datas] FROM ...
比如:
DECLARE @t AS TABLE([Datas] NVARCHAR(40)) INSERT INTO @t ([Datas]) VALUES(N'DF'),(N'W4F'),(N'EYY'),(N'ER'),(N'GFF'),(N'A445') SELECT [Datas] FROM @t ORDER BY [Datas]Source Code
由於我們不清楚Datas數據內容,它是動態的內容。但是我們需要獲取這表中的某一筆記錄,那如何獲取呢?
可以使用ROW_NUMBER方法來求得:
SELECT [Datas] FROM ( SELECT ROW_NUMBER() OVER (ORDER BY [Datas]) AS [RowNumber], [Datas] FROM @t) AS t WHERE [RowNumber] IN (2,5)Source Code