title: Can a Union have another column name as long as the number of columns is the same?
body: <p>I have a query I would like to eventually put into a view.</p>
  
  <p>First can I name my Flag column differently as long as I have 2 columns throughout?</p>
  
  <p>Also, can I perform a union on the same table with a different WHERE clause?</p>
  
  <p>Finally, what is the correct approach for getting these 3 selects into 1 view?</p>
  
  <pre><code>    SELECT ID, 'Y' AS PW_CHANGE31, NULL AS LAST_LOGON90, NULL AS LAST_LOGON365 FROM user_info WITH (nolock) WHERE ([Last Password Change] &lt; GETDATE() - 31)
  UNION ALL
  SELECT ID, NULL AS PW_CHANGE31, 'Y' AS LAST_LOGON90, NULL AS LAST_LOGON365 FROM user_info WITH (nolock) WHERE ([Last Logon] &lt; GETDATE() - 90) AND ([Account Disabled] = 0)
  UNION ALL
  SELECT ID, NULL AS PW_CHANGE31, NULL AS LAST_LOGON90, 'Y' AS LAST_LOGON365 FROM user_info WITH (nolock) WHERE ([Last Logon] &lt; GETDATE() - 365)
  </code></pre>
  
  <p>**UPDATED TO:</p>
  
  <pre><code>SELECT ID, '31' AS StatusVal FROM user_info WITH (nolock) WHERE ([Last Password Change] &lt; GETDATE() - 31)
  UNION 
  SELECT ID, '90' AS StatusVal FROM user_info WITH (nolock) WHERE ([Last Logon] &lt; GETDATE() - 90) AND ([Account Disabled] = 0)
  UNION 
  SELECT ID, '365' AS StatusVal FROM user_info WITH (nolock) WHERE ([Last Logon] &lt; GETDATE() - 365)
  </code></pre>