Like a book or a beautiful picture, we also need to take care with how we write a query. We can either use SQLA or Teradata Studio Express for this purpose. The main thing is, our query should be readable and should easily be understood.
- Keep individual SQL statements small as they are easier to debug and support.
- Always qualify table names with database names; default database assignments can change.
- Use ANSI join syntax with join criteria in the ON clause, not in the WHERE clause. Join the clause on one line, tableA inner join tableB, and use a separate line for each criteria.
- Use a separate line for each table in the form list.
- When using subqueries, ...