Getting SUM of related table column not working
Hi all, I'm trying to get the SUM of the values on a related table column, and although I'm not getting any errors, this doesn't work with my code. The two COUNT columns work, but the two SUM columns don't. Can someone point out what I'm doing wrong? Many thanks.
Solution:Jump to solution
Found the documentation and
trips_sum_distance
works! Thanks for pointing me in the right direction.5 Replies
The name is probably
distance_sum
not total_miles
Thanks Dennis. Just tried that and still no luck.
Is it
trips_sum
? then. It follows Laravels conventionNo, That doesn't work either. Tried
trips.distance_sum
too, and that doesn't work. Really scratching my head! πSolution
Found the documentation and
trips_sum_distance
works! Thanks for pointing me in the right direction.