SalesforceSalesforce Marketing Cloud SpecialistMarketing Cloud DeveloperMedium
What is the difference between Lookup, LookupRows, and LookupOrderedRows in AMPscript?
Suggested answer
Lookup returns a single scalar value — the value of the specified column from the first row matching the filter criteria. Syntax: Lookup("DE_Name","ReturnCol","FilterCol","FilterVal"). LookupRows returns a rowset object containing all matching rows. You iterate using Row(rowset, rowNum) and Field(row, "colName"). LookupOrderedRows returns a rowset sorted by a specified field (ascending or descending) and can be capped to a maximum row count. Use LookupOrderedRows when you need the most recent N records (e.g., last 3 purchases ordered by date descending).
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.