title: Being DRY in a Sqlite query with CASE statement
body: <p>In the following (working) query:</p>
  
  <pre><code>SELECT q.id, q.section_id, q.type, q.required, q.condition,
  CASE WHEN (t1.text_1 IS NULL) THEN
      CASE WHEN ((SELECT t2.text_1 FROM translations t2 WHERE t2.item_id = q.id AND t2.item_model = 'questions' AND t2.language = 'en' LIMIT 1) IS NULL) THEN 
          (SELECT t3.text_1 FROM translations t3 WHERE t3.item_id = q.id AND t3.item_model = 'questions' LIMIT 1)
      ELSE
          (SELECT t2.text_1 FROM translations t2 WHERE t2.item_id = q.id AND t2.item_model = 'questions' AND t2.language = 'en' LIMIT 1)
      END
  ELSE
      t1.text_1
  END
  AS translation
  FROM questions q
  LEFT JOIN translations t1 ON t1.item_id = q.id
      AND t1.item_model = 'questions'
      AND t1.language = 'fr'
  ORDER BY q.position
  </code></pre>
  
  <p>You can see that the part <code>(SELECT t2.text_1 FROM translations t2 WHERE t2.item_id = q.id AND t2.item_model = 'questions' AND t2.language = 'en' LIMIT 1)</code> is repeated twice (the first to check if it's null, and the second to get the value).</p>
  
  <p>Could the repeated same query a performance issue (I guess so)?<br>
  Is there a better way to rewrite this query, being DRY? </p>