Next databese record which has a flg

I am now facing a problem.

There is a table, called “advertisement”, which stock advertisement information such as movie, click count, and active flag - yes/no (most important)
I store this information into “current user” as relation, when the user finish watching the advertisement.

Once a user finish watching a movie(ads), I want to show next ads when the user take specific actions.
As I write above, he ads table has “active flg” which devide if the ad is active or not.

How can I identify the next table record, which has “active flg” ?
I don’t have any idea to do it.