Could you please help find the equivalent in Rails ActiveRecord for this MySql query:
SELECT parent1_id, COUNT(DISTINCT parent2_id), sum(loaded), FROM child
GROUP BY parent1_id
The column "loaded" is boolean in rails. The mysql query works just fine because it allows sums as null (loaded = 1 or null (not 0) in mysql)
In your answer you can assume the models Parent1, Parent2 and Child as the models for these tables.
Thank you
Aucun commentaire:
Enregistrer un commentaire