Hey there,
I'm probably missing something here, but no matter what I try, I can't
seem to find a way to translate this query into SQLAlchemy code:
SELECT AVG(sub.average)
FROM (
SELECT AVG(feedback.overall_rating) AS average
FROM feedback
INNER JOIN listings ON feedback.listing_id =
listings.id
WHERE feedback.is_for_driver = false
GROUP BY feedback.listing_id
) AS sub;
So, is there any way someone could possibly point me in the right
direction? All of the tables have SA mappers defined for them (named
Feedback and Listing), if that helps. I've tried to do things like:
sa.select([sa.func.avg('sub.average'), sa.select([sa.func.avg
(Feedback.overall_rating).label('average')]).alias('sub')])
but no avail (and I know that doesn't include the grouping or the
where :)
Anyway, if someone could possibly help me out, I'd be most grateful.
Thanks,
Oliver Beattie