How can anyone help when you post nothing that is needed to help you? You haven't posted any facts, code, expected results or actual results.
For all we know the procedure is returning the correct results; we have no way of knowing what the results should be or even what they really are since you didn't post them.
You made a lot of statements but haven't posted anything to show that the statements are even true.
Post facts that backup all the statements that you made and post the code you are using.
I marked your answer as correct to be as snippy as your answer. This kind of answer was unwarranted. You could simply have asked specific questions. If you read and think about what I stated, the answers are there. I won't bother dignifying you with an answer.
PS: I only read the first couple of lines of your answer - it was not worth my time to go on. I'll find another way around this.