title: Most efficient way to DECODE multiple columns -- DB2
body: <p>I am fairly new to DB2 (and SQL in general) and I am having trouble finding an efficient method to DECODE columns</p>
  
  <p>Currently, the database has a number of tables most of which have a significant number of their columns as numbers, these numbers correspond to a table with the real values. We are talking 9,500 different values (e.g '502=yes' or '1413= Graduate Student')</p>
  
  <p>In any situation, I would just do WHERE clause and show where they are equal, but since there are 20-30 columns that need to be decoded per table, I can't really do this (that I know of).</p>
  
  <p>Is there a way to effectively just display the corresponding value from the other table?</p>
  
  <p>Example: </p>
  
  <pre><code>SELECT TEST_ID, DECODE(TEST_STATUS, 5111, 'Approved, 5112, 'In Progress') TEST_STATUS
  FROM TEST_TABLE
  </code></pre>
  
  <p>The above works fine.......but I manually look up the numbers and review them to build the statements. As I mentioned, some tables have 20-30 columns that would need this AND some need DECODE statements that would be 12-15 conditions.</p>
  
  <p>Is there anything that would allow me to do something simpler like:</p>
  
  <pre><code>SELECT TEST_ID, DECODE(TEST_STATUS = *TableWithCodeValues*) TEST_STATUS
  FROM TEST_TABLE
  </code></pre>
  
  <p><strong>EDIT:</strong> Also, to be more clear, I know I can do a ton of INNER JOINS, but I wasn't sure if there was a more efficient way than that.</p>