title: Teradata Case When statement - replacing values not in 1 column in result
body: <p>I have two tables and want to combine them where if not in one column it will be added to the other column. That way if they match except for where column 1 does not contain name in column 1 an 'N/A' will appear and same for column 2.  </p>
  
  <p>I get the names to match for rows that are present and get the 'N/A' to appear in column 2 where there is no match. I cannot get more rows added to column 1 where there is no match. I have 800 rows in total in Column 1 and 330 match in column 2. In column 2 there are 30, that are not in column 1.  </p>
  
  <p>So I want to get a list of the 800 + 30 = 830 rows total. 30 being N/A in column 1.</p>
  
  <p>Thanks for the help.  I have looked here and other places but nothing seems to match or come close or I just not getting it.</p>
  
  <pre><code>SELECT  
    CASE 
      WHEN cc.Db_Name = dr.DB_NAME THEN cc.DatabaseName
      WHEN cc.DatabaseName &lt;&gt; dr.DBE_NAME THEN 'n/a'
      ELSE cc.Db_Name
    END AS SQL_DB_NAME
    , CASE 
      WHEN cc.Db_Name = dr.DB_NAME THEN dr.DATABASE_NAME
      WHEN cc.Db_Name &lt;&gt; dr.DB_NAME THEN 'zz'
      ELSE 'N/A'
    END AS DG_DB_NAME
  FROM DL_SCANS1 AS cc -- (column1)
  LEFT JOIN DG_SCAN AS dr -- (column2)
    ON dr.DB_NAME = cc.DB_Name AND dr.Table_View = 'TABLE'
  GROUP BY cc.Db_Name, dr.DB_NAME 
  </code></pre>
  
  <p>Result:  </p>
  
  <pre><code>SQL_DB_NAME DG_DB_NAME  
  AAA         AAA  
  BBB         BBB  
  CCC         N/A  
  N/A         DDD  
  </code></pre>
  
  <p>total of 830 rows</p>