Nested Query

This is also posted on StackOverflow.
This is also talked about in this reply of another topic.