Query looping

General

Query looping

How to write a query... looping, please find the attached image