How to use ROW_NUMBER() in SQL Server....
Suppose i have a table named HistoricalData containing 5 records in it.If i want to show my table containing one column at run time that will display the row number of this table starting from 1 to the count of the record of this table. For that purpose i will use Row_Number() function.
This command will show all records of a table HistoricalData
SELECT *from HistoricalData
This command will add an column NoOfrows at run time
select Symbol,ROW_NUMBER() over(order by symbol) as NoOfRows from HistoricalData
The result will b like this of both of the commands...
This command will show all records of a table HistoricalData
SELECT *from HistoricalData
This command will add an column NoOfrows at run time
select Symbol,ROW_NUMBER() over(order by symbol) as NoOfRows from HistoricalData
The result will b like this of both of the commands...
.bmp)
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home