title: Convert SQL statement to Arel Rails query
body: <p>So, let's get straight: I'm struggling to days do convert this SQL Statement:</p>
  
  <pre><code>select * from (
      select distinct on (program_id) editions.*, programs.* 
      from editions inner join programs on editions.program_id = programs.id 
      where programs.station_id = 1) as editionsprograms 
  order by fixed desc, published_at desc, time desc 
  limit 4;
  </code></pre>
  
  <p>to an Arel rails query. Someone has any idea about how could make an Arel query that would have the same effect of the above SQL?</p>