Imriel interview question

How to write complex quires and how to store it and return.