This is my 20th year working with SQL (eek!), and I’ve shared my 10 key learnings to help make sure your SQL code is easy to read, debug, and maintain.

The key to success is, of course, to enforce these (or your own standards) across your Enterprise. Tip 10 discusses how you can do this.

So, in no particular order, let’s begin.

#1 Choose a CASE and Stick to_it

If I was given £1 every time I saw something like this, I think I’d be sitting on a tidy sum:

select first employee_first_name,
       surname employee_last_name,
       title,
       CASE WHEN employment = 1 THEN 'FT' WHEN employment = 2 THEN 'PT' ELSE 'T' END 
       as EmploymentStatus,
       'Y' AS isValid
       ,"HR" Employee-source
from employees
WHERE Valid = 1

#postgres #data-science #mysql #sql #sql-server

10 SQL Standards to Make Your Code More Readable in 2021
1.15 GEEK