• As Sean said, if you post the DDL (CREATE TABLE statement) for the table(s) involved, some sample data (a series of INSERT INTO statements (some people here still use SQL Server 2005)) for the tables involved, and the expected results based on the sample data provided you will get better answers to your questions plus the bonus of tested code.

    If you don't know how to do this then please read the article that Sean also told you about. You can get to it using the first link in my signature block. It will show you what you need to post and how to do it.

    Anything less, then you are just going to get shots in the dark that may or may not help you.