Just out of curiosity, why don't you simply run those statements on SQL Server?
I think "END = 99" is an artefact left from the development of the query. I would change it to something like "END AS StateNr". I have noticed SQL Server sometimes misses those quirks, doesn't give any warning or error message, but gives wrong results afterwards. Perhaps that is what you are experiencing.
What do you think those Scenarios will give as result?
Last edited by Wim; 10-24-09 at 18:39.
With kind regards . . . . . SQL Server 2000/2005/2012
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2. Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages