title: Creating a SQL column based on the value of another column in the same table
body: <p>I must not be using the right Google foo to find the correct answer. </p>
  
  <p>I have a table that looks like the following:  </p>
  
  <p>ID  Parent  Status   Name</p></p>
  
  <p>1              NULL     0              Root</p> 2              1              0              Group 1</p></p>
  
  3               6              400         WINXP32</p>
  
  4              2              400         WIN7</p>
  
  5              2              400         WIN2K8</p>
  
  6              1              0              Group 2</p>
  
  <p></p>
  
  <p>The 'name' column contains both group names and machine names. Groups have a 'Status' of 0.
  How would I create a SQL statement to display (not modify the database) a column called 'Group' based on the logic that the 'Parent' column holds the 'ID' of its parent.</p>
  
  <p>Somehow I can figure out how to join data from other tables but I cant figure this out...</p>
  
  <p>-- Update: I forgot to show an example of the output I'm looking for, in a perfect world I would get the following..</p>
  
  <p>ID   |   Group   |  Status    |  Name<br>
  3   |   Group 2   | 400   |  WINXP32<br>
  4  | Group 1  |  400  | WIN7<br>
  5  |  Group 1  | 400  | WIN2K8</p>
  
  <p>I would (i think) filter out the groups from the output by doing a where status > 0</p>
  
  <p>Thanks everyone for the quick feedback !</p>