12.138.Create-tables-to-get-daily-revnue-and-daily-product-revenue

Create Daily product Revenue table

 CREATE TABLE daily—product_revenue
> AS
> SELECT o.order_date ,
         oi.order_item_product_id ,
          round(sum(oi.order—item_subtotal), 2) AS revenue
  FROM orders o JOIN order _ items oi
  ON o.order_id = oi
> WHERE o.order_status IN ('COMPLETE' ,'CLOSED')
  GROUP BY o.order_date, oi .order_item_product_id;

Share this post