To combine data from different records in your query you need to use the <link-entity> element. This is equivalent to a join in SQL.
As promised, I’m starting a series of blog posts covering various aspects of FetchXML and the humble <attribute> element seems like a good place to start.
Firstly, thank you to everyone who’s shown an interest in my SQL 4 CDS XrmToolBox tool! I’ve been busy working on the difficult second release, and I’m pleased to announce version 1.0.3 is in the new Tool Library today!