The ROW_NUMBER
function returns the row number in the resulting dataset.
In your query you restricted the results to only those whose name is Murali
. Since you have only one such record, it is normal that it will return 1.
In SQL there's no such notion as row number. Table rows do not have an order. The notion of order only makes sense when you make a SQL query. Without SQL query you simply cannot talk about order and row numbers.
It appears that you need to introduce some order number for each user. The correct way to implement this is to add an Order
column to your Deposit
table. Now in order to retrieve it you would use the following query:
SELECT [Order] From Deposit WHERE Name = 'Murali'
All that's left is make the Order
column to autoincrement and you are good to go. Everytime a new record is inserted the value will be automatically incremented. So there you go, now you have an order which represents the order in which the records have been inserted into the table. You now have context.