Top N reports are beneficial where there is a need to display only the specific number of top-most rows or records from a table or list. You can create this type of report by using the TopN operator in dataset filters or modifying the query while creating a dataset. TopN operator can be used in dataset filters for all data sources. Your data will be more meaningful if you also specify the order of rows.
Consider a scenario where the user wants to display the top ten movie records.
Data Source Connection String |
Copy Code
|
---|---|
data source = C:\Data\reels.db; |
Dataset Query |
Copy Code
|
---|---|
SELECT * FROM Movie ORDER BY UserRating Desc |
Expression: =[UserRating]
Operator: TopN
Value: 10
The following image illustrates Top N Report displaying top 10 movie records:
The following sections provide sample dataset queries to obtain top N data from other data sources.
DataSet Query |
Copy Code
|
---|---|
SELECT * FROM Movie LIMIT 10 |
DataSet Query |
Copy Code
|
---|---|
SELECT Top 10 * FROM Movie |
DataSet Query |
Copy Code
|
---|---|
//countries/country[position() <= 10]
|
DataSet Query |
Copy Code
|
---|---|
$.Customers[:10] |