Support for mandatory request - insert, select from the same table

Hi all

I need your help to write queries effectively.
Oracle Version: 10.2.0.3.0
OPERATING SYSTEM: UNIX

I have a METRICS_TBL that is mentioned below table.

CYCLE_DATE METRIC VALUE
08/17/2008 COST-TV 100
08/17/2008 COST-JOURNAL 50
08/17/2008 COST-POSTALMAIL 25
08/17/2008-PROD-TV 10
08/17/2008-PROD-JOURNAL 25
08/17/2008-PROD-POSTALMAIL 5

Any data above, I have to add (Insert into select METRICS_TBL METRICS_TBL) at the same table with the records as mentioned below.

2008-08-17 COSTPERPROD-TV 10
08/17/2008-COSTPERPROD-LOG 2
2008-08-17 COST PROD-POSTALMAIL 5

Basically, I need to calculate the cost per product for each category. Depending on the settings available, metric should also be changed as COSTPERPROD and values should be cost/prod under each category.

Can someone help me with the query.

Thank you

Something like this:

INSERT INTO metrics_tbl
(cycle_date, metrics, value)
SELECT cost.cycle_date
         , 'COSTPERPROD-'||cost.mtype
         ,cost.value / prod.value
FROM  (
   select cycle_date,substr(metrics, 1, 4) mtype, substrmetrics,instr(metrics,'-')+1) mmetric
   where substr(metrics, 1, 4) = 'PROD'
   ) prod
INNER JOIN (   select cycle_date,substr(metrics, 1, 4) mtype, substrmetrics,instr(metrics,'-')+1) mmetric
   where substr(metrics, 1, 4) = 'COST'
   ) cost on cost.cycle_date = prod.cycle_date and cost.mmetric = prod.mmetric

Ideally you would divide your METRICS column into two: one for the thing you're measuring (e.g. TV or NEWSPAPER) and the other for the metric (COST, PROD, COSTPERPROD etc.). That's what I did in the views online. Without it, it's kinda a mess and behave so, if the table becomes much more.

HTH

Nigel cordially

Edited by: nthomas on January 14, 2009 15:57 - small correction SQL

Tags: Database

Similar Questions

  • Insert select on the same table: possible without side effects?

    I have a very large table T1 containing millions of records. I need to treat its lines and create a few new lines based on selection.

    Table T1 contains events and one of them, with the code 100, is created by the further development of other events inside the table.

    My code is as follows:

    insert /*+append */ into T1 (code,...) values (100, c1,c2,...)
    select c1,c2... from T1 where (code=20 or code=10) and <other conditions>...
    
    

    as you can see I'm extract T1 lines to insert again in T1 with a different code and I use the direct path in order to get good performance.

    My fear is: choose is made from the same table I risk data loss? In general it is a good practice? Or is it better to create another table?

    Hello

    No I don't think that there may be loss of data. But that may depend on the behavior of the application and your where clause.

    I will explain how it is treated, so you can see if it's ok:

    1. the table is locked because of the insert add, (as)

    2 lines are read by select and make compatible from the State that was at the beginning of the query - 1.

    3 rows are inserted at the end, after the high-water line

    4 columns for new lines are sorted to be merged in the index

    5. high watermark is adjusted - visible new lines and lock is released

    Note that 2. and 3. occur at the same time: rows are inserted all read.

    Note that anyone can choose in the table during the operation - they see the changes committed only - if the State 1.

    all other DML are waiting for the lock being released, and will see new ranks and then

    If you have things that prevent the direct-path insert, append the hint will be ignored. So, if you must rely on close to 1. then the best lock explicitly with table lock. But I don't think that you need.

    Kind regards

    Franck.

  • Update, and select from the same table

    Hello

    I have this selection - I've tested and work

    [code]

    Select
    case
    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTBT
    of other DTF_REEW_201301.KTBT - CTF_REEW_KUM_201301.KTBT
    end

    as KTBT_ISO,

    case
    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTZN
    of other DTF_REEW_201301.KTZN - CTF_REEW_KUM_201301.KTZN
    end

    as KTZN_ISO,

    case
    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTAB
    of other DTF_REEW_201301.KTAB - CTF_REEW_KUM_201301.KTAB

    end as KTAB_ISO,

    DTF_REEW_201301.brnrn,
    DTF_REEW_201301.ktat

    Of

    reewcore. CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq. DTF_REEW_201301 DTF_REEW_201301

    where

    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1).

    [/ code]

    With the result of KTBT_ISO, KTZN_ISO and KTAB_ISO I want to update the table 'reewdq. DTF_REEW_201301' - and this picture is in the select statement.

    I think I've tried every update statement - but no update does not work.

    I need something like this:

    [code]

    Update reewdq. DTF_REEW_201301 set t1 t1. KTBT_ISO =

    (

    Select
    case
    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTBT
    of other DTF_REEW_201301.KTBT - CTF_REEW_KUM_201301.KTBT
    end
    as KTBT_ISO

    Of

    reewcore. CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq. DTF_REEW_201301 DTF_REEW_201301

    where

    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1).

    ),

    T1. KTZN_ISO =

    (

    Select

    case
    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTZN
    of other DTF_REEW_201301.KTZN - CTF_REEW_KUM_201301.KTZN
    end
    as KTZN_ISO

    Of

    reewcore. CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq. DTF_REEW_201301 DTF_REEW_201301

    where

    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1).

    ),

    T1. KTAB_ISO =

    (

    Select
    case
    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTAB
    of other DTF_REEW_201301.KTAB - CTF_REEW_KUM_201301.KTAB
    end as KTAB_ISO

    Of

    reewcore. CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq. DTF_REEW_201301 DTF_REEW_201301

    where

    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1).

    )

    [/ code]

    But this isn´t of the labour code. Someone an idea please? Can someone help me please.

    Best regards

    Heidi

    Use MERGE:

    Fusion

    in reewdq. DTF_REEW_201301 t1

    a_l'_aide_de)

    Select the case sensitive option

    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTBT

    of other DTF_REEW_201301.KTBT - CTF_REEW_KUM_201301.KTBT

    end as KTBT_ISO,

    case

    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTZN

    of other DTF_REEW_201301.KTZN - CTF_REEW_KUM_201301.KTZN

    end as KTZN_ISO,

    case

    When DTF_REEW_201301.KTMO = 1 then DTF_REEW_201301.KTAB

    of other DTF_REEW_201301.KTAB - CTF_REEW_KUM_201301.KTAB

    end as KTAB_ISO,

    reewdq. ROWID that RID

    of reewcore. CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,

    reewdq. DTF_REEW_201301 DTF_REEW_201301

    where DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN

    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT

    and CTF_REEW_KUM_201301.KTMO = DTF_REEW_201301.KTMO - 1

    ) t2

    on)

    T1. ROWID = t2.rid

    )

    When Fachhochschule

    then

    Update

    the t1 value. KTBT_ISO = t2. KTBT_ISO,

    T1. KTZN_ISO = t2. KTZN_ISO,

    T1. KTAB_ISO = t2. KTAB_ISO

    /

    SY.

  • ORA-22992: cannot use LOB Locators selected from the remote tables...

    Oracle 10.2.1.0.4
    Solaris 10

    We try to access a table in another database via a db_link.

    The table we are trying to access has a LOB.

    We get the following error: ora-22992: cannot use LOB Locators selected from the remote tables.

    Is there a way to get around this? We need the data in the BLOB field.

    Thank you.

    See on metalink:

    ORA-22992 has a workaround solution in 10 gr 2
    DOC - ID: 436707.1

    Werner

  • Insert data into the same table based on certain conditions

    Hello. I'm new to this forum.
    I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:

    Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:

    1. if PaidAmount > 0 & & CurrentInstallment < TotalInstallment then

    CurrentInstallment = CurrentInstallment + 1

    2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...

    So, I have to insert data by incrementing the month and year. for example:

    If currentdata is 11/2012 next data will be 12/2012

    But following will be 01, 2013
    I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit on each record selected and insert data and then turns them into table (MYTABLE) even.

    How to achieve that?

    Thank you.

    978184 wrote:
    Hello. I'm new to this forum.
    I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:

    Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:

    1. if PaidAmount > 0 & CurrentInstallment

    CurrentInstallment = CurrentInstallment + 1

    2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...

    So, I have to insert data by incrementing the month and year. for example:

    If currentdata is 11/2012 next data will be 12/2012

    But following will be 01, 2013
    I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit & on each of the selected data record and insert then turns them into table (MYTABLE).

    You can do this way:

    This is not tested, but if you can provide the example of table structure and data (IN create table and insert scripts), it can be put to the test.

    insert into your_table
    (col1, col2, col3...current_installment, month_field)
    select col1, col2, col3..,
           current_installment +
           case when paidamount > 0 and current_installment < total_installment then
            row_number() over (
                                partition by column1, column2,.. columnn      -->You may choose partition if you want the
                                                                              --Increment of Current_installment to reset after particular combination ends
                                order by primary_key        -->Order the Increment, you may choose to add more columns to order by
                              )
          else
            0                                               --> if condition is not met, then Add 0
          end curr_installment,
          add_months(to_date(month_field, 'MM/YYYY'), 1) nxt_month
      from your_table;
    
  • Create the table in select * from the other table

    DB: 11.2.0.2

    How to create a table with structure only not empty the data that we do not generally create table in select * from... But the command will pull the data also. How to create without data?

    create table foo
    in select * bar
    where 1 = 0

  • How can I quickly add a stroke color identical to a filled shape for hundreds of items selected at the same time

    I have an illustration with hundreds small Traoré forms are exactly adjacent. But Illustrator seems to show a small seemed however.

    Is there a way to select all objects of my and have a script their race with the same color as their individual filling?

    Albert

    Why don't you just try using object > path > offset path and use a small number (> 0.005 or more).

  • Compare the records from the same table

    Hi all

    I have this sample, the data were rendered are group by my_id, the same number of records exist for the two my_ids (2 and 62) as:

    create table myTest as
    (
    my_id number, 
    fieldA varchar2, 
    fieldB number, 
    fieldC number, 
    cost_A number, 
    cost_B number
    )
    
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (2, 'MAINT', 60, 5, 10.3, 15.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (2, 'MAINT', 70, 6, 20.3, 25.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (2, 'MAINT', 80, 7, 30.3, 35.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (62, 'MAINT', 60, 5, 10.3, 5.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (62, 'MAINT', 70, 6, 20.3, 25.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (62, 'MAINT', 80, 7, 10.3, 15.00);
    

    How can display the records with numbers of different costs for the same unique key (fieldA, fieldB and FieldC)?

    With the help of Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0.

    I hope that my message is clear.

    Thank you!

    Hello

    user9542267 wrote:

    ... I need all the exits...

    Me too.  Always show the complete, accurate, results you want from the data provided.  If you want 2 rows at the exit point, don't tell you want 1.

    Here are the results you want?

    MY_ID FIELDA, FIELDB, FIELDC OLD_COST_A COST_A OLD_COST_B COST_B

    ------ ---------- ------ ------ ---------- ------ ---------- ------

    MAINT 62 60 5 10.3 10.3 15 5

    MAINT 62 80 7 30.3 10.3 35 15

    If so, here's a way to get them:

    WITH got_old_costs AS

    (

    SELECT fielda, fieldb, fieldc, cost_a, my_id, cost_b

    , LAG (cost_a) OVER (PARTITION BY fielda, fieldb, fieldc)

    ORDER BY my_id

    ) AS old_cost_a

    , LAG (cost_b) OVER (PARTITION BY fielda, fieldb, fieldc)

    ORDER BY my_id

    ) AS old_cost_b

    OF mytest

    WHERE my_id IN (2, 62)

    )

    SELECT my_id, fielda, fieldb, fieldc

    old_cost_a, cost_a

    old_cost_b, cost_b

    OF got_old_costs

    WHERE my_id = 62

    AND (cost_a <> old_cost_a)

    OR cost_b <> old_cost_b

    )

    ORDER BY fielda, fieldb, fieldc

    ;

  • problem of query by comparing records from the same table against each other

    Hi, i'ms truggling to see where I am going wrong here. I have data from cards of following music: -.
    with charts_table as (select 1 id,'oasis' product_name,0801 week, 20 week_chart_position, 20 highest_chart_position from dual
    union select 2,'oasis',0802,14,14 from dual
    union select 3,'oasis',0803,17,14 from dual
    union select 4,'oasis',0804,29,14 from dual
    union select 5,'kings of leon',0801,55,55 from dual
    union select 6,'kings of leon',0802,22,22 from dual
    union select 7,'kings of leon',0803,35,22 from dual
    union select 8,'kings of leon',0804 , 11 , 11  from dual
    union select 9,'bob dylan',0801, 88 , 88  from dual
    union select 10,'bob dylan',0802,79 , 79  from dual
    union select 11,'bob dylan',0803,54,54 from dual
    union select 12,'bob dylan',0804,22,22 from dual
    union select 13,'kid rock',0801,19,19 from dual
    union select 14,'kid rock',0802,24,19 from dual
    union select 15,'kid rock',0803,55,0 from dual
    union select 16,'kid rock',0804,44,0 from dual)
    italic , I need to identify the rogue data where the highest_position is incorrectly registered lower or 0 as there
    position of the highest week was at an earlier date. (stick with me) for example in this kid of rock data initially charted at position 19. What follows
    week (0802) his week_chart_position slipped to 24 and the position the highest card is correctly saved at 19 (ie the week 1). The problem
    is available in week 0803 and 0804 when somehow the data was corrupted and the higest_chart_position is trying to read 0 (instead of 19). How can I write a query to identify this error?

    is the best I have at the moment:-
    select * from charts_table ct1 where 
    nvl2(highest_chart_position,0,99999)>
    (select min(week_chart_position) from charts_table ct2
    where ct2.week<ct1.week
    and ct1.product_name=ct2.product_name)
    but it's not working. can someone help and tell where I'm wrong. Thanks a lot for the research/resolve.

    Ahh, I was suggesting using the lag function to ensure that highest chart position is not fall lower than highest prior chart positions. Your concern is he reports a higher chart position that she never had. In this case I use the MIN function as an analytic function rather than as an aggregate function:

    with t1 as (
      select ct.*
           , min(week_chart_position) over( PARTITION by product_name order by week) highest
        from charts_table ct
       order by product_name, week
    )
    select * from t1 where highest != highest_chart_position;
    

    Conversely, you place your order of cards, which is the highest rank is 1, thew me. I saw the high word and the expected value in the highest chartposition column to be on the rise, but has seen examples of it decreases. It was an oversight on my part.

    Published by: Sentinel on October 9, 2008 08:31

  • Best practices for retrieving a single value from the Oracle Table

    I'm using Oracle Database 11 g Release 11.2.0.3.0.

    I would like to know the best practice to do something like that in a PL/SQL block:

    DECLARE
        v_student_id    student.student_id%TYPE;
    BEGIN
        SELECT  student_id
        INTO    v_student_id
        FROM    student
        WHERE   last_name = 'Smith'
        AND     ROWNUM = 1;
    END;

    Of course, the problem here is that when there is no success, the NO_DATA_FOUND exception is thrown, which interrupts the execution.  So, what happens if I want to continue despite the exception?

    Yes, I could create a block nested with EXCEPTION section, etc, but it seems awkward for what seems to be a very simple task.

    I've also seen this handled like this:

    DECLARE
        v_student_id    student.student_id%TYPE;
        CURSOR c_student_id IS
            SELECT  student_id
            FROM    student
            WHERE   last_name = 'Smith'
            AND     ROWNUM = 1;
    BEGIN
        OPEN c_student_id;
        FETCH c_student_id INTO v_student_id;
        IF c_student_id%NOTFOUND THEN
            DBMS_OUTPUT.PUT_LINE('not found');
        ELSE
            (do stuff)
        END IF;
        CLOSE c_student_id;   
    END;

    But it still seems to kill an Ant with a hammer.

    What is the best way?

    Thanks for any help you can give.

    Wayne

    201cbc0d-57b2-483a-89f5-cd8043d0c04b wrote:

    What happens if I want to continue despite the exception?

    It depends on what you want to do.

    You expect only 0 or 1 rank. SELECT INTO waiting for exactly 1 row. In this case, SELECT INTO may not be the best solution.

    What exactly do you do if you return 0 rows?

    If you want to set a variable with a NULL value and continue the treatment, Frank's response looks good, or else use the modular Billy approach.

    If you want to "do things" when you get a line and 'status quo' when you don't get a line, then you can consider a loop FOR:

    declare
      l_empno scott.emp.empno%type := 7789;
      l_ename scott.emp.ename%type;
    begin
      for rec in (
        select ename from scott.emp
        where empno = l_empno
        and rownum = 1
      ) loop
    l_ename := rec.ename;
        dbms_output.put_line('<' || l_ename || '>');
      end loop;
    end;
    /
    

    Note that when no line is found, there is no output at all.

    Post edited by: StewAshton - Oops! I forgot to put the result in l_ename...

  • Comparison of the 2 columns from the same table

    Mr President.

    I have a table xyz that has 10 million rows

    who has 3 columns

    ProfileId personid fpersonid


    I find on all of the profileids that do not match personid = fpersonid

    is there a way better and faster outside self-join?


    Select a. profileid xyz a, b of xyz where a.personid! = b.fpersonid

    Your SQL is incorrect.

    Just use... . Select xyz profileid where personid! = fpersonid

  • Question: Is foreign key references to a different column in the same table

    Hello

    I'm not grasp this concept. Would you be able to provide the logic how and why you need to create a foreign key that references a column of the same table?

    For example, referencing the schema, SupervisorNo @ here is a FOREIGN KEY to the "EmpNo" column in the same table.

    EMPLOYEE (EmpNo, title, Fname, Lname, phone, Email, date of birth, sex, salary, HireDate, OutNo, SupervisorNo @)


    Why would you want to do this and how can it be used? If you are filling out the data in the table, and this constraint is enabled, you will not be able to load whatever it is because the "EmpNo" column will be empty.


    Any input you can provide me with this would be greatly appreciated. Thank you!



    His name

    Self-referential integrity constraints

    Lets say that we have the table emp with emp_no and mgr_no columns.

    Now all managers should also be an employee too. How can I check this when inserting data into this table? I applied auto integrity constraint. It would help me to make sure no handler (doesn't mean no mgr_no) must be registered if this Manager is not an employee of this organization. Which means, I won't be able to enter any mgr_no in the column until and unless that the same employee also is an employee (emp_no from the same table).

    Check the link as well below.

    Data integrity

    Thank you

    Ishan

  • UPDATE on the same table in the sub query

    DB version: 11.2

    We have a table called SHP_GC_TRACK, which has about 8 million records with partitions. In the below UPDATE, it updates a column based on the SELECT on the same table in a subquery.
    UPDATE shp_gc_track a
       SET f_tran_proc  = 'Y'
     WHERE last_update_date <
              (SELECT MAX (last_update_date)
                 FROM shp_gc_track b
                WHERE a.shp_trx_rowid = b.shp_trx_rowid
                  AND a.c_shp_inst = b.c_shp_inst
                  AND a.f_tran_proc  = b.f_tran_proc 
                  AND b.f_ltr_received = 'D'
                  AND f_rec_code IN ('G', 'W')
                  AND b.f_rec_status = 'B'
                  AND b.c_shp_inst = :b1
                  )
       AND a.c_shp_inst = :b1
       AND a.f_ltr_received = 'D'             -----------------> part of composite index
       AND a.f_tran_proc  = 'N'              -----------------> part of composite index
       AND a.f_rec_code IN ('G', 'W')      --------------> part of composite index  
       AND a.f_rec_status = 'B';              -----------------> part of composite index  
    This UPDATE takes a long time to run and sometimes get hung up.

    We have a composite index on four columns f_ltr_received, f_rec_code, f_rec_status and f_tran_proc. Explain the plan shows that this composite index is used.



    Any way to rewrite this query or suggestion?

    Steve_74 wrote:
    DB version: 11.2

    We have a table called SHP_GC_TRACK, which has about 8 million records with partitions. In the below UPDATE, it updates a column based on the SELECT on the same table in a subquery.

    UPDATE shp_gc_track a
    SET f_tran_proc  = 'Y'
    WHERE last_update_date <
    (SELECT MAX (last_update_date)
    FROM shp_gc_track b
    WHERE a.shp_trx_rowid = b.shp_trx_rowid
    AND a.c_shp_inst = b.c_shp_inst
    AND a.f_tran_proc  = b.f_tran_proc
    AND b.f_ltr_received = 'D'
    AND f_rec_code IN ('G', 'W')
    AND b.f_rec_status = 'B'
    AND b.c_shp_inst = :b1
    )
    AND a.c_shp_inst = :b1
    AND a.f_ltr_received = 'D'             -----------------> part of composite index
    AND a.f_tran_proc  = 'N'              -----------------> part of composite index
    AND a.f_rec_code IN ('G', 'W')      --------------> part of composite index
    AND a.f_rec_status = 'B';              -----------------> part of composite index  
    

    This UPDATE takes a long time to run and sometimes get hung up.

    We have a composite index on four columns f_ltr_received, f_rec_code, f_rec_status and f_tran_proc. Explain the plan shows that this composite index is used.

    Any way to rewrite this query or suggestion?

    Setting updates with subqueries may be difficult: (.) Unfortunately my suggestions below are of the try-it-and-see-what-happens variety - nothing of certain

    First of all, check the index. Is it bitmap or tree? If the tree to see if the more restrictive columns are listed first - this can help with effectiveness of b-tree indexes. Also if the tree a composite bitmap for columns with lots of repeat values instead could help

    Its a correlated subquery so that you cannot run just the subquery first put the result in a scalar varaiable and using the variable in the SQL instead. You can try putting the keys w/join subuqery results in a TWG first to use TWG in SQL to see if I/O is reduced together during these two operations.

    You have the license for the parallel query option? Using parallel DML (this must be activated manually) can help. Check the documentation of the ALTER SESSION command to do so. In addition, the PARALLEL_INDEX() indicator could help

    Display the SQL execution plan

  • Report with multiple columns NUMBER of counts of the same table

    I am new to discoverer, so I'm a little lost.

    I work to create a report to show usage data and Knowledge Base of e-business. I have written using subqueries in SQL query that is in the format:

    Solution number | Soultion title | Solution views. Positive feedback | Negative feedback
    Title of 12345 _ 345 _ 98 34


    The entries 'Views', 'Positive' and 'Negative' are stored in the same table, so I do a count where setid = setid and usedtype = VS, then count where usedtype = usedtype and PF = NF

    Discoverer, I can get the number of solution, the title and THE totals but I can't seem to understand how to get an ACCOUNT for three different things from the same table in the columns on the same line.

    When I go on change map-> select the items once I select the option NUMBER of the UsedType column in the CS_KB_SET_USED_HISTS table, I can't select it again. I also found way now to add a column based on a query entered.

    If someone could help it would be much appreciated.

    Thank you

    Published by: Toolman21 on December 2, 2010 14:17
    _ to correct spacing added.

    Hello
    You can separate the column with a case or decode.
    for example to create 2 calculations:

    case
    When usedtype = "PF".
    then - that contain both
    0 otherwise
    end

    case
    When usedtype = 'NF '.
    then - that contain both
    0 otherwise
    end

    After that, you can create the aggregation count on those.

    Tamir

  • FRM - 40202:Field must be entered on two blocks with the same table

    I have two blocks, blockA and blockB, both from the same table that is tableX.

    When I ask of blockA and it worked, then I go to blockB and modify data, and save, there is no problem. But when I do not run the query of blockA or if the query did not return any results, I go to blockB and change some data then save, I got this error. The cursor then go to first blockA point. So now, I have to delete this empty line before the Save.


    Any suggestion?

    you set a few initial values programmatically for a block?
    in this case, the status changes to INSERT and you will get this message.
    You can check the staus with GET_RECORD_PROPERTY (1, "A BLOCK", STATUS), e.g. with the trigger KEY-COMMIT.

Maybe you are looking for

  • DesignJet 350 c E/A0

    My Chartplotter goes all the Service Mode, we test still fails when loading the roll paper. It goes through all the usual steps to advance the paper, etc. Then feeding roller reverse and spit the paper. The LEDs indicate then 1259 bit that I can't fi

  • Mobile data turn power switch on the second user profile

    HelloI just put a second user profile on my Xperia z3 compact for my girlfriend, she's going to borrow the phone for a few weeks, but I can't find an option to enable mobile data using his profile.If I turn my profile and then go to hers, she'll have

  • Error Code 800706BE when installing Windows Live Essentials 2011 update

    Original title: 800706BE error Code I installed the latest update of Windows Live Essentials 2011 windows. Part of the way in which the process, I was asked what I wanted to download and I chose the minimum download which has been downloaded and inst

  • DVD writer prob

    I have a dvd writer what tray comes out sometime sometimes not it crashes any solution to free up the movement of the status bar.

  • Lightroom 6.5 error "?: 0: try calling transnational" private_initPDFL'(a nil value) "after the creation of a book.

    I upgraded to Lightroom 6.5 it worked fine until I tried to make a book.I got the error "? : 0: try calling transnational ' private_initPDFL'(a nil value).This error will not erase and appears as soon as I open Lightroom.  Thus, no Lightroom