I am trying to make the following query in ActiveRecord in rails.
SELECT * FROM test_run WHERE build = '$build' AND suite='$suite'AND (result = 'fail' OR result = 'error')
AND test_name NOT IN(SELECT test_name FROM test_run WHERE result = 'pass' AND build = '$build')GROUP BY test_name";
The first part is easy, I am not sure how to do the subquery.
scope :never_passed, lambda { |b| where(:build => b, :status => 'fail').where(??)
Any ideas on what I would need to do to be able to get this subquery to work as the sql above?
Thanks
Thanks to Arel, you can do subqueries like:
would output the following SQL: