1 Reply Latest reply on May 1, 2013 3:58 AM by rp0428

    Beginner looking for a little help on a SQL statement.

      Which stores sold the most turkey dinners during the Red Carpet Closeout promotion by day?

      Displays all stores with sales for the turkey dinner each day but I only want to display the store with the most sales for each day. So my result should only be displaying 7 results with the dollar amount for each day as well as which store.

      SELECT name,description "Description", promotion_name "Promotion Name",
      TO_CHAR(SUM(unit_sales), 'L99G999D99MI') AS "Unit Sales", day_of_week "Day"
      FROM store_data_warehouse.store
      JOIN store_data_warehouse.sales_fact
      USING (store_key)
      JOIN store_data_warehouse.time
      USING (time_key)
      JOIN store_data_warehouse.product
      USING (product_key)
      JOIN store_data_warehouse.promotion
      USING (promotion_key)
      WHERE product_key = 3
      AND promotion_key = 2
      GROUP BY day_of_week, name, description, promotion_name
      ORDER BY (SUM(unit_sales))DESC, name

      What am I missing? Thanks for any and all help.