You can pretty much format your code as you like — capitalized letters, spaces, indents, and line breaks don’t influence the result in SQL.

This is great, because it means you can use your formatting to make your code easier to read.

There are different conventions for how to structure your code, and you might develop your own style.

But here are some suggestions of how to best format your code:

  • Field names and functions should be lowercase
  • When using alias use the AS keyword
  • Use line breaks & indents to make your code more readable
  • Have space after a comma and on both side of operators
  • Use preceding commas
Exercise result

Next up

Documenting your code

Documenting your code ensures that you and others can go back and understand what the code is doing and how it’s structured.

Go to lesson