Capgemini Interview Question

How to write complex Query?