Need some help over sql query format

Input :
TABLE 1 ppl
id name
1 ravi
2 andy
3 john
TABLE 2 fa_ppl
id attr_name attr_value
1 watch Guess
1 laptop Sony
2 fashion casual
2 laptop Dell
3 watch fossil
3 fashion formal
OUTPUT Required:(3 rows)
name watch laptop fashion
ravi guess sony NULL
andy NULL dell casual
john fossil NULL formal
SQL Statements that may help in schema objects:
create table ppl(id number,name varchar2(50));
create table fa_ppl(id number,attr_name varchar2(20), attr_value varchar2(20));
insert into ppl values(1,'ravi');
insert into ppl values(2,'andy');
insert into ppl values(3,'john');
insert into fa_ppl values(1,'laptop','sony');
insert into fa_ppl values(1,'watch','guess');
insert into fa_ppl values(2,'laptop','dell');
insert into fa_ppl values(2,'fashion','casual');
insert into fa_ppl values(3,'fashion','formal');
insert into fa_ppl values(3,'watch','fossil');
I tried in the below way:
Select P.name,
case when attr_name='fashion' then attr_value end as fashion ,
case when attr_name='laptop' then attr_value end as laptop,
case when attr_name='watch' then attr_value end as watch,
from ppl P join fa_ppl F on (P.id=F.id and F.attr_name in ('fashion','laptop','watch'))
PROBLEM:
Getting separate rows(6 rows in my case) for each attribute_value.
Thanks a lot.....

What you are trying is a pivot. There is a [url https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360005]thread in the FAQ linking to various methods.
You are actually pretty close, if you just do a group by on your select:
Select P.name,
max(case when attr_name='fashion' then attr_value end) as fashion ,
max(case when attr_name='laptop' then attr_value end) as laptop,
max(case when attr_name='watch' then attr_value end) as watch
from ppl P join fa_ppl F on (P.id=F.id and F.attr_name in ('fashion','laptop','watch'))
group by
p.nameBut if you have several people with same name, you probably want to do this:
Select
p.id, /*you may omit this column if you do not need it*/
max(P.name) as name,
max(case when attr_name='fashion' then attr_value end) as fashion ,
max(case when attr_name='laptop' then attr_value end) as laptop,
max(case when attr_name='watch' then attr_value end) as watch
from ppl P join fa_ppl F on (P.id=F.id and F.attr_name in ('fashion','laptop','watch'))
group by
p.idSimilar can be done in 11G with the PIVOT statement. See the links in the FAQ thread.

