How to Answer: How would you return the first 100 records from a table based upon the order of a numerical value?
Advice and answer examples written specifically for a Sql Server Developer job interview.
3. How would you return the first 100 records from a table based upon the order of a numerical value?
This question focuses on using SQL to obtain specific data.
The TOP expression allows you to return a limited number or percentage of rows from a query. It is typically used in conjunction with the order by clause.
/** In an [Order] table, the following query will return the top 100 orders based upon the total cost of an order, in descending order. **/
select top 100 [OrderID], [OrderAmount], [CustomerLastName]
from Orders
order by OrderAmount desc
Written by Edward Danganan on April 13th, 2021