sql server - How to generate auto increment field in select query -
for example have table 2 columns, first_name
, last_name
these values
ali khani elizabette amini britney spears ,...
i want write select
query generate table this:
1 ali khani 2 elizabette amini 3 britney spears ,...
thanks help.
if mysql can try
select @n := @n + 1 n, first_name, last_name table1, (select @n := 0) m order first_name, last_name
and sqlserver
select row_number() on (order first_name, last_name) n, first_name, last_name table1
Comments
Post a Comment