Add sequence number to query results

M

mscertified

I need to run a SELECT query based on a column and include a sequence column
in the results. Does anyone know how to do this?
e.g. if my table has values 200,150,700,500,300
It should return:
1 150
2 200
3 300
4 500
5 700
 
K

KARL DEWEY

Try this --
SELECT (SELECT COUNT(*)
FROM [YourTable-4] T1
WHERE T1.Column1 <= T.Column1) AS Sequence, T.Column1
FROM [YourTable-4] AS T;

When you run it the first time the sequence may be out of order. Click in
the column then click the A-Z icon.
 
Top