An additional column of serial numbers is automatically added to the SQL statement query results, and an SQL column is automatically added.
Sqlserver
It can be implemented using the row_number function.
As follows:
SELECT *, row_number () OVER (order by score (column name) DESC) AS rank FROM score
The SQL query statement automatically adds the serial number.
SQL 2000 has been written; similar, but forget, there are two solutions for reference:
1. select identity (INT, 1, 1) AS No., avge FROM Table1
2. select identity (INT, 1, 1) AS No., avge INTO # temp1 FROM Table1
SELECT * FROM # temp1
Drop table # temp1
The above two types are purely handwritten. If any word is wrong, please forgive me.
(Sqlserver) How to Write an SQL statement that adds an auto-increment column when the query result is inserted into a new table?
Assume that the table has a primary key ID column. The following table generates a new table with an Sequence Number Column greater than the original table and is filled with the ID number.
Select No. = (select count (1) from tablename a where a. id> = tablename. id), * from tablename