简体   繁体   中英

How can I use ROW_NUMBER() if the column name is not identified?

I want to create row number but I don't want to use any specified column (or column name not identified). Something like below

SELECT ROW_NUMBER() OVER(ORDER BY '*'), * FROM DIM_BRANCH

How can I achieve this?

就像这样

SELECT ROW_NUMBER() OVER(ORDER BY (Select Null)), * FROM DIM_BRANCH
SELECT ROW_NUMBER() OVER(ORDER BY @@rowcount), * FROM DIM_BRANCH

如果您想要更随机的行为:

SELECT ROW_NUMBER() OVER(ORDER BY NEWID()), * FROM DIM_BRANCH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM