Reputation: 113
i have my table like this
Sr_No / AccessionNo / Roll_nO / Price
---------------------------------------
1 / 101 / 45 / 1000
2 / 102 / 46 / 2000
3 / 101 / 43 / 500
i want that when user types in the textbox 2 then the last 2 rows should be retrived but i dont know which function to be used here i am a student and started my c# quite few months before and using sql server from few months only. i have googled that and found some query but i dont think this will be helpfull as this query gives me the top part is there any function which gives the bottom part defined by the user?
SELECT TOP 5 * FROM [TableName]
sorry for my bad english.
Upvotes: 0
Views: 65
Reputation: 263703
TOP
will certianly work. you just need to Reorder the records using ORDER BY
clause,
SELECT TOP 2 * FROM [TableName] ORDER BY SR_NO DESC
Upvotes: 0
Reputation: 79929
Specify an ORDER BY ... DESC
clause to get the bottom rows:
SELECT TOP 5 *
FROM [TableName]
ORDER BY Sr_No DESC;
Upvotes: 1