AVG() over a JOINed orders/order_items table gives the wrong "average order value" — correct SQLAlchemy aggregation pattern? (stackoverflow.com)stack
26 points by Adarsh Singh in stackoverflow.com · 1h ago · stack
I have a fairly standard e-commerce schema: one orders row per order, and one order_items row per line item on that order (an order has 1-N items): sql CREATE TABLE orders ( id INTEGER PRIMARY KEY, order_date DATE ); CREATE TABLE order_items ( id INTEGER PRIMARY KEY, order_id IN…
filed under sqlalchemy