Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    369

    Unanswered: need help with populating table using insert and select

    I have a data warehouse fact table that I need to re-populate using an insert and select sum(column) query: below is the query that I am trying to use but it fails. We have Oracle 8i database on Solaris. Can anyone help me out?

    INSERT INTO fact_tb1
    (cost1,
    cost2,
    qt1,
    qt2
    )
    SELECT SUM
    (
    cost1,
    cost2,
    qt1,
    qt2
    )
    FROM fact_tb1
    WHERE week_id between 1 and 52
    GROUP BY week_id
    )
    );
    /

    Thanks gurus!
    Scott

  2. #2
    Join Date
    Jan 2005
    Location
    Green Bay
    Posts
    201
    What are these fields
    qt1,
    qt2

    These need an aggregate funtion applied to them

    Sum
    Min
    Max
    Or Group by

    INSERT INTO fact_tb1
    (cost1,
    cost2,
    qt1,
    qt2
    )
    SELECT
    SUM(cost1),
    sum(cost2),
    qt1,
    qt2
    FROM fact_tb1
    WHERE week_id between 1 and 52
    GROUP BY week_id
    ;

  3. #3
    Join Date
    May 2003
    Posts
    369

    the solution

    I figured it out:

    prompt populating fact_t1

    INSERT INTO /*+ APPEND PARALLEL (fact_t1, 8) */
    (
    current_year,
    current_yr_min_cost,
    current_year_avg_cost
    )
    SELECT /*+ PARALLEL (fact_t1, 8) */
    SUM(current_year),
    SUM(current_yr_min_cost),
    SUM(current_year_avg_cost)
    FROM fact_t1
    /


    Had to play around with SQL. Thanks for your help.
    Scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •