…it is not contained in either an aggregate function or the GROUP BY clause

I cannot tell you how annoying I find this error, and before you post a comment, I know it’s not the fault of SQL Server. I’ve asked it for something that is not logically solvable. […]