title: Amazon Redshift: Selecting columns based on a list of columns present in a table
body: <p>Is it possible in any way (without scripting) to aggregate columns which are stored in a table cell.</p>
  
  <p>Basically what i am trying to achieve here is that if i have the following table</p>
  
  <pre><code>Table 1
  KEYNAME    | COLUMN_NAME
  COUNT_USER | USER_ID
  SUM_HOURS  | HOURS_WATCHED
  </code></pre>
  
  <p>Can i do something like</p>
  
  <pre><code>select SUM((select column_name from TABLE1 where KEYNAME = "SUM_HOURS")) FROM MAIN_TABLE
  </code></pre>
  
  <p>I have the option to script in python via which i know how to achieve this. But i am curious to know if this is possible in any version of SQL or not
  Please let me know if the information is insufficient.</p>