• I think the correct query would be to add the GROUP BY of course, and also ORDER BY 3 DESC. Or name the derived item, and order by that name. I wonder how much the author have tested his own query...

    Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2