Killing 1NF for fun :)
An client wanted to add an arbitrary ordering to a set of rows which were being displayed in some legacy code, I had this functionality in newer versions of the software that he was running but due to “technical issues” couldn’t upgrade the software at the time.
The correct way to do this would obviously to add a “weight” field to the database and use an ORDER BY to sort the rows, however this would mean changing code in the input/edit feilds which I didn’t have time for. My simplified 5-minute solution is as follows:
SELECT name, SUBSTRING(position FROM 3) as position, biography, image
FROM members
ORDER BY SUBSTRING(position, 1,2) ASC
Yes it broke 1NF and will probably end up on an SQLWTF some day, but it was a quick and easy solution which only required a change in the SQL string and didn’t touch the code.