Reputation: 120
select
CodeColumn, NameColumn, UnitCostColumn, DiscountRateColumn,
TotalColumn, DescriptionColumn,
row_number() over (order by CodeColumn) AS RowNumber
from
GoodsTable1
This is the code I use. But it adds RowNumber
at the end of my table. I don't want that
Upvotes: 1
Views: 73
Reputation: 311478
Just move that "column" to the beginning of the select list:
SELECT ROW_NUMBER() OVER (ORDER BY CodeColumn) AS RowNumber, -- Here!
CodeColumn,
NameColumn,
UnitCostColumn,
DiscountRateColumn,
TotalColumn,
DescriptionColumn
FROM GoodsTable1
Upvotes: 1