title: Return array of values instead of array of objects from SQL query in Rails
body: <p>I have a SQL query in a Rails model that responds with an array of objects. And each object has an attribute called <code>points</code> with a value.</p>
  
  <p>But its preferable for query to just return an array of <code>points</code> like <code>[10,15,5]</code> instead of <code>[object,object,object]</code> which requires then extracting the points out into another array to be useful.</p>
  
  <p><strong>Model file</strong></p>
  
  <pre><code>LAST_3_SELECT = "
    SELECT
      (
        (data.ap / (data.apa * 1.0))
        +
        (data.vp / (data.vpa * 1.0))
      )
      / 2 * 1.5 * data.level
      AS points
    FROM data
    WHERE data.user_id = ?
    GROUP BY data.id
    ORDER BY data.created_at DESC
    LIMIT 3
  "
  
  def self.last_3(user_id)
    connection.select_all(sanitize_sql_array( [LAST_3_SELECT, user_id]), "last-3")
  end
  </code></pre>
  
  <p>Is this possible to do in a query itself, or necessary to do in a method outside it?</p>
  
  <p>I don't have much experience writing raw SQL queries into Rails methods so any guidance would be very appreciated.</p>