Retrieves a rowset from a data extension. You can specify the number of rows returned and the order that the results are returned in. If the order of results isn’t important, the LookupRows() function offers a simpler syntax.

This function returns a maximum of 2,000 rows.

LookupOrderedRows(1, 2, 3, 4, 5)

1stringRequired. The name of the data extension.
2numberRequired. The number of rows to return. If you specify a value less than 1, the function returns 2,000 rows, which is the default value.
3stringRequired. The column and direction to sort by, using the syntax COLUMN_NAME SORT_ORDER, where SORT_ORDER is either ASC (ascending) or DESC (descending).
4string or arrayRequired. The name of the column that contains the data to look up. To specify multiple column names, place the column names in an array. When you specify multiple column names, they’re connected using AND logic.
5string or arrayRequired. The value to look up in the specified column. To specify multiple values, place the values in an array. If you specify an array for ordinal 4, you must specify an array of equal length for this ordinal.

To use the function, specify the name of the data extension, the number of rows to return, and the column to sort by. Next, specify the column that contains the data that you want to retrieve and the value to search for in the specified column.

These examples reference a data extension that contains the customer data listed in this table.


This example retrieves all rows in which the value of the RewardsTier column is Silver. In the resulting rowset, the results are sorted by last name in ascending order. The function returns the default number of results (2,000).

The function outputs three results.

You can also specify multiple values for the column name or the value by placing the values in an array. Multiple values are connected using AND logic. This example retrieves the rows in which the value of PreferredLanguage the value of RewardsTier is Silver. The function sorts the results in ascending order by LastName. The function returns the default number of results (2,000).

The function outputs the names of the customers whose preferred language is English and whose rewards tier is Silver.