Hi,

We have a model called "Item". The Item is associated to UserReview Model 
and CriticReview Model. Both UserReview and CriticReview models have a 
column called rating. I want to find the item having the maximum average 
rating. The average rating is the average of rating column in both user 
reviews and critic reviews. So, I tried the following query:

Item.max { UserReview.where(item_id: 
Sequel[:items][:id]).union(CriticReview.where(item_id: 
Sequel[:items][:id])).select{avg(:rating)} }

But, I am getting the following error: Sequel::DatabaseError: Mysql::Error: 
Unknown column 'items.id' in 'where clause'

How will I be able to calculate it?

Thanks,
Satya

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to