SQL Gotchas

20 Nov 2017

  • when comparing columns, always be aware of nulls and how your particular engine treats nulls.

  • when using NVL, use a default value that is not in the possible list of values you are comparing.. so instead of nvl(valid_ind,'N'), use nvl(valid_ind,'X') - assuming x is not a possible value for valid_ind

  • always have a driving table and start with that driving table as part of your query, and left join everything else. This will also let you comment out specific parts of the query and see if you are missing rows because of a join. If you have more than one driving table, it might be better to split the query using with clause and show how there are two logical different sources at play.

who am i

I am a data engineer with interests in databases, data science, algorithms and programming in general.

where am i

linkedin//rchamarthi
stackoverflow/users/237939/rchamarthi
Content available under Creative Commons (BY-NC-SA) unless otherwise noted.
This site is hosted at Github Pages and created with Jekyll. It uses the papyrus theme