title: SQL Server : exclude rows with NULL values after CASE expression
body: <p>The query below aggregates data from a logging table in the way I want... </p>
  
  <pre><code>SELECT 
      [TransactionNumber]
      ,MIN(CASE WHEN [Entry] = 'Updated status to Awaiting OCLC Sending' THEN [DateTime] END) AS 'start' 
      ,MAX(CASE WHEN [Entry] = 'Updated Status to: Delivered to Web' THEN [DateTime] END) AS 'end' 
      FROM [ILLData].[dbo].[History]
      GROUP BY [TransactionNumber] 
      /*
      227882  2015-09-29 14:17:07.443 2015-09-29 15:27:03.180
      227883  NULL    NULL
      227884  2015-09-29 14:29:22.340 NULL
      227885  NULL    2015-09-29 14:59:54.677
      */
  </code></pre>
  
  <p>...but I want to exclude any of the resulting rows containing NULL values. I tried the queries below, but I keep getting the same results and the rows with NULL values are not excluded. </p>
  
  <pre><code>SELECT 
      [TransactionNumber]
      ,MIN(CASE WHEN [Entry] = 'Updated status to Awaiting OCLC Sending' THEN [DateTime] END) AS 'start' 
      ,MAX(CASE WHEN [Entry] = 'Updated Status to: Delivered to Web' THEN [DateTime] END) AS 'end' 
  FROM 
      [ILLData].[dbo].[History]
  WHERE 
      'start' IS NOT NULL 
      AND 'end' IS NOT NULL 
  GROUP BY 
      [TransactionNumber] 
  
  /* still get rows with NULL values */
  
  SELECT 
      [TransactionNumber]
      ,MIN(CASE WHEN [Entry] = 'Updated status to Awaiting OCLC Sending' THEN [DateTime] END) AS 'start' 
      ,MAX(CASE WHEN [Entry] = 'Updated Status to: Delivered to Web' THEN  [DateTime] END) AS 'end' 
  FROM 
      [ILLData].[dbo].[History] 
  GROUP BY  
      [TransactionNumber] 
  HAVING 
      'start' IS NOT NULL 
      AND 'end' IS NOT NULL
  
  /* still get rows with NULL values */
  
  WITH history AS 
  (
     SELECT  
         [TransactionNumber]
         ,MIN(CASE WHEN [Entry] = 'Updated status to Awaiting OCLC Sending' THEN [DateTime] END) AS 'start' 
         ,MAX(CASE WHEN [Entry] = 'Updated Status to: Delivered to Web' THEN [DateTime] END) AS 'end' 
     FROM 
         [ILLData].[dbo].[History]
     GROUP BY 
         [TransactionNumber])
  SELECT * 
  FROM history 
  WHERE 'start' IS NOT NULL 
    AND 'end' IS NOT NULL 
  
  /* still get rows with NULL values */
  </code></pre>
  
  <p>Is there a way to filter the results of my query which used <code>CASE</code>?</p>