title: CONCAT with IF condition in SQL Server
body: <p>I have a table with four columns presenting {YES, NO, N/A} values. What I'd like to obtain is a column with concatenated names of those columns which present a 'YES' value separate by a double underscore.</p>
  
  <pre><code>\, A, B, C, D
  1, YES, NO, YES, N/A
  2, NO, YES, N/A, N/A
  3, YES, NO, NO, YES
  </code></pre>
  
  <p>Expected result:</p>
  
  <pre><code>A__C
  B
  A__D
  </code></pre>
  
  <p>Something like: </p>
  
  <pre><code>select CONCAT(
  IF(A = 'YES', 'A'),
  IF(B = 'YES', 'B'),
  IF(C = 'YES', 'C'),
  IF(D = 'YES', 'D'))
  from my_table
  </code></pre>