Please provide all related table definition together with sample data and expected result in a ready to use format.
The query you provided won't run due to missing tables and columns.
Lutz
A pessimist is an optimist with experience. How to get fast answers to your question[/url]
How to post performance related questions[/url]
Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]