Jeff Smith Blog

Random Thoughts & Cartesian Products with Microsoft SQL Server

SELECT DISTINCT and ORDER BY

Let's take a look at another one of those stupid, arbitrary SQL Server error messages that Bill Gates clearly only created because Micro$oft is evil and incompetent and they want to annoy us (and probably kill baby squirrels, too): Msg 145, Level 15, State 1, Line 4ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Read more →