如何在我的 table in SQL 的开头添加行号列?
How to add Row Number Column at the beginning of my table in SQL?
select
CodeColumn, NameColumn, UnitCostColumn, DiscountRateColumn,
TotalColumn, DescriptionColumn,
row_number() over (order by CodeColumn) AS RowNumber
from
GoodsTable1
这是我使用的代码。但是它在我的 table 末尾添加了 RowNumber
。我不想要那个
只需将 "column" 移动到 select 列表的开头:
SELECT ROW_NUMBER() OVER (ORDER BY CodeColumn) AS RowNumber, -- Here!
CodeColumn,
NameColumn,
UnitCostColumn,
DiscountRateColumn,
TotalColumn,
DescriptionColumn
FROM GoodsTable1
select
CodeColumn, NameColumn, UnitCostColumn, DiscountRateColumn,
TotalColumn, DescriptionColumn,
row_number() over (order by CodeColumn) AS RowNumber
from
GoodsTable1
这是我使用的代码。但是它在我的 table 末尾添加了 RowNumber
。我不想要那个
只需将 "column" 移动到 select 列表的开头:
SELECT ROW_NUMBER() OVER (ORDER BY CodeColumn) AS RowNumber, -- Here!
CodeColumn,
NameColumn,
UnitCostColumn,
DiscountRateColumn,
TotalColumn,
DescriptionColumn
FROM GoodsTable1