title: Create a new column when querying SQL Server
body: <p>I have two tables like this:</p>
  
  <p><strong>Function</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/VP9d9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VP9d9.png" alt="Function"></a></p>
  
  <p><strong>FunctionName</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/bPunV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bPunV.png" alt="enter image description here"></a></p>
  
  <p>On query, I need to create a new column 'Status' where it will be 'true' if an AccountId has a function and 'false' if it is not in the function. What I mean is AccountId 1 has all the functions so basically I should get 'true' in all rows of the Function since AccountId 1 has all the functions and for AccountId 16, i should get 'false' in the Status column since there is no Function for AccountId 16. I really don't know how to implement this. I know how to Left join and stuff, I don't know how to go about what I need. Can you help? My feeble attempt got me to this is below but I know it's still a long way.</p>
  
  <pre><code>SELECT f.FunctionId, f.FunctionName,
  CASE WHEN f.FunctionId IS NOT NULL THEN 'true' ELSE 'false' END AS [Status]
  FROM [AccountFunction] as af
  left join [Function] as f ON f.FunctionId = af.FunctionId
  where af.AccountId = 1
  </code></pre>