286/289
\begin{frame}
  \frametitle{Inner and Outer Joins}

  \begin{quiz}{\textwidth}{Is there a problem with the following query?}
    ``\emph{Number of homeworks solved per student (including 0).}''
  
    \bigskip
    \small
    \BUseVerbatim{query}
  \end{quiz}
  
  %% Yes:
  %% The outer join is constructed before the WHERE clause is evaluated:
  %% for students without any entry in RESULTS, the attributes R.CAT,
  %% R.ENO, ... have been set to NULL before the test one R.CAT = 'H'
  %% takes place.
  \smallskip\pause
  
  It is generally wise to restrict the outer join inputs
  \emph{before} the outer join is performed (or move restrictions into the \sql{ON} clause).
  \pause
  
  \begin{code}{\textwidth}{Corrected version of last query.}
    \small
    \BUseVerbatim{query2}
  \end{code}
\end{frame}