Similar Messages

  • Need a help in SQL query

    Hi,
    I need a help in writing an SQL query . I am actually confused how to write a query. Below is the scenario.
    CREATE TABLE demand_tmp
    ( item_id  NUMBER,
      org_id   NUMBER,
      order_line_id NUMBER,
      quantity NUMBER,
      order_type NUMBER
    CREATE TABLE order_tmp
    ( item_id  NUMBER,
       org_id   NUMBER,
       order_line_id NUMBER,
       open_flag  VARCHAR2(10)
    INSERT INTO demand_tmp
    SELECT 12438,82,821,100,30 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,849,350,30 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,NULL,150,29 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,0,50,-1 FROM dual;
    INSERT INTO order_tmp
    SELECT 12438,82,821,'Y' FROM dual;
    INSERT INTO order_tmp
    SELECT 12438,82,849,'N' FROM dual;
    Demand_tmp:
    Item_id        org_id   order_line_id       quantity       order_type     
    12438     82                 821                 100       30     
    12438     82                 849                 350       30     
    12438     82              NULL                 150       29     
    12438     82                    0                  50       -1     
    Order_tmp :
    Item_id        org_id        order_line_id      open_flag     
    12438     82                  821                Y     
    12438     82                  849                N     I need to fetch the records from demand_tmp table whose order_line_id is present in order_tmp and having open_flag as 'Y' or if order_type in demand_tmp table is 29.
    The below query will give the records whose order line id is present in order_tmp. But, If i need records which are having order_type=29 the below query wont return any records as order_line_id is NULL. If I place outer join I will get other records also (In this example order_type -1 records) . Please help me how can we write a query for this. Expected o/p is below.
    Query :
    Select item_id,org_id,order_line_id,quantity,order_type,open_flag
    from demand_tmp dt , order_tmp ot
    where dt.order_line_id = ot.order_line_id
    AND dt.item_id=ot.item_id
    AND dt.org_id = ot.org_id
    AND ot.open_flag = 'Y';
    Expected Output :                         
    item_id     org_id     order_line_id     quantity     order_type   open_flag
    12438     82                 821               100                    30             Y
    12438     82              NULL               150                29         NULL Thanks in advance,
    Rakesh
    Edited by: Venkat Rakesh on Oct 7, 2012 6:32 PM
    Edited by: Venkat Rakesh on Oct 7, 2012 8:39 PM

    Hi Rakesh,
    the query is not working as you would like ( but IS working as expected ) since your trying to compare null to another value.
    Comparing null always results in FALSE, also if you compare null to null. This is because null means undefined.
    select 1 from dual where null=null results in no data found.
    I would suggest using a non natural key to join the tables.
    For example include a column ID in the master table which is filled with a sequence and include that field as a foreign key in the detail table.
    This way you can easily join master and detail on ID = ID, and you don't have to worry about null values in this column since it's always filled with data.
    Regards,
    Bas
    btw, using the INNER JOIN and OUTER JOIN syntax in your SQL makes it better readable, since you're separating join conditions from the where clause, just a tip ;)

  • Need some help about a query

    Hello,
    I'm new to oracle DB.
    Can someone help me with this query please?
    I want a query which returns the details of all the DML and DDl queries performed on a database in a particular period of time like for example from that date to today.
    Thank you..

    All changes made to user data or to the data dictionary are recorded in the Oracle redo logs. Therefore, redo logs contain all the necessary information to perform recovery operations. Because redo log data is often kept in archived files, the data is already available.
    Actually to do this you got to have DBA privileges.
    You have to use oracle LOGMINER
    Oracle Corporation provides SQL access to the redo logs through LogMiner, which is part of the Oracle database server. LogMiner presents the information in the redo logs through the V$LOGMNR_CONTENTS fixed view. This view contains historical information about changes made to the database
    Please refer the following link to get more details on the same.
    http://docs.oracle.com/cd/B10501_01/server.920/a96521/logminer.htm
    Hope this helps :)

  • Need some help with count query

    Hello,
    I'm terrible @ oracle, so bear with me. I am trying to use the count function with my query but it counts rows from different tables.
    I want my query to basically add a column from another table but have it not be a part of the count.
    Say, table1 table2 table3. My count is right between the first two tables (Buyers,5).But since in table3 there are duplicate values(or accounts in this case(3), the count multiples by that many (15).
    I need it to read Buyers,5,account #. I've tried distinct and a union but to no avail.
    Help me please.

    If I understand you correctly, you want to count the records in table1 and table2 which have a one-to-one relationship, but you need to display additional data from table3 which has a one-to-many relationship. If this is correct, you need to use an in-line view to join table1 and table2 then join that in-line view to table3 to display the data from it. Something along the lines of:
    SELECT v.col1, v.col2, v.col3, v.col4, v.cnt, t3.col1 t3col1, t3.col2 t3col2
    FROM (SELECT t1.col1, t1.col2, t2.col1 col3, t2.col2 col4, COUNT(*) cnt
          FROM table1 t1, table2 t2
          WHERE <join conditions between t1 and t2> and
                <other conditions if required>
          GROUP BY t1.col1, t1.col2, t2.col1, t2.col2) v,
         table3 t3
    WHERE <join conditions between v and t3>
          <other conditions if required>John

  • Goshh, need some help over here!

    hi everyne.
    need help.
    U insert a number e.g ( -12 ) the operation will be: (-1) + 2 = 1
    e.g : - 42 = (-4) + 2 = -2
    I cannot find a way to do that.
    here is the code for simple sum:
    int sum = 0;
              int aux;
              int digit = 0;
              System.out.print("Insert  a number: ");
              int num = Teclado.intLido();
              aux = num;
              while(aux != 0 ) {
                digit = aux % 10;
                aux = aux / 10;
                if(digit > 0) {
                     sum += digit; when i say "digit > o " this digit is the second one, because the first is always positive.
    So i need help to find a way to tell the computer if the second digit is negative it will deduct. e.g -12 -> (-1 ) + 2 = 1
    Anyone could tell how to tell the computer if the second digit is negative or positive. I cannot find a way to tell that.
    thanks!
    Josh

    what about num / 10 + Math.abs(num % 10) ?
    :D
    i know and with strings and length () to count the digits will be easier too.
    But i can't use Math.abs etcc string length() etc.. just loops :P
    Just wanna know how to tell the computer if the second digits (from right to left) is neg or pos. if neg (-12) (-1) +2 = 1 or (-41) = -4 +1 = -3
    using this method with something else.
    while(aux != 0 ) {
              digit = aux % 10;
              aux = aux / 10;
              if(digit > 0) {
                   soma = soma + digito;
              }else if (digit < 0) {
    // this line is wrong because i want it to see if the SECOND digit is < 0 and not the first which is always positive.
                   sum = sum - digit;
    Do u know what i mean?

  • Need some help in SQL...

    Sorry for asking before doing a search.
    I really don't know what is the keyword to do this search.
    my case is i want a report to show now many Documents created in yesterday and it is group by hours
    so i have write the following SQL:
    select TO_char(xf_txdate,'ddmmyyyy'),TO_char(xf_txdatetime,'HH24'),count(distinct xf_docno)
    from xf_vipitemdm
    where TO_DATE(xf_txdate,'dd/mm/yyyy') = (select TO_DATE(sysdate-1,'dd/mm/yyyy') from dual)
    group by xf_txdate,TO_char(xf_txdatetime,'HH24')
    and i get the following in return.
    TO_CHAR(XF_TXDATE,'DDMMYYYY')     HOUR     COUNT(DISTINCTXF_DOCNO)
    22112009     13     3
    22112009     14     1
    22112009     15     1
    22112009     16     5
    22112009     17     3
    22112009     18     6
    22112009     19     3
    22112009     20     1
    but wat i need is a 24 hour report like the following.
    22112009     00     0
    22112009     01     0
    22112009     02     0
    22112009     03     0
    22112009     04     0
    22112009     05     0
    22112009     06     0
    22112009     07     0
    22112009     08     0
    22112009     09     0
    22112009     10     0
    22112009     11     0
    22112009     12     0
    22112009     13     3
    22112009     14     1
    22112009     15     1
    22112009     16     5
    22112009     17     3
    22112009     18     6
    22112009     19     3
    22112009     20     1
    22112009     21     0
    22112009     22     0
    22112009     23     0
    What should i do? to force the row with "0" show?
    Thank you very much of your time.

    Hi,
    Welcome to the forums.
    You can write querylike this:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as(
      2  SELECT 22112009 dt, 13 cnt, 3 hrs from dual union all
      3  SELECT 22112009, 14, 1  from dual union all
      4  SELECT 22112009, 15, 1 from dual union all
      5  SELECT 22112009, 16, 5 from dual union all
      6  SELECT 22112009, 17, 3 from dual union all
      7  SELECT 22112009, 18, 6 from dual union all
      8  SELECT 22112009, 19, 3 from dual union all
      9  SELECT 22112009, 20, 1 from dual)
    10  select NVL(t.dt,22112009),t1.hrs,NVL(t.cnt,0) from t ,  (SELECT rownum hrs
    from dual connect by level <=24) t1
    11  WHERE t.hrs(+) = t1.hrs
    12* order by t1.hrs asc
    SQL> /
    NVL(T.DT,22112009)        HRS NVL(T.CNT,0)
              22112009          1           20
              22112009          1           14
              22112009          1           15
              22112009          2            0
              22112009          3           17
              22112009          3           13
              22112009          3           19
              22112009          4            0
              22112009          5           16
              22112009          6           18
              22112009          7            0
    NVL(T.DT,22112009)        HRS NVL(T.CNT,0)
              22112009          8            0
              22112009          9            0
              22112009         10            0
              22112009         11            0
              22112009         12            0
              22112009         13            0
              22112009         14            0
              22112009         15            0
              22112009         16            0
              22112009         17            0
              22112009         18            0
    NVL(T.DT,22112009)        HRS NVL(T.CNT,0)
              22112009         19            0
              22112009         20            0
              22112009         21            0
              22112009         22            0
              22112009         23            0
              22112009         24            0
    28 rows selected.
    SQL>I hope you can do necessary changes. if not let us know.
    Cheers,
    Avinash

  • Need tuning help on sql query

    In below query, table A has 200,000 records and table B has 10 million records. There are no indexes on this table at this point, how can i improve the query perfromance ?
    select *
    from A, B
    where A.VARCHAR = SUBSTR(B.VARCHAR, 1, 6)
    and TO_DATE(A.DT_Varchar, 'YYYYMMDD') = TO_DATE(B.DT_Varchar, 'DD Mon YYYY')
    A.VARCHAR & A.DT_Varchar form the uniqueness in Table A
    B.VARCHAR & B.DT_Varchar form the uniqueness in Table B

    Hi,
    Krishna4Oracle wrote:
    In below query, table A has 200,000 records and table B has 10 million records. There are no indexes on this table at this point, how can i improve the query perfromance ?
    select *
    from A, B
    where A.VARCHAR = SUBSTR(B.VARCHAR, 1, 6)
    and TO_DATE(A.DT_Varchar, 'YYYYMMDD') = TO_DATE(B.DT_Varchar, 'DD Mon YYYY')
    A.VARCHAR & A.DT_Varchar form the uniqueness in Table A
    B.VARCHAR & B.DT_Varchar form the uniqueness in Table BDo you need all columns from both tables?
    You might want to consider using explicit joins instead, i.e
    select a.column1, b.column2 from a
    inner join b on
    a.varchar = substr(b.varchar,1,6) and
    TO_DATE(A.DT_Varchar, 'YYYYMMDD') = TO_DATE(B.DT_Varchar, 'DD Mon YYYY')HtH
    Johan

  • Need some help formulating a query

    I need to formulate a query to list the branch number, branch name, revenue_target, and the revenue_generated for each branch that fails to meet its revenue_target where the revenue_generated by a branch is the sum of the total amount of all orders for salespersons working at that branch. The total amount of an order is given by the sum of the total amount for products and the total amount for installation.
    Here are the tables that I am presented with:
    Table: EMPLOYEE
    PK: employeeID     
    FK: empBranch references BRANCH     
    FK: empSupervisor references EMPLOYEE
    EMPLOYEEID     EMPLNAME     EMPFNAME     EMPTITLE     EMPSTARTDATE     EMPBRANCH     EMPSALARY     EMPSUPERVISOR
    e1 Adam     Alan     CEO     11-JAN-02     b1 600000     -
    e2 Bryson     Brad     branch_manager     01-FEB-03     b2 400000     e1
    e3 Clay     Cedric     branch_manager     21-JUN-01     b3 450000     e1
    e4 Day     Daisy     branch_manager     17-AUG-03     b4 480000     e1
    e5 Engle     Eva     salesperson     01-JAN-04     b2 120000     e2
    e6 Falcon     Fred     salesperson     01-JAN-02     b2 80000     e2
    e7 Gandhi     Gagan     salesperson     01-JAN-03     b3 90000     e3
    e8 Hee     Hwang     salesperson     01-JUN-04     b3 95000     e3
    e9 Ingram     Irene     salesperson     24-SEP-02     b4 110000     e4
    e10 Jerome     John     salesperson     25-AUG-02     b4 75000     e4
    Table: BRANCH
    PK: branchNumber
    FK: branchManager references EMPLOYEE
    BRANCHNUMBER     BRANCHNAME     BRANCHSTREET     BRANCHCITY     BRANCHSTATE     BRANCHZIP     REVENUETARGET     BRANCHMANAGER
    b1 branch1     9700 NW 41 St     Miami     FL     33178     800000     e1
    b2 branch2     8700 SW 24 St     Miami     FL     33170     600000     e2
    b3 branch3     E 200 47 St     New York     NY     11010     1000000     e3
    b4 branch4     300 Park Avenue     New York     NY     10010     1200000     e4
    Table: PRODUCT
    PK: productCode
    PRODUCTCODE     PRODDESCRIPTION     PRICE     STOCKLEVEL
    p1 carpet     40     10000
    p2 tile     20     100000
    p3 pergo     50     50000
    Table: INSTALLATION
    PK: installationType
    INSTALLTYPE     INSTALLDESCRIPTION     RATE
    i1 carpet installation     40
    i2 tile installation     50
    i3 pergo installation     60
    Table: ORDERS
    PK: orderNumber
    FK: customerID references CUSTOMER
    FK: salesPerson references EMPLOYEE
    ORDERNUMBER     ORDDATE     SALESPERSON     CUSTOMERID
    o1 12-AUG-07     e5 c1
    o2 14-DEC-07     e5 c2
    o3 04-NOV-07     e5 c3
    o4 15-AUG-07     e5 c4
    o5 22-NOV-07     e10 c5
    o6 01-JUL-07     e10 c6
    o7 12-DEC-07     e6 c6
    o8 30-NOV-07     e9 c2
    Table: PRODLINE
    PK: orderNumber + prodCode
    FK: orderNumber references ORDERS
    FK: prodCode references PRODUCT
    ORDERNUMBER     PRODCODE     QUANTITY
    o1 p1 1000
    o1 p2 500
    o2 p3 200
    o3 p1 600
    o3 p3 100
    o4 p2 1000
    o5 p2 800
    Table: INSTLINE
    PK: orderNumber + instType
    FK: orderNumber references ORDERS
    FK: instType references INSTALLATION
    ORDERNUMBER     INSTTYPE     HOURS
    o1 i1 20
    o1 i2 30
    o1 i3 10
    o2 i1 10
    o2 i2 20
    o6 i1 20
    o6 i2 10
    o7 i3 10
    o8 i2 20
    I can write the queries to get the TOTAL_AMOUNT_FOR_ORDERS, TOTAL_AMOUNT_FOR_INSTALLATIONS, and BRANCHNUMBER, BRANCHNAME, REVENUETARGET. But I can't seem to put them all together.
    Query 1:
    SELECT *
    FROM
    (SELECT o.ORDERNUMBER, SUM(QUANTITY*PRICE) as TOTAL_AMOUNT_FOR_ORDERS
    FROM ORDERS o, PRODUCT p, PRODLINE pl
    WHERE o.ORDERNUMBER=pl.ORDERNUMBER
    AND p.PRODUCTCODE=pl.PRODCODE
    GROUP BY o.ORDERNUMBER
    ORDER BY o.ORDERNUMBER) TOTORD
    FULL JOIN
    (SELECT o.ORDERNUMBER, SUM(HOURS*RATE) as TOTAL_AMOUNT_FOR_INSTALLATIONS
    FROM ORDERS o, INSTALLATION i, INSTLINE il
    WHERE o.ORDERNUMBER=il.ORDERNUMBER
    AND i.INSTALLTYPE=il.INSTTYPE
    GROUP BY o.ORDERNUMBER
    ORDER BY o.ORDERNUMBER) TOTINS
    ON
    TOTORD.ORDERNUMBER=TOTINS.ORDERNUMBER
    Query 2:
    SELECT BRANCHNUMBER, BRANCHNAME, REVENUETARGET
    FROM ORDERS o, EMPLOYEE e, BRANCH b
    WHERE e.EMPLOYEEID=o.SALESPERSON
    AND b.BRANCHNUMBER=e.EMPBRANCH
    Can someone please assist?

    Hi,
    895231 wrote:
    I need to formulate a query to list the branch number, branch name, revenue_target, and the revenue_generated for each branch that fails to meet its revenue_target where the revenue_generated by a branch is the sum of the total amount of all orders for salespersons working at that branch. The total amount of an order is given by the sum of the total amount for products and the total amount for installation.
    Here are the tables that I am presented with: ...Whenever you have a problem, please post CREATE TABLE and INSERT statements for your sample data, and the final results you want to get from that data.
    Explain how you get those results from that data, with specific examples, such as "Branch b1 is included in the results because its revenue_target (which I can get from this query ...) is x, but the order total (which I can see from this query ...) is y, which is less than x. Branch b2 is not included because ..."
    Always say which version of Oracle you're using
    ... I can write the queries to get the TOTAL_AMOUNT_FOR_ORDERS, TOTAL_AMOUNT_FOR_INSTALLATIONS, and BRANCHNUMBER, BRANCHNAME, REVENUETARGET. But I can't seem to put them all together.Thanks for posting these, but without CREATE TABLE and INSERT statements for your sample data, nobody can run them.
    I don't think you need a FUL OUTER JOIN. If all you need is a grand total, UNION ALL would be more efficient.

  • Need some help with SQL logic

    Hi all,
    I have the following query:
    select x.area_id
            , x.ORG_id
            , x. product               
            , case when x.param_info_key in (400, 410, 420, 430, 440)
                         then x.new_value
                end as facility_average_price
            , case when x.param_info_key in (660, 670,680,690,700)
                         then x.new_value
                end as royalty_rate_adjustment     
    from
         select d.area_id
                 , d.ORGANIZATION_NUMBER org_id
                 , d.PARAM_INFO_KEY
                 , i.PARAM_INFO_NAME
                 , case when d.param_info_key in (400)
                                      then 'Gas'
                          when d.param_info_key in (410, 700) 
                                  then 'Ethane'
                          when d.param_info_key in (420, 680)
                                  then 'Propane'
                          when d.param_info_key in (430, 690)
                                  then 'Butane'     
                          when d.param_info_key in (440, 670)
                                  then 'Pentane'                                                                              
                    end as product
                 ,  d.old_value
                 , d.new_value
                 , m.CHANGE_DATE_TIME
                 , max(m.CHANGE_DATE_TIME) over(partition by area_id, organization_number,d.param_info_key) max_change_date
                 , m.PERIOD_KEY
                 , m.change_comment
         from accruals2.accrual_parm_chng_hist_detail d
               , accruals2.accrual_parm_chng_hist_master m
               , accruals2.accrual_period p
               , accruals2.accrual_param_info i
         where d.PARM_CHNG_HIST_MASTER_KEY = m.PARM_CHNG_HIST_MASTER_KEY
                and m.PERIOD_KEY = p.PERIOD_KEY
                and d.PARAM_INFO_KEY = i.PARAM_INFO_KEY
                and d.param_info_key in (400, 410, 700, 680, 430, 690, 440, 670)
                and area_id = 1013
                and p.ACCOUNTING_DATE = date '2010-04-30'
    ) x
    where x.change_date_time = x.max_change_date     
    order by x.area_id, x.org_id
           , x.product,  x.PARAM_INFO_KEYIt returns a data set that looks like this:
    AREA_ID     ORG_ID     PRODUCT     FACILITY_AVERAGE_PRICE     ROYALTY_RATE_ADJUSTMENT
    1013          1     Butane          0.08     
    1013          1     Butane                                             0.0015
    1013          1     Ethane          0.06     
    1013          1     Ethane                                             0.003
    1013          1     Gas               -0.1     
    1013          1     Pentane          0.09     
    1013          1     Pentane                                             0.006
    1013          1     Propane                                             0.007                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    And...............?

  • Need some help in a query

    I have my select statement but I want to make order by 2 things(parameters) that the user choose.
    I have my parameter as list of values where i have the constant value FIRSTNAME and the constant value DATE.
    I have something like this
    select * from TABLE1 as P,TABLE2 as AP
    ORDER BY :CHOICE
    I want that :CHOISE to be replaced by code(P.Fname,P.LName)
    or by (AP.DATE).(depends on users selection)
    How can i pass my order selection from a parameter????
    Thanx

    Hi,
    Add user parameter P_ORDER_BY as character.
    In the afterparamform trigger add this code:
    :P_ORDER_BY := 'order by '||:choice;
    In the data model replace ORDER BY :CHOICE with &P_ORDER_BY.
    For more information pls read the help for lexical parameters.
    Regards, Gicu

  • Need some help over the table CRMD_SRV_REFOBJ

    HI,
    I want to know when does this table get filled and how do i relate it to table CRMD_ORDERADM_H.
    Regards,
    Rishav

    Hi Rishav,
    Check the views - CRMV_SRV_REFOB_I and CRMV_SRV_REFOBJ. the first view will give you the linkage of the ref object with the Item, and the second will give you the linkage of the ref object with the header.
    If you study the join conditions of the view, you will also understand the linkage.
    Regards,
    Siddhesh.

  • 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 with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • We have a set of oracle clients running on T5220 zones that need some help

    Greetings all -
    We have a set of oracle clients running on T5220 zones that need some help.
    If, for example, I execute the query "select (all) from dba_objects", trace output reports 90% of the elapsed time spent under "SQLNet message from client".
    Here are OS details for the clients: Solaris 10 5/08 s10s_u5wos_10 SPARC
    Running "uname -a" from the client gives:
    (SunOS bmc-ste-app 5.10 Generic_127127-11 sun4v sparc SUNW,SPARC-Enterprise-T5220)
    Here are OS details for the dataserver: Enterprise Linux Enterprise Linux Server release 5.2
    Running "uname -a" from the dataserver gives:
    (2.6.18-92.1.6.0.2.el5 #1 SMP Thu Jun 26 17:44:55 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux)
    The RDBMS is 10.2.0.4
    Again, please note, there is no application in the picture here. We are just running a simple catalog query (select * from dba_objects) from sqlplus. Why the wait on something like this? The wait also occurs when a different query is used (select (all) from SYS.COL$ where rownum < 50000). And it doesn't matter if I used the full client or the instant client. I still get the same high-wait.
    We had thought - maybe this is a network thing - so we put a test client on the same subnet as the dataserver. This helped - but not enough. The wait is still way too high even with firewalls taken out of the equation.
    We've also looked at arraysize, SDU, kernel settings. And we've spent time going over tkprof, truss and sqlnet-tracing.
    Has anyone ever had to solve this HIGH WAIT ON CLIENT issue? Is there a work around or some tweak I'm missing.
    Is anyone configured like we are (linux dataserver, solaris clients)? If so - did you see anything like this?
    tia -
    Jim
    Edited by: jim1768 on Mar 31, 2010 1:47 PM
    Edited by: jim1768 on Mar 31, 2010 2:12 PM
    Edited by: jim1768 on Mar 31, 2010 2:13 PM

    Hello,
    We have the exact same issue. Did you ever solve this issue? We have a t5220 and have just upgraded our 11.5.10.2 11i system on it from 9.2.0.8 32-bit sparc to 11.2.0.1 64-bit sparc. Things should be faster but arent, and our consultant has tracked it down to high wait times when the apps tier using forms connects to the database tier on the same box. So even though the t5220 is both server and client, there is something about the client sql connection.through TNS that his having trouble. Thanks for any information. We've also created an S/R with Oracle.
    Note: I am well aware of the other issues with the CMT server series but this particular issue seems independent of the regular / known issues and remains a mystery to us. Other known issues with the CMT servers for SPARC:
    Metalink Note 781763.1 (Migration from fast single threaded CPU machine to CMT UltraSPARC T1 & T2)
    http://blogs.sun.com/glennf/resource/Optimizing_Oracle_CMT_v1.pdf
    http://blogs.sun.com/glennf/tags/throughput
    http://blogs.sun.com/glennf/entry/getting_past_go_with_sparc
    http://www.oracle.com/apps_benchmark/doc/E-Bus-11i-PAY_ORA_SUN-T5220.pdf (this paper has some oracle init settings at the end. The kernel settings have been included in the OS upgrade)
    http://blogs.sun.com/mandalika/entry/siebel_on_sun_cmt_hardware

  • Need some help understanding the way materialized views are applied through

    Hi, I need some help understanding the way materialized views are applied through adpatch.
    In patch 1, we have a mv with build mode immediate. When applying it PTS hang due to pool performance of mv refresh.
    So we provide patch 2, with that mv build mode deferred, hoping it'll go through. But patch 2 hang too on the same mv.
    How does this work? Is that because mv already exists in the database with build immediate, patch 2 will force it to refresh first before changing build mode? How to get over this?
    Thanks,
    Wei

    Hi Hussein,
    Thank you for the response.
    Application release is 11.5.10.
    Patch 1 is MSC11510: 8639586 ASCP ENGINE RUP#38 PATCH FOR 11.5.10 BRANCH
    Patch 2 is MSC11510: 9001833 APCC MSC_PHUB_CUSTOMERS_MV WORKER IS STUCK ON "DB FILE SEQUENTIAL READ" 12 HOURS
    The MV is APPS.MSC_PHUB_CUSTOMERS_MV
    This happens at customer environment but not reproducable in our internal environment, as our testing data is much smaller.
    Taking closer look in the logs, I saw actually when applying both patch 1 and patch 2, MV doesn't exist in the database. So seems my previous assumption is wrong. Still, strange that patch 2 contains only one file which is the MV.xdf, it took 7 hours and finally got killed.
    -- patch 1 log
    Materialized View Name is MSC_PHUB_CUSTOMERS_MV
    Materialized View does not exist in the target database
    Executing create Statement
    Create Statement is
    CREATE MATERIALIZED VIEW "APPS"."MSC_PHUB_CUSTOMERS_MV"
    ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 10 MAXTRANS 255 LOGGING
    STORAGE(INITIAL 4096 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
    TABLESPACE "APPS_TS_SUMMARY"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH FORCE ON DEMAND
    WITH ROWID USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS select distinct
    from
    dual
    AD Worker error:
    The above program failed. See the error messages listed
    above, if any, or see the log and output files for the program.
    Time when worker failed: Tue Feb 02 2010 10:01:46
    Manager says to quit.
    -- patch 2 log
    Materialized View Name is MSC_PHUB_CUSTOMERS_MV
    Materialized View does not exist in the target database
    Executing create Statement
    Create Statement is
    CREATE MATERIALIZED VIEW "APPS"."MSC_PHUB_CUSTOMERS_MV"
    ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 10 MAXTRANS 255 LOGGING
    STORAGE(INITIAL 4096 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 4 FREELIST GROUPS 4 BUFFER_POOL DEFAULT)
    TABLESPACE "APPS_TS_SUMMARY"
    BUILD DEFERRED
    USING INDEX
    REFRESH COMPLETE ON DEMAND
    WITH ROWID USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS select distinct
    from dual
    Start time for statement above is Tue Feb 02 10:05:06 GMT 2010
    Exception occured ORA-00028: your session has been killed
    ORA-00028: your session has been killed
    ORA-06512: at "APPS.AD_MV", line 116
    ORA-06512: at "APPS.AD_MV", line 258
    ORA-06512: at line 1
    java.sql.SQLException: ORA-00028: your session has been killed
    ORA-00028: your session has been killed
    ORA-06512: at "APPS.AD_MV", line 116
    ORA-06512: at "APPS.AD_MV", line 258
    ORA-06512: at line 1
    Exception occured :No more data to read from socket
    AD Run Java Command is complete.
    Copyright (c) 2002 Oracle Corporation
    Redwood Shores, California, USA
    AD Java
    Version 11.5.0
    NOTE: You may not use this utility for custom development
    unless you have written permission from Oracle Corporation.
    AD Worker error:
    The above program failed. See the error messages listed
    above, if any, or see the log and output files for the program.
    Time when worker failed: Tue Feb 02 2010 19:51:27
    Start time for statement above is Tue Feb 02 12:44:52 GMT 2010
    End time for statement above is Tue Feb 02 19:51:29 GMT 2010
    Thanks,
    Wei

Maybe you are looking for