After a coworker left, I was - among other things - put in charge of maintaining a bunch of database views he added to our ERP system to do some reports (on Microsoft SQL Server, in case it matters).<p>It wasn&#x27;t even that it was so exceptionally clever, but the SQL code made my eyes bleed at times.<p>So while I know basic SQL fairly well, I am by no means a wizard, and I tend more and more to keep the queries I write as simple as possible and to do the heavy lifting on the client side. Obviously, there are limits - to get the sum of a column, for example, it makes much more sense to do that on the server instead of transferring lots of data to the client and have it compute the sum.<p>As soon as I want to do more sophisticated stuff, my queries tend to get fairly ugly, and some day some other poor soul might have to look at and understand the code. I&#x27;d rather write a simple query and do the more complicated transformations using a PivotTable in Excel.<p>So while it&#x27;s nice to know that there are these tricks, I try not to use them (not more than I have, anyway).