Capgemini interview question

How to write complex Query?