Need a help in query

Hi,
It' s duplicate thread...deleted
Edited by: user586 on Mar 23, 2011 9:42 AM

Hi,
You should do two regular expression operations.
First, extract just the part of the string that is between the parentheses. Use that substring, and not the full string, in the rest of the query.
After that, you can use REGEXP_SUBSTR the way you were doing.
You should devise a way to test all your strings at once, without having to type the same string more than once.
I used this table to test:
CREATE TABLE     table_x
(      txt     VARCHAR2 (40)
INSERT INTO table_x (txt) VALUES ('TECHPKG(INTELLI CC+FRT SONAR)');
INSERT INTO table_x (txt) VALUES ('PWRPKG(P/W+P/L+CC)');Here's my solution:
WITH   got_paren_txt     AS
     SELECT     REGEXP_REPLACE ( txt
                      , '^.*\((.*)\).*$'
                      , '\1'
                      )     AS paren_txt
     FROM    table_x
,       got_item_cnt AS
     SELECT     PAREN_txt
     ,     1 + LENGTH (paren_txt)
            - LENGTH ( REPLACE ( paren_txt
                                  , '+'
                  )     AS item_cnt
     FROM    got_paren_txt
,     cntr     AS
     SELECT     LEVEL     AS n
     FROM     (
               SELECT  MAX (item_cnt)     AS max_item_cnt
               FROM     got_item_cnt
     CONNECT BY     LEVEL     <= max_item_cnt
SELECT       i.paren_txt
,       c.n
,       REGEXP_SUBSTR ( i.paren_txt
                       , '[^+]+'
               , 1
               , c.n
               )     AS item
FROM       got_item_cnt  i
JOIN       cntr          c  ON   c.n  <= i.item_cnt
ORDER BY  i.paren_txt
,            c.n
;and its output:
PAREN_TXT                               N ITEM
INTELLI CC+FRT SONAR                    1 INTELLI CC
INTELLI CC+FRT SONAR                    2 FRT SONAR
P/W+P/L+CC                              1 P/W
P/W+P/L+CC                              2 P/L
P/W+P/L+CC                              3 CCThis assumes that each string will contain a '(', followed by a ')'. If you can have multiple sets of parentheses in the same string, the query above can be adjusted. Post some sample data that shows what kinds of strings you might need to handle, and the results you want from them.
Whenever you post a question, say what version of Oracle you're using. The query above will work in Oracle 10, but it could be simplified in Oracle 11 using REGEXP_COUNT and the new version of REGEXP_SUBSTR.

Similar Messages

  • Friends need ur help in query

    SELECT      AL_ID,AL_CAPTION FROM ALB WHERE AL_MEMBERID=8
    UNION      
    SELECT      VD_ID,VD_CAPTION FROM VDSF WHERE VD_MEMBERID=8
    ORDER BY 2;
    This is my result set for the query
    3     Bunch
    4     New
    5     falss
    Actually it displays in the Order by Case Sensitive, i want it in the order
    3     Bunch
    5     falss
    4     New
    Is this possible, if then please help without changing the Case Sensitive of the Data
    Thanks,
    Dick...

    Hey I think the only problem with your query was use of same name
    select AL_ID,AL_CAPTION
    from
    SELECT AL_ID,AL_CAPTION FROM ALB WHERE AL_MEMBERID=8
    UNION
    SELECT VD_ID,VD_CAPTION FROM VDSF WHERE VD_MEMBERID=8
    ORDER BY upper(AL_CAPTION);
    AL_ID and AL_CAPTION .So an alias is needed for order by otherwise It will confuse AL_CAPTION as the AL_CAPTION inside from().

  • Need Tuning help in query

    Hi,
    I have aquery which looks like this
    CREATE TABLE BKP3
    PARALLEL(DEGREE 4 INSTANCES 1)
    NOLOGGING
    AS
    SELECT /* + PARALLEL(4,1) */ *
    FROM BKP2 A
    WHERE A.COL1 NOT IN (SELECT /* + PARALLEL(4,1) */ COL1
    FROM BKP1)
    AND A.COL2 NOT IN (SELECT /* + PARALLEL(4,1) */ COL2
    FROM BKP1)
    AND ROWNUM<=5000000;
    Table BKP1 holds more than 5million rows and table BKP2 holds more than 60million rows.
    This query is very slow. Is there any way i can improve the performance.
    Kindly help.

    > I dont know how but somehow i am unable to run the explain plan.
    What have you tried and what error did you get?
    What is your Oracle version?
    In 10g I think sys.plan_table$ is granted public access by default. Try using this handy Explain Plan script in SQL*Plus:
    www.williamrobertson.net/code/xplan.sql

  • Need some help with query

    Hey all, I have the following scenario,
    Table A
    Column1
    2
    3
    5
    Table B
    Column2
    7
    5
    4
    Table C
    Column1, Column2
    2,7
    3,8
    5,10
    So basically I need to compare in a way that the combination of the values in A AND B match the recordset in C as such,
    select column1, column2 from Table A, Table B
    where a combination of both those columns exists in Table C. Therefore in the above example, this query should return "2,7" as the output. Any ideas would be appreciated.

    This should do?
    SQL> select c.col1, c.col2
      2  from c
      3  where (c.col1, c.col2) in (select col1, col2
      4                            from (select c.col1 col1
      5                                  from C, a
      6                                  where c.col1 = a.col1) q1
      7                                ,(select c.col2 col2
      8                                  from C, b
      9                                  where c.col2 = b.col1) q2
    10                            )
    11  /
          COL1       COL2
             2          7Cheers
    Sarma.

  • Need urgent help with query....

    i need to print loc field with it but the logic is get ti loc code where the month is maximum...
    Need output like this
    K  Loc            M_1        M_2        M_3        M_4        M_5        M_6
    A   1     2.5        4.5          0          0          0          0
    B   4        0          0          0          0        2.5          0
    C  3       2.5        2.5        2.5        2.5        2.5        2.5
    drop table y;
    create table y( key char(1),
              loc number,
              month char(2),
              amnt number);
    insert into y values('A',2,'01',2.50);
    insert into y values('A',1,'02',4.50);
    insert into y values('B',4,'05',2.50);
    insert into y values('C',2,'01',2.50);
    insert into y values('C',8,'02',2.50);
    insert into y values('C',3,'03',2.50);
    insert into y values('C',3,'04',2.50);
    insert into y values('C',3,'05',2.50);
    insert into y values('C',3,'06',2.50);
    commit ;
    select key
    ,sum(decode(month,'01',amnt,0)) m_1
    ,sum(decode(month,'02',amnt,0)) m_2
    ,sum(decode(month,'03',amnt,0)) m_3
    ,sum(decode(month,'04',amnt,0)) m_4
    ,sum(decode(month,'05',amnt,0)) m_5
    ,sum(decode(month,'06',amnt,0)) m_6
    from y
    group by key;
    SQL> select key
      2  ,sum(decode(month,'01',amnt,0)) m_1
      3  ,sum(decode(month,'02',amnt,0)) m_2
      4  ,sum(decode(month,'03',amnt,0)) m_3
      5  ,sum(decode(month,'04',amnt,0)) m_4
      6  ,sum(decode(month,'05',amnt,0)) m_5
      7  ,sum(decode(month,'06',amnt,0)) m_6
      8  from y
      9  group by key;
    K        M_1        M_2        M_3        M_4        M_5        M_6
    A        2.5        4.5          0          0          0          0
    B          0          0          0          0        2.5          0
    C        2.5        2.5        2.5        2.5        2.5        2.5

    Well, maybe I'm lucky to understand here ?
    SQL> select
    2   key
    3  ,max(loc) keep (dense_rank last order by
    amnt,month) loc
    4  ,sum(decode(month,'01',amnt,0)) m_1
    5  ,sum(decode(month,'02',amnt,0)) m_2
    6  ,sum(decode(month,'03',amnt,0)) m_3
    7  ,sum(decode(month,'04',amnt,0)) m_4
    8  ,sum(decode(month,'05',amnt,0)) m_5
    9  ,sum(decode(month,'06',amnt,0)) m_6
    10  from y
    11  group by key;
    K        LOC        M_1        M_2        M_3
    M_4        M_5        M_6
    A          1        2,5        4,5          0
    0          0          0
    4          0          0          0          0
    2,5          0
    3        2,5        2,5        2,5        2,5
    2,5        2,5Nicolas.
    This should be more a question for SQL and PL/SQL
    Forum :
    PL/SQL
    start=0
    Message was edited by:
    N. GasparottoPerfect..... many thanks... and i am sorry i put this in this forum rather than in SQL/PLSQL... but you are the best!!
    thanks to all of you..

  • I need a help in query

    Dears,
    i want to create a report which shall work on OU basis, and the output should be as:
    ORG_NAME  SUB_INVENTORY_CODE     SUB_INVENTORY_NAME     CUSTOMER_NUMBER     CUSTOMER_NAME     ORDER_TYPE_NAME
    any help ?

    Dears,
    i want to create a report which shall work on OU basis, and the output should be as:
    ORG_NAME  SUB_INVENTORY_CODE     SUB_INVENTORY_NAME     CUSTOMER_NUMBER     CUSTOMER_NAME     ORDER_TYPE_NAME
    any help ?

  • I need a help with query

    hello all,
    {code}
    create table balance
    (open_balance  number(4)
    ,qty_in                   number(4)
    ,qty_out                number(4)
    insert into balance values (200,1,0);
    insert into balance values ('',0,-25);
    insert into balance values ('',0,-20);
    {code}
    i need a result like this
    {code}
    OPEN_BALANCE QTY_IN QTY_OUT RESULT
             200      1       0    201
                      0     -25    185
                      0     -20    165
    {code}

    Hi,
    u0597684 wrote:
    hello all,
    {code}
    create table balance
    (open_balance  number(4)
    ,qty_in                   number(4)
    ,qty_out                number(4)
    insert into balance values (200,1,0);
    insert into balance values ('',0,-25);
    insert into balance values ('',0,-20);
    {code}
    i need a result like this
    {code}
    OPEN_BALANCE QTY_IN QTY_OUT RESULT
             200      1       0    201
                      0     -25    185
                      0     -20    165
    {code}
    There is no built-in order to rows in a relational table.  I assume you have some other column that tells what order the rows are in, like this:
    CREATE TABLE  balance
    ( open_balance  NUMBER (4)
    , qty_in        NUMBER (4)
    , qty_out       NUMBER (4)
    , trans_dt DATE
    insert into balance (open_balance, qty_in, qty_out, trans_dt) values (200,  1,  0,  DATE '2013-05-31');
    insert into balance (open_balance, qty_in, qty_out, trans_dt) values (NULL, 0, -25, DATE '2013-06-07');
    insert into balance (open_balance, qty_in, qty_out, trans_dt) values (NULL ,0, -20, DATE '2013-06-14');
    This looks like a job for the analytic SUM function.
    Here's one way:
    SELECT    b.*
    ,   SUM ( NVL (open_balance, 0)
           + qty_in
           + qty_out
           ) OVER (ORDER BY trans_dt) AS result
    FROM      balance  b
    ORDER BY  trans_dt
    The results are slightly different from what you posted:
    OPEN_BALANCE     QTY_IN    QTY_OUT TRANS_DT        RESULT
             200          1          0 31-May-2013        201
                          0        -25 07-Jun-2013        176
                          0        -20 14-Jun-2013        156
    If you really want the results you requested, please explain how you get them.

  • Need small help in query

    Hi,
    Cancel the request. i have resolved its my own.
    Thanks for all your help...
    Edited by: user586 on Oct 31, 2011 7:42 PM

    Learn about the Workspace Management functions ... demo here:
    http://www.morganslibrary.org/reference/wm_functions.html
    It is best to not reinvent the wheel.

  • Help needed to optimize the query

    Help needed to optimize the query:
    The requirement is to select the record with max eff_date from HIST_TBL and that max eff_date should be > = '01-Jan-2007'.
    This is having high cost and taking around 15mins to execute.
    Can anyone help to fine-tune this??
       SELECT c.H_SEC,
                    c.S_PAID,
                    c.H_PAID,
                    table_c.EFF_DATE
       FROM    MTCH_TBL c
                    LEFT OUTER JOIN
                       (SELECT b.SEC_ALIAS,
                               b.EFF_DATE,
                               b.INSTANCE
                          FROM HIST_TBL b
                         WHERE b.EFF_DATE =
                                  (SELECT MAX (b2.EFF_DATE)
                                     FROM HIST_TBL b2
                                    WHERE b.SEC_ALIAS = b2.SEC_ALIAS
                                          AND b.INSTANCE =
                                                 b2.INSTANCE
                                          AND b2.EFF_DATE >= '01-Jan-2007')
                               OR b.EFF_DATE IS NULL) table_c
                    ON  table_c.SEC_ALIAS=c.H_SEC
                       AND table_c.INSTANCE = 100;

    To start with, I would avoid scanning HIST_TBL twice.
    Try this
    select c.h_sec
         , c.s_paid
         , c.h_paid
         , table_c.eff_date
      from mtch_tbl c
      left
      join (
              select sec_alias
                   , eff_date
                   , instance
                from (
                        select sec_alias
                             , eff_date
                             , instance
                             , max(eff_date) over(partition by sec_alias, instance) max_eff_date
                          from hist_tbl b
                         where eff_date >= to_date('01-jan-2007', 'dd-mon-yyyy')
                            or eff_date is null
               where eff_date = max_eff_date
                  or eff_date is null
           ) table_c
        on table_c.sec_alias = c.h_sec
       and table_c.instance  = 100;

  • Need Help to query Lync Database for User Information

    Need Help to Query the lync database to retrieve below user information.
    1. SIP Address of the registered user
            2. Phone Number configured to the particular account.
            3. IP Address
           4. Last Logged in time.
    I am trying to pull the above information from rtc database for all the registered users. Please let me know if this is possible and it would be great if you can throw some light on what tables to look for the data. Thank You.

    Hi,
    For SIP address and Phone number you can check RTC database.
    IP Address:
    You can refer to the link below to query IP address: 
    http://h30499.www3.hp.com/t5/Business-Service-Management-BAC/Monitoring-Lync-with-the-User-Registrations-Viewer-Free-NMC-tool/ba-p/5961497#.UtOU43mIrwo
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
    Last Logged in time:
    You can refer to the link below:
    http://blogs.technet.com/b/dodeitte/archive/2011/05/11/how-to-get-the-last-time-a-user-registered-with-a-front-end.aspx
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • I need to pass a query in form of string to DBMS_XMLQUERY.GETXML package...the parameters to the query are date and varchar ..please help me..

    I need to pass a query in form of string to DBMS_XMLQUERY.GETXML package...the parameters to the query are date and varchar ..please help me build the string .Below is the query and the out put. ( the string is building fine except the parameters are with out quotes)
    here is the procedure
    create or replace
    procedure temp(
        P_MTR_ID VARCHAR2,
        P_FROM_DATE    IN DATE ,
        P_THROUGH_DATE IN DATE ) AS
        L_XML CLOB;
        l_query VARCHAR2(2000);
    BEGIN
    l_query:=  'SELECT
        a.s_datetime DATETIME,
        a.downdate Ending_date,
        a.downtime Ending_time,
        TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
        TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
        TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
      FROM
        (SELECT s_datetime + .000011574 s_datetime,
          TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
          DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
          ||'mi''), ''00:'
          ||'00'',''24:'
          ||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
          ||'mi'')) downtime,
          s_usage downusage,
          s_cost downcost
        FROM summary_qtrhour
        WHERE s_mtrid = '
        ||P_MTR_ID||
       ' AND s_mtrch   = ''1''
        AND s_datetime BETWEEN TO_DATE('
        ||P_FROM_DATE||
        ',''DD-MON-YY'') AND (TO_DATE('
        ||P_THROUGH_DATE||
        ',''DD-MON-YY'') + 1)
        ) a,
        (SELECT s_datetime + .000011574 s_datetime,
          s_usage downusage
        FROM summary_qtrhour
        WHERE s_mtrid = '
        ||P_MTR_ID||
        ' AND s_mtrch   = ''2''
        AND s_datetime BETWEEN TO_DATE('
        ||P_FROM_DATE||
        ',''DD-MON-YY'') AND (TO_DATE('
        ||P_THROUGH_DATE||
        ','' DD-MON-YY'') + 1)
        ) B
      where a.S_DATETIME = B.S_DATETIME(+)';
    SELECT DBMS_XMLQUERY.GETXML('L_QUERY') INTO L_XML   FROM DUAL;
    INSERT INTO NK VALUES (L_XML);
    DBMS_OUTPUT.PUT_LINE('L_QUERY IS :'||L_QUERY);
    END;
    OUTPUT parameters are in bold (the issue is they are coming without single quotes otherwise th equery is fine
    L_QUERY IS :SELECT
        a.s_datetime DATETIME,
        a.downdate Ending_date,
        a.downtime Ending_time,
        TO_CHAR(ROUND(a.downusage,3),'9999999.000') kWh_Usage,
        TO_CHAR(ROUND(a.downcost,2),'$9,999,999.00') kWh_cost,
        TO_CHAR(ROUND(B.DOWNUSAGE,3),'9999999.000') KVARH
      FROM
        (SELECT s_datetime + .000011574 s_datetime,
          TO_CHAR(S_DATETIME ,'mm/dd/yyyy') DOWNDATE,
          DECODE(TO_CHAR(s_datetime+.000011574 ,'hh24:mi'), '00:00','24:00', TO_CHAR(s_datetime+.000011574,'hh24:mi')) downtime,
          s_usage downusage,
          s_cost downcost
        FROM summary_qtrhour
        WHERE s_mtrid = N3165 AND s_mtrch   = '1'
        AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,'DD-MON-YY') + 1)
        ) a,
        (SELECT s_datetime + .000011574 s_datetime,
          s_usage downusage
        FROM summary_qtrhour
        WHERE s_mtrid = N3165 AND s_mtrch   = '2'
        AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,' DD-MON-YY') + 1)
        ) B
      where a.S_DATETIME = B.S_DATETIME(+)

    The correct way to handle this is to use bind variables.
    And use DBMS_XMLGEN instead of DBMS_XMLQUERY :
    create or replace procedure temp (
      p_mtr_id       in varchar2
    , p_from_date    in date
    , p_through_date in date
    is
      l_xml   CLOB;
      l_query VARCHAR2(2000);
      l_ctx   dbms_xmlgen.ctxHandle;
    begin
      l_query:=  'SELECT
        a.s_datetime DATETIME,
        a.downdate Ending_date,
        a.downtime Ending_time,
        TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
        TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
        TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
      FROM
        (SELECT s_datetime + .000011574 s_datetime,
          TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
          DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
          ||'mi''), ''00:'
          ||'00'',''24:'
          ||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
          ||'mi'')) downtime,
          s_usage downusage,
          s_cost downcost
        FROM summary_qtrhour
        WHERE s_mtrid = :P_MTR_ID
        AND s_mtrch   = ''1''
        AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
                           AND (TO_DATE(:P_THROUGH_DATE,''DD-MON-YY'') + 1)
        ) a,
        (SELECT s_datetime + .000011574 s_datetime,
          s_usage downusage
        FROM summary_qtrhour
        WHERE s_mtrid = :P_MTR_ID
        AND s_mtrch   = ''2''
        AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
                           AND (TO_DATE(:P_THROUGH_DATE,'' DD-MON-YY'') + 1)
        ) B
      where a.S_DATETIME = B.S_DATETIME(+)';
      l_ctx := dbms_xmlgen.newContext(l_query);
      dbms_xmlgen.setBindValue(l_ctx, 'P_MTR_ID', p_mtr_id);
      dbms_xmlgen.setBindValue(l_ctx, 'P_FROM_DATE', to_char(p_from_date, 'DD-MON-YY'));
      dbms_xmlgen.setBindValue(l_ctx, 'P_THROUGH_DATE', to_char(p_through_date, 'DD-MON-YY'));
      l_xml := dbms_xmlgen.getXML(l_ctx);
      dbms_xmlgen.closeContext(l_ctx);
      insert into nk values (l_xml);
    end;

  • Help needed in writing a query

    Hi all,
    Following is the structure of my table.
    Data
    Key Number
    Id Number
    Value varchar2(100)
    activity_name varchar2(100)
    Creation_Date Date
    Eval_Point varchar2(100)
    In the above table Id is the primary key.
    The column eval_point holds only two types of entries 'activation' or 'completion'
    The activity_name column holds the name of the activity.
    The sample entries in the table are as follows
    Key Value activity_name Creation_Date Id Eval_Point
    260002 XXX assign_1 2007-09-21 16:58:41.920000 951 activation
    260002     XXX assign_1 2007-09-21 16:58:43.392000 953     completion
    260002     XXX assign_2 2007-09-21 16:59:03.732000 956     activation
    260002     XXX assign_2 2007-09-21 16:59:04.112000 954     completion
    260002     XXX assign_3 2007-09-21 16:59:24.331000     958     activation
    260002     XXX assign_3 2007-09-21 16:59:24.421000     957     completion
    i need to write a query which gives me data in the following format
    value id start_date end_date
    XXX YYY 2007-09-21 16:58:41.920000 2007-09-21 16:58:43.392000
    where start_date is the creation date of the 'activation' and end_date is the creation_date of 'completion'.
    Can somebody help?
    -thanks
    lavanya

    hello all,
    I would like to re frame my question.
    this is the output of the base query
    select id,instance_key,sensor_target,activity_sensor,creation_date,eval_point from bpel_variable_sensor_values where instance_key=260002;
    953     260002     Assign_1     952     2007-09-21 16:58:43.392000     completion
    951     260002     Assign_1     952     2007-09-21 16:58:41.920000     activation
    956     260002     Assign_2     955     2007-09-21 16:59:03.732000     activation
    954     260002     Assign_2     955     2007-09-21 16:59:04.112000     completion
    958     260002     Assign_3     959     2007-09-21 16:59:24.331000     activation
    957     260002     Assign_3     959     2007-09-21 16:59:24.421000     completion
    962     260002     Assign_4     960     2007-09-21 16:59:44.741000     completion
    961     260002     Assign_4     960     2007-09-21 16:59:44.640000     activation
    964     260002     Assign_5     965     2007-09-21 17:00:05.290000     completion
    963     260002     Assign_5     965     2007-09-21 17:00:04.950000     activation
    I am trying out this query
    select a.instance_key,a.creation_date,b.creation_date,a.id
    from bpel_variable_sensor_values a, bpel_variable_sensor_values b
    where a.instance_key=b.instance_key
    and a.instance_key=260002
    and a.eval_point='activation'
    and b.eval_point='completion'
    and i am getting 25 entries i.e a cartesian product of a.creation_date
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:58:43.392000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:59:04.112000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:59:24.421000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 16:59:44.741000     951
    260002     2007-09-21 16:58:41.920000     2007-09-21 17:00:05.290000     951
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:58:43.392000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:59:04.112000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:59:24.421000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 16:59:44.741000     956
    260002     2007-09-21 16:59:03.732000     2007-09-21 17:00:05.290000     956
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:58:43.392000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:59:04.112000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:59:24.421000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 16:59:44.741000     958
    260002     2007-09-21 16:59:24.331000     2007-09-21 17:00:05.290000     958
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:58:43.392000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:59:04.112000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:59:24.421000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 16:59:44.741000     961
    260002     2007-09-21 16:59:44.640000     2007-09-21 17:00:05.290000     961
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:58:43.392000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:59:04.112000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:59:24.421000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 16:59:44.741000     963
    260002     2007-09-21 17:00:04.950000     2007-09-21 17:00:05.290000     963
    can soembody help me to reduce these to 5 rows.

  • Help needed in tuning a query

    Hi,
    I need some help in performing tuning of a big query. Explain plan is as under:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    Edited by: AbdulHadi on Sep 16, 2011 3:56 PM
    Edited by: AHadi on Sep 19, 2011 10:02 AM

    3     SORT GROUP BY          47916     25M     491G     15M (3)     17:30:31               
    4     VIEW          870M     445G          15M (2)     17:24:08               
    5     HASH GROUP BY          870M     427G     885G     15M (2)     17:24:08               
    In above steps its using very high temporary tablespace usage. please try to tune your query.
    - dynamic sampling used for this statement
    The statistics appears to be stale.

  • Need some help with the Select query.

    Need some help with the Select query.
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    select single vkorg abgru from ZADS into it_rej.
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
            VKORG TYPE VBAK-VKORG,
            ABGRU TYPE VBAP-ABGRU,
           END OF IT_REJ.
    This is causing performance issue. They are asking me to include the where condition for this select query.
    What should be my select query here?
    Please suggest....
    Any suggestion will be apprecaiated!
    Regards,
    Developer

    Hello Everybody!
    Thank you for all your response!
    I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table 
    select vkorg abgru from ZADS into it_rej.
    Earlier :
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    Now :
    DATA : BEGIN OF IT_REJ occurs 0,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    I guess this will fix the issue correct?
    PLease suggest!
    Regards,
    Developer.

  • Need help in query to have all items in sap with PO data on order, date

    Hello Everyone,
    I need some help in writing a query to show all items in sap db to have itemcode, itemname, onhand, sellable(onhand-committed), on order, and the delivery date when that time should be received.  I need to know what items are regular items, which ones are master and components.  For the master I need to have the deliver date of the PO for the component.
    I have written this.
    SELECT DISTINCT TOP (100) PERCENT T1.ItemCode, SUM(T1.Sellable) AS Sellable, T1.OnOrder, MAX(T1.Docduedate) AS DeliveryDate, T1.WhsCode
    FROM         (SELECT     ItemCode, Sellable, OnOrder, '1/1/1900' AS Docduedate, WhsCode
                           FROM          dbo.V_RAZ_StoreInv
                           UNION ALL
                           SELECT     TOP (100) PERCENT ItemCode, '0' AS Sellable, Quantity AS Onorder, DocDueDate, WhsCode
                           FROM         dbo.V_RAZ_OPENPOSDATA
                           ORDER BY ItemCode) AS T1 LEFT OUTER JOIN
                          dbo.V_RAZ_ItemInfo ON T1.ItemCode = dbo.V_RAZ_ItemInfo.ItemCode
    GROUP BY T1.ItemCode, T1.OnOrder, T1.WhsCode, dbo.V_RAZ_ItemInfo.OnHold
    HAVING      (dbo.V_RAZ_ItemInfo.OnHold = 'n')
    ORDER BY T1.ItemCode, T1.WhsCode
    and for the v_raz_openposdata I have the following query
    SELECT     dbo.OPOR.DocNum, dbo.OPOR.DocStatus, dbo.POR1.WhsCode, dbo.POR1.ItemCode, dbo.POR1.Dscription, dbo.POR1.Quantity, dbo.POR1.OpenQty,
                          dbo.POR1.LineStatus, dbo.OPOR.DocDueDate
    FROM         dbo.OPOR LEFT OUTER JOIN
                          dbo.POR1 ON dbo.OPOR.DocEntry = dbo.POR1.DocEntry
    WHERE     (dbo.OPOR.DocStatus = 'O')
    Any help is greatly appreciated. 
    Right now I do get the delivery date for regular items and components but the master sku for the component all of them have 1/1/1900. 
    Thank you

    Thank you for replying Gordon.  I did not remember I had asked this before.  I no longer have access to the other account. 
    What I need on the query is that I want  a list of items with the on order quantity and when we are expecting this order to be received.  The receiving date is based on the PO delivery date.  The trick here is that  I need to Master sku to show the delivery date of the component sku.  In my scenario all components have the same delivery date for the Master sku.  If there are mulitple delivery dates because each warehouse is getting them on a different date then I want to get the delivery date for that warehouse.
    Let me know if this is possible and if yes please guide towards a query for it.
    Thank you.

Maybe you are looking for

  • How do you switch between web server snapshot jpg and png modes?

    I read in another forum a posting by "NathanK" stating: "The snapshot feature of the web server can generate images either as png or jpg. In LabVIEW 8.6 and later, the default which is generated by the web publishing tool is the png format. In this m

  • The lack of details and customer service.

    After less than one month of ownership, my Ideapad K1 power button broke. After talking to a customer service rep (K). She informed me it will have to be returned to Lenovo for repair, which will take about 7 to 10 business days from time of delivery

  • Comparing OS X Leopard to Windows Vista...

    I saw Windows Vista for the first time this weekend and while the first thing I noticed was that many of the features were taken straight from Mac (ex: Expose or the Apple+Tab feature) there was one thing that I noticed Vista had, that Mac did not -

  • Filled area on left or right side of path – make path clockwise - reverse path

    Hello, for a script I'm writing, which will select path points at specific angles (all angles with less than 180°) I need to know, if the inner part of my shape (namely the filled area) is to the left or to the right regarding the direction the path

  • How to work with low quality offline media efficiently?

    I have a late 2013 rMBP with an NVIDA GPU that is a fantastic platform for editing when I am travelling. The downside is that it doesn't have allot of storage and when I have high bit rate material it can struggle. I often shoot DNxHD 220 on an Atomo