1
我正在使用SQL服务器2005年。如何在sql中创建索引列?
我有许多列的表,行我选择有where子句,使不可能使用身份作为索引。我想要选择所有这些行+索引器行(像身份一样)。
例如
2 jack
4 thomas
8 james
到
1 2 jack
2 4 thomas
3 8 james
感谢
我正在使用SQL服务器2005年。如何在sql中创建索引列?
我有许多列的表,行我选择有where子句,使不可能使用身份作为索引。我想要选择所有这些行+索引器行(像身份一样)。
例如
2 jack
4 thomas
8 james
到
1 2 jack
2 4 thomas
3 8 james
感谢
使用秩函数或ROW_NUMBER(http://www.databasejournal.com/features/mssql/article.php/3661461/New-Ranking-Functions-within-SQL-Server-2005.htm)
select rank() OVER (ORDER BY list of your columns) as Id,
your_column_1, your_column_2 ...
from your table