Day 12 – Display loyalty details from different Data Extension


To display customers’ transaction and loyalty details on the email.


SET @fullname = Concat(FirstName, " ", LastName)
SET @email = Email
SET @rows = LookupRows("AMPscript - Day 12 Rental_Transactions", "Email", @email)
SET @rowscount = RowCount(@rows)
SET @remaining = Subtract(10, @rowscount)
IF @rowscount >= 10 THEN
    SET @msg = "you have earned 100 points!"
    SET @msg = Concat("you are ", @remaining, " rent(s) away to earn 100 points")
Hello %%=v(@fullname)=%%,

Congratulations on renting from our car rental services! You have rented a total of %%=v(@rowscount)=%% time(s) and %%=v(@msg)=%%.



Use LookupRows(name of data extension from which to return specified rows, column name used to identify rows to return, value used to match rows to return) to look up rows in another Data Extension based on the matched values. Use RowCount(specified rowset) to calculate the total count of all the rowset.