gksharmaajmer (10/2/2013)
Thank you Chris for your continue support. Probably I am not able to find a bug in the query but when I am saying :SELECT *
FROM #Results
WHERE student_name <> 'Default'
which is not returning me the required output No. 3, same when I am saying :
SELECT *
FROM #Results
WHERE student_name = 'Default'
is not returning me the required output No. 2, while
SELECT *
FROM #Results
is giving me the correct oupput of required output No. 1.
I am really thankful to you for your valuable code which is simultaneously giving me the learning of SQL too (in which I am very much poor)
Regards
Girish Sharma
You're welcome.
Apart from the first row of your third table (which I don't think should be there), the queries appear to generate the correct results from your sample data. If you are getting different results then describe what you see - check using the sample data set you've provided which may differ from your actual data. If this is the case, then set up a new sample data set which demonstrates.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden