select
CodeColumn, NameColumn, UnitCostColumn, DiscountRateColumn,
TotalColumn, DescriptionColumn,
row_number() over (order by CodeColumn) AS RowNumber
from
GoodsTable1
这是我使用的代码。但是它在表的末尾添加了RowNumber
。我不要那个
答案 0 :(得分:1)
只需将“列”移动到选择列表的开头:
SELECT ROW_NUMBER() OVER (ORDER BY CodeColumn) AS RowNumber, -- Here!
CodeColumn,
NameColumn,
UnitCostColumn,
DiscountRateColumn,
TotalColumn,
DescriptionColumn
FROM GoodsTable1