![]() We can also select and run only the subquery in the CTE. quantity FROM orders AS o - join the CTE avg_order LEFT JOIN avg_order AS a WHERE - above-average total o. CTE to calculate average order total and quantity WITH avg_order ( total, quantity ) AS ( SELECT AVG ( total ), AVG ( quantity ) FROM orders WHERE - exclude test orders product_id > 10 AND - exclude orders before launch created_at > '' AND - exclude test accounts user_id > 10 ) - orders with above-average totals SELECT o.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |