How can I write this query in Ruby on Rails? Query inside a from
select * from (
select *
from points, sports
where points.sport_id = sports.id
group by sports.id
order by max(points.value) desc
)
order by created_at desc
it's inside a app\models\concerns\scopes\sport.rb, so it should start as
scope :best_scores_in_sports, lambda {
joins(:points)
.select(etc.etc.
...right?
Aucun commentaire:
Enregistrer un commentaire