1 Reply Latest reply: Apr 30, 2013 10:58 PM by rp0428 RSS

    Beginner looking for a little help on a SQL statement.

    1006456
      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.
        • 1. Re: Beginner looking for a little help on a SQL statement.
          rp0428
          WRONG FORUM!

          Welcome to the forums but you have posted you SQL question in the SQL Developer forum which, as the forum title says, is NOT for general SQL/PLSQL questions.

          Please mark this question ANSWERED and repost it in the SQL and PL/SQL forum
          PL/SQL

          When you post provide your 4 digit Oracle version.

          You also need to post the results your query is giving and explain why those results are wrong.