Rewrite the query with joins, and group by

Hello

It's an interview question.

Table names: bookshelf_checkout
virtual library

And the join condition between these two tables is title

We need to rewrite under request without using the join condition and group by clause?

SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out"
           FROM bookshelf_checkout bc,bookshelf b
           WHERE bc.title(+)=b.title
           GROUP BY b.title;
When I was in College, I read most of SELECT statements can be replaced by operations base SQL (DEFINE the OPERATORS). Now, I am rewriting the query with SET operators, but not able to get the exact result.

Kindly help me on this.

Thank you
Suri

Something like that?

  1  WITH books AS (
  2  SELECT 'title 1' title FROM dual UNION ALL
  3  SELECT 'title 2' FROM dual UNION ALL
  4  SELECT 'title 3' FROM dual ),
  5  bookshelf AS (
  6  SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL
  7  SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL
  8  SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual )
  9  SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs
 10  UNION
 11  (SELECT b.title, NULL FROM books b
 12  MINUS
 13* SELECT bs.title, NULL FROM bookshelf bs)
SQL> /

TITLE   MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE)
------- ------------------------------------------------------------
title 1                                                           14
title 2                                                           44
title 3

Lukasz

Tags: Database

Similar Questions

  • Internal XML to the query with join

    I have a CF page that reads an XML file in a query using < cffile > XMLParse and QueryAddrow.

    I then do a QoQ on the result and voila! I have my page.  I hide the query for 8 hours and the XML file is only reread this cache expires.  It works well.

    My problem now is that the file contains data from three tables of database instead of one, so I need to make an inner join on the tables.  But I can't do a t/t with an inner join.

    Does anyone know a way for me to do this?

    Oh, didn't know that.  How about interweaving of QofQ?  Join Query1 and Query2 requests in a new query, then join for 3 statement?

  • Report with the query with union and parameters

    Hello

    We have an obligation to create a report with the request, which is the union and parameters.

    I intend to create a database for the report based on a query. But the problem here is that the way to pass parameters in the query.

    Request is something like that

    Select x.a, x.b, x.c
    x
    where x.year =: para1
    and x.status = 'A '.
    Union of all the
    Select x.a, x.b, x.c
    x
    where x.year =: para1 - 1
    and (x.status = 'c' and x.date =: para2 or x.status = 'I' and x.date < =: para2)

    Here x.year in the first select statement must be equal to: para1 and second select statement, it should be: para - 1.

    How this requirement can be achieved?

    Client don't want to separate worksheet, a parameter and another for the actual data that I tried with sys_context and it worked. But the client wants the result in a single sheet only... So I need to change their approach.

    Help, please.

    Thank you

    Hello
    Another option is to convert the request so that you will have the items from the selection
    for example on the query you provided that you can use:

    Select 'Curr' rec_type, x.a, x.b, x.c, x.year, x.date, x.status
    x
    where x.status = "A".
    Union of all the
    Select 'Prev' rec_type, x.a, x.b, x.c, x.year, x.date, x.status
    x
    where x.status in ('c', 'I')

    then, in the workbook, you will be able to create conditions such as:
    rec_type = 'Curr' and year =: para1

    rec_type = 'Prev' and year =: para1-1
    rec_type = 'Prev' and (status = 'c' and date =: para2 or status = 'I' and date)<=>

    Tamir

  • Need a clarification on the concept of 'World' and 'Group' with regard to CPU reviews

    All-

    I am investigating questions of CPU usage for one of my guests with esxtop. Can someone clarify the concept of 'World' and 'group '? Many of my guests have a 7 or 11 NWLD and I'm trying to figure out exactly this means. What I gather is the following:

    A guest has many worlds

    There is one guest per group

    A group contains many worlds

    Can someone also explain the purpose to describe the use of the processor in this way?

    Megan

    Hello.

    Check it out "[interpretation statistical esxtop | ]. "[http://Communities.VMware.com/docs/doc-9279.pdf]" document.  «[The planner of UC in VMware® ESX 4 |]» [ http://www.vmware.com/files/pdf/perf-vsphere-cpu_scheduler.pdf] "white book is also a good reference.

    Good luck!

  • How can rewrite the query statement effectively

    Hi gurus,

    BANNER

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

    Oracle Database 10g Release 10.2.0.4.0 - Production 64-bit

    PL/SQL Release 10.2.0.4.0 - Production

    CORE 10.2.0.4.0 Production

    AMT for Linux: release 10.2.0.4.0 - Production

    NLSRTL Version 10.2.0.4.0 - Production

    Table scripts


    CREATE TABLE WAREHOUSE

    (

    IDZONE VARCHAR2 (6 BYTE) NOT NULL,

    ZONE_CREATEDATE DATE NOT NULL,

    DATE OF DT_WAREHOUSE,

    DATE OF DT_POSTING

    )

    AREA ID, ZONE_CREATEDATE is PK

    CREATE TABLE ZONE_VIEW

    (

    IDZONE VARCHAR2 (6 BYTE) NOT NULL,

    ZONE_CREATEDATE DATE NOT NULL,

    ZONE_NUM NUMBER (2) NOT NULL,

    DATE OF TRANX_DATE

    )

    ID of the AREA, ZONE_CREATEDATE, ZONE_NUM is PK

    Query

    SELECT ID area, zone_createdate

    Of

    (

    SELECT ID area, zone_createdate,

    MAX (CASE WHEN zone_num = 18 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 18 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_18,.

    MAX (CASE WHEN zone_num = 110 AND not IS NOT NULL, THEN 1 TIME = 110 zone_num tranx_date AND tranx_date IS NULL THEN 0 ELSE-1 END) region_110,.

    MAX (CASE WHEN zone_num = 135 AND tranx_date no IS NOT NULL, THEN 1 TIMES zone_num = 135 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_135,.

    MAX (CASE WHEN zone_num = 140 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 140 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_140

    OF zone_view

    GROUP BY IDZone, zone_createdate

    ) zrn

    WHERE zrn.region_18 <>0

    AND (((zrn.region_110 = 1) OR (zrn.region_110 = - 1)) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_warehouse IS NULL)))

    AND (((zrn.region_135 = 1) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_posting IS NULL))) OR (zrn.region_140 = 1))

    OR ((zrn.region_18 >-1) AND (zrn.region_135 = - 1) AND (zrn.region_140 < 1))

    OR ((zrn.region_110 = 1) AND (zrn.region_135 = - 1) AND (zrn.region_140, <>, 0))

    );

    Top query runs too slowly on the real data set. Is there an effective way to rewrite the query which can perform the dough?

    Any help or suggestion would be appreciated

    Thanks in advance

    At the time where the application may not throw anything until after he has retrieved and grouped all the ranks of zone_view. His estimate of 7.5 minutes to scan millions 639 lines really fast enough - it's 85 million lines per minute.

    This seems to be where the time went. The only way that the query can be accelerated is to recover some of the conditions that must be applied before the grouping. The only obvious possibilities for this are

    (a) filter values of zone_num

    (b) move the audit only

    NOT EXISTS (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_warehouse IS NULL)

    within the group, because this condition is applied regardless of the values in calculated fields. The AREA ID, ZONE_CREATEDATE are not null, so I suggest to try:

    SELECT ID area, zone_createdate

    Of

    (

    SELECT ID area, zone_createdate,

    MAX (CASE WHEN zone_num = 18 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 18 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_18,.

    MAX (CASE WHEN zone_num = 110 AND not IS NOT NULL, THEN 1 TIME = 110 zone_num tranx_date AND tranx_date IS NULL THEN 0 ELSE-1 END) region_110,.

    MAX (CASE WHEN zone_num = 135 AND tranx_date no IS NOT NULL, THEN 1 TIMES zone_num = 135 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_135,.

    MAX (CASE WHEN zone_num = 140 AND tranx_date 'n' IS NOT NULL, THEN 1 TIME zone_num = 140 AND tranx_date IS NULL THEN 0 ELSE-1 END) region_140

    OF zone_view

    where (IDZone, zone_createdate) NOT IN (select the zone ID, w warehouse zone_createdate WHERE w.dt_warehouse IS NULL)

    and zone_num (18, 110, 135, 140)

    GROUP BY IDZone, zone_createdate

    ) zrn

    WHERE zrn.region_18 <> 0

    AND ((zrn.region_110 = 1) OR (zrn.region_110 = - 1))

    AND (((zrn.region_135 = 1) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_posting IS NULL))) OR (zrn.region_140 = 1))

    OR ((zrn.region_18 >-1) AND (zrn.region_135 = - 1) AND (zrn.region_140)<>

    OR ((zrn.region_110 = 1) AND (zrn.region_135 = - 1) AND (zrn.region_140 <> 0))

    )

    Unfortunately, if the plan of the query time estimates are correct, most of the duration of the query is spent doing a reading zone_view in a full analysis, and which will not be changed by this query.

    If there are many rows for each (IDZone, zone_createdate) zone_view pair, then it is possible that an index on (area ID, zone_num, zone_createdate) would contribute to this request, especially if most (IDZone, zone_createdate) pairs are filtered with the NOT IN (select the zone ID, zone_createdate w warehouse WHERE w.dt_warehouse IS NULL). More radical but probably effective measure would be a functional on index

    zone_view (zone_num, IDZone, zone_createdate, case when tranx_date is null then 0 otherwise 1 end)

    and using the expression in the query box:

    SELECT ID area, zone_createdate

    Of

    (

    SELECT ID area, zone_createdate,

    NVL (MAX (CASE WHEN zone_num = 18 then case when tranx_date is null, then 0 or 1 end end),-1) region_18,.

    NVL (MAX (CASE WHEN zone_num = 110 then case when tranx_date is null, then 0 or 1 end end),-1) region_110,.

    NVL (MAX (CASE WHEN zone_num = 135 then case when tranx_date is null, then 0 or 1 end end),-1) region_135,.

    NVL (MAX (CASE WHEN zone_num = 140 then case when tranx_date is null, then 0 or 1 end end),-1) region_140

    OF zone_view

    where (IDZone, zone_createdate) NOT IN (select the zone ID, w warehouse zone_createdate WHERE w.dt_warehouse IS NULL)

    and zone_num (18, 110, 135, 140)

    GROUP BY IDZone, zone_createdate

    ) zrn

    WHERE zrn.region_18 <> 0

    AND ((zrn.region_110 = 1) OR (zrn.region_110 = - 1))

    AND (((zrn.region_135 = 1) AND (there IS NOT (SELECT null from warehouse w WHERE w.zoneid = zrn.zoneid AND w.zone_createdate = zrn.zone_createdate AND w.dt_posting IS NULL))) OR (zrn.region_140 = 1))

    OR ((zrn.region_18 >-1) AND (zrn.region_135 = - 1) AND (zrn.region_140)<>

    OR ((zrn.region_110 = 1) AND (zrn.region_135 = - 1) AND (zrn.region_140 <> 0))

    )

    This gives a very different plan on my database, by performing an iteration on relevant areas of performance status:

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

    | ID | Operation | Name |

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

    |   0 | SELECT STATEMENT |              |

    |*  1 |  FILTER                          |              |

    |   2.   VIEW                           |              |

    |*  3 |    FILTER                        |              |

    |   4.     HASH GROUP BY.              |

    |   5.      ANTI NESTED LOOPS.              |

    |   6.       INLIST ITERATOR.              |

    |*  7 |        INDEX RANGE SCAN | ZV_F1 |

    |*  8 |       TABLE ACCESS BY INDEX ROWID | WAREHOUSE |

    |*  9 |        INDEX UNIQUE SCAN | WAREHOUSE_PK |

    | * 10 |   TABLE ACCESS BY INDEX ROWID | WAREHOUSE |

    | * 11 |    INDEX UNIQUE SCAN | WAREHOUSE_PK |

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

    Your plan will be different because you have data volumes (I didn't create millions of lines of test data)

    It would be useful to know how many rows there are in the WAREHOUSE, how many distinct (IDZone, zone_createdate) pairs there are in zone_view and the number of rows actually returns the query, and how much is NOT IN (select the zone ID, w zone_createdate warehouse WHERE w.dt_warehouse IS NULL) because these relative numbers determine how these approaches are.

    If there is a table containing all of the (area ID, zone_createdate) pairs which could take place in zone_view, which would have may another possible approach:

    First filter possible pairs against NOT IN (select the zone ID, w warehouse zone_createdate WHERE w.dt_warehouse IS NULL)

    Then attach them to the zone_view to retrieve only the rows in the filtered (IDZone, zone_createdate) pairs.

    Good luck.

  • Combine two results of the query with rank

    Dear all,

    I'm an analyst working DB for the first time:

    I have two requests:
    1)
    Select * (select 'CAFNo', 'ActionDate', 'ActionDetail', rank() on rnk (partition by order of 'CAFNo' through 'ActionDate'),
    of 'ABC '.
    where 'ActionDetail '.
    as 'FIU successfully presented and routed to the fulfillment team %')
    where rnk = 1

    Results in
    CAFNo', 'ActionDate1', 'ActionDetail '.

    2)
    Select * (select rank() on rnk (partition by order of "CAFNo" by "ActionDate"), 'CAFNo', 'ActionDate', 'ActionDetail'
    of 'ABC '.
    where 'ActionDetail '.
    like '% customer ID %')
    where rnk = 1

    Results in
    CAFNo', 'ActionDate2', 'ActionDetail '.
    ---------------------------------------------------------------------
    I would like to combine the results of two as:
    No College, Actiondate1, actiondate2, ActionDetail

    I tried the full outer join and other options but without success. Help, please
    Please share concept to join the two results not the actual query.
    with t as (
               select  "CAFNo",
                       "ActionDate",
                       "ActionDetail",
                       case
                         when "ActionDetail" like '%Customer ID%' then 2
                         else 1
                       end weight,
                       rank() over(
                                   partition by "CAFNo",
                                                 case
                                                   when "ActionDetail" like '%Customer ID%' then 2
                                                   else 1
                                                 end
                                   order by "ActionDate"
                                  ) rnk
                 from  "ABC"
                 where "ActionDetail" like '%Customer ID%'
                    or "ActionDetail" like 'CRF successfully submitted and routed to Fulfillment Team%'
              )
    select  "CAFNo",
            max(
                case weight
                  when 1 then "ActionDate"
                end
               ) "ActionDate1",
            max(
                case weight
                  when 2 then "ActionDate"
                end
               ) "ActionDate2",
            max(
                case weight
                  when 1 then "ActionDetail"
                end
               ) "ActionDetail1",
            max(
                case weight
                  when 2 then "ActionDetail"
                end
               ) "ActionDetail2"
      from  t
      where rnk = 1
      group by "CAFNo"
    /
    

    SY.

  • Rewrite the query, select below or try to get the necessary O/P

    Hello..

    My example of data.,.

    Create table customer (name varchar2 (10), telephone1 telephone2 number (10), number of phone3 (10), (10) number, bitwisephone number (10));

    Insert into customer values('a',23456,67890,null,12345);

    Insert into customer values ('b', 67459,89760,null, 37689);

    create table do_not_call (dont_call number (10));

    insert into do_not_call values (67890);

    insert into do_not_call values (37689);

    Question: -.
    --------------

    Customer 'a' has value of numbers1 as 23456.check if telephone1 exists in the do_not_call table.
    In fact there is no, so set the bit for numbers1 as "o" like wise search telephone2
    & phone3.after update of the bitwisephone for each client should be as the output below.


    Need to O/P: -.
    -------------------

    name bitwisephone

    a 010
    b 001


    For that matter... I use "any" operator...



    SELECT name, case when numbers1 = all (SELECT dont_call FROM do_not_call) and then put an end to '1' other '0'.
    -case when telephone2 = all (SELECT dont_call FROM do_not_call) and then put an end to '1' other '0'.
    -case when phone3 = all (SELECT dont_call FROM do_not_call) then '1' other '0' end 'Bits '.
    OF THE customer;


    Is there any other way to get the necessary O/P?


    Thank you!!

    Kind regards
    VijayRajaram.

    Looks like one already answered Re: rewrite the query, select below or try to get the necessary O/P

    with
    customer(name,phone1,phone2,phone3,bitwisephone) as
    (select 'a',23456,67890,12345,null from dual union all
     select 'b',67459,89760,37689,null from dual
    ),
    do_not_call(dont_call) as
    (select 67890 from dual union all
     select 23456 from dual union all
     select 37689 from dual
    )
    select name,
           to_char(mod(trunc(sum(weight)/4),2))||
           to_char(mod(trunc(sum(weight)/2),2))||
           to_char(mod(sum(weight),2)) bitwisephone
      from (select name,phone1 phone,4 weight
              from customer
            union all
            select name,phone2,2
              from customer
            union all
            select name,phone3,1
              from customer
           ) c,
           do_not_call d
     where c.phone = d.dont_call(+)
       and d.dont_call is not null
     group by name
    

    Please do not duplicate messages

    Concerning

    Etbin

  • Maybe it's to rewrite the BIOS with crisis recovery mode?

    Hey everybody,

    my laptop 'freezes' during BIOS 'PHOENIX' updated 2 years ago.
    SERVICE told to change the motherboard, the price as new pc, so I bought new laptop.

    I keep looking at the toshiba forum always, so I read a lot of information on the MODE of RECOVERY from CRISIS.
    so I tried to check my laptop died after 2 years.

    My satellite M100 starts in crisis recovery mode Fn + B.
    my laptop starts up to CRISIS MODE, but do not read the USB STICK
    I did the flash with the CRISDISK 1.0.0.4 USB key program, but I'm not sure I did it way right!

    My question is:
    is it really possible to REWRITE the bios with crisis recovery mode, where I can read more information on how to do it.

    I want back my M100 :)))

    Hey,.

    As Akuma writes that you should try a USB FDD instead a USB key. Key USB is supported only on new models of laptops, but as far as I know USB FDD will be always supported.

    In any case, just for your information: you should know what you're doing. It is a delicate and risky procedure and in the worst cases you might destroy the whole ROM module but if you already have a new laptop I think that it s a problem for you. ;)

  • More than 1 SQL query with checkbox and error invalid number report

    Hi all

    I have two SQL query reports that each has an apex_item.checkbox and two processes for each report.  A report/process works very well.  It gives me an error of invalid number.

    In addition, another query SQL (editable report) gives me the following error when using the Multi line process, delete.

    ORA-06502: PL/SQL: digital or value error: character number conversion
    error ORA-06502: PL/SQL: digital or value error: character number conversion
    error
    Ok

    When I got a report from SQL query (with box and a process) and the query SQL (editable report) everything worked.  It stopped working when I added another SQL query report (with box and a process).

    A SQL query has the following in my query: apex_item.checkbox(3,email_id,'UNCHECKED') ""

    The other SQL query has the following: apex_item.checkbox(2,b.file_id,'UNCHECKED') ""

    Any help will be greatly appreciated,

    Sylvia

    Hi Reema,

    I've recreated the region and now it works!

    Thank you for this, looking at

    Sylvia

  • Structure of the query with parameters

    Hello
    Consume the web service, the results in a file xml with complex structures.
    The function below the structure of the query
    < TemplateName CcResultItems = "CgrInfo_1" >
    My question is how to reorganize the query to obtain the results of the structure
    < TemplateName CcResultItems = "CgrOwners_4" >
    which should return three rows.

    Kind regards
    Kostadin

    create or replace
    FUNCTION WS_SELECT_XML RETURN VARCHAR2 AS
    XML_VAR XMLTYPE: = XMLTYPE)
    "" ' < soap envelope: xmlns:soap = 'http://www.w3.org/2003/05/soap-envelope"" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" >. "
    < soap: Header >
    "< XmlSoapHeader xmlns ="https://test.wstestx.com/XWS2/ "/>"
    < / soap: Header >
    < soap: Body >
    "< ProcessRequestResponse xmlns ="https://test.wstestx.com/XWS2/">."
    < ProcessRequestResult > <! [CDATA [< CcResponse >

    < TemplateName CcResultItems = "CgrInfo_1" >
    < CcResultItem > < InfoMessage > < / InfoMessage > < IsitTerminated > 0 < / IsitTerminated > < IdObject > 365124 < / IdObject > < sanctuary ObjectlName > < / ObjectlName > < ObjectTaxNumber > 305089321502 < / ObjectTaxNumber > < / CcResultItem >
    < / CcResultItems >
    < TemplateName CcResultItems = "CgrUnits_2" >
    < / CcResultItems >
    < TemplateName CcResultItems = "CgrActors_3" >
    < CcResultItem > < IdObject > 365124 < / IdObject > < UnitNo > 0 < / UnitNo > < EntityTYPEcode > 1 < / EntityTYPEcode > < EntityTYPEdesc > person < / EntityTYPEdesc > < / CcResultItem >
    < / CcResultItems >
    < TemplateName CcResultItems = "CgrOwners_4" >
    < CcResultItem > < IdObject > 365124 < / IdObject > < EntityTYPEcode > 1 < / EntityTYPEcode > < EntityTYPEdesc > person < / EntityTYPEdesc > < OwnerID > 610697843014 < / OwnerID > < OwnerName > ALEX < / OwnerName > < / CcResultItem >
    < CcResultItem > < IdObject > 365124 < / IdObject > < EntityTYPEcode > 1 < / EntityTYPEcode > < EntityTYPEdesc > person < / EntityTYPEdesc > < OwnerID > 840645947005 < / OwnerID > < OwnerName > JOHN < / OwnerName > < / CcResultItem >
    < CcResultItem > < IdObject > 365124 < / IdObject > < EntityTYPEcode > 2 < / EntityTYPEcode > < company EntityTYPEdesc > < / EntityTYPEdesc > < OwnerID > 703454 < / OwnerID > < OwnerName > BROWN < / OwnerName > < / CcResultItem >
    < / CcResultItems >
    < TemplateName CcResultItems = "CgrActivities_5" >
    < / CcResultItems >
    < TemplateName CcResultItems = "CgrMembership_6" >
    < / CcResultItems >
    < TemplateName CcResultItems = "CgrFounding_7" >
    < CcResultItem > < IdObject > 365124 < / IdObject > < FoundingDate > 2007-08-16 13:53 < / FoundingDate > < Total > 146701.00 < / Total > < / CcResultItem >
    < / CcResultItems >
    [[< / CcResponse >]] > < / ProcessRequestResult >
    < / ProcessRequestResponse >
    < / soap: Body >
    < / envelope soap: >
    ');
    BEGIN
    FOR R IN)
    WITH T AS (SELECT (XML_VAR) DOUBLE COLLAR)
    SELECT x2.*
    FROM XMLTable)
    XMLNamespaces)
                ' http://www.w3.org/2003/05/soap-envelope ' LIKE 'SOAP'
    , by default ' https://test.wstestx.com/XWS2/ '
    )
    , ': soap envelope / soap: Body/ProcessRequestResponse/ProcessRequestResult '
    by the way XML_VAR
    path of CcResponse clob columns '.'
    ) x 1
    XMLTABLE)
    ' / CcResponse/CcResultItems.
    XMLPARSE PASSAGE (DOCUMENT X 1.) CCRESPONSE)
    COLUMNS
    TemplateName VARCHAR2 (140) path "@TemplateName"
    , IDOBJECT VARCHAR2 (140) PATH "CcResultItem/IdObject.
    , PATH of VARCHAR2 (340) OBJECTLNAME ' CcResultItem/ObjectlName '.

    , PATH of VARCHAR2 (140) VRSKA 'CcResultItem '.
    ) X 2
    WHERE X 2. TemplateName = "CgrInfo_1."
    -WHERE X 2. TemplateName = "CgrActors_3."
    -WHERE X 2. TemplateName = "CgrOwners_4."
    ) LOOP
    DBMS_OUTPUT. Put_line (' IdObject: ' |) R.IDOBJECT |  ' ObjectlName: ' | R.ObjectlName | "TemplateName ' |" R.TemplateName);
    END LOOP;
    DBMS_OUTPUT. Put_line ("- end -");
    RETURNS A NULL VALUE.
    END WS_SELECT_XML;

    Based on your query, I'll assume that you started with

    Extract data from webservice response

    In my opinion, it comes of the change you are looking for

    FOR R IN (
       SELECT x2.TemplateName, x3.idobject, x3.OWNERID
          FROM XMLTable(
                 XMLNamespaces(
                   'http://www.w3.org/2003/05/soap-envelope' AS "soap"
                 , default 'https://test.wstestx.com/XWS2/'
                 )
               , 'soap:Envelope/soap:Body/ProcessRequestResponse/ProcessRequestResult'
                 passing XML_VAR
                 columns
                 CcResponse clob path '.'
               ) x1
          , XMLTABLE(
              '/CcResponse/CcResultItems[@TemplateName="CgrOwners_4"]'
              PASSING XMLPARSE(DOCUMENT X1.CCRESPONSE)
              COLUMNS
                      TemplateName  VARCHAR2(20) PATH '@TemplateName'
                    , ItemXML       XMLTYPE       PATH 'CcResultItem'
            ) X2
          , XMLTABLE(
              '/CcResultItem'
              PASSING x2.itemXML
              COLUMNS
                      IDOBJECT      VARCHAR2(20) PATH 'IdObject'
                    , OWNERID       VARCHAR2(20) PATH 'OwnerID'
            ) X3
    )
    

    As Odie post pointed out.  The first (x 1) XMLTable retrieves the content of ProcessRequestRequest and by doing this, delete the CDATA tag.  We now have a CLOB that resembles XML.  The second XMLTable (x 2) converts this CLOB into an XMLType and looking for the node that matches the XPath expression.  It's where I've hardcoded in your query to search for a specific node.  As you want node has a repeated structure that you want to retrieve each row, I spent structures repeatedly in the third XMLTable (x 3) so he could analyze.  You could combine x 2 and x 3 using XQuery, but I suggest starting by this method I found that it's easier to understand what is happening.

    To test out your code, simply replace the line

    by the way XML_VAR

    with

    from XMLTYPE ("... the content of the SOAP Message...")

    and run the query.  You can do this to debug the query as you and just do a SELECT * to see what all went from XMLTable to XMLTable, so went to check the correct data.

  • SQL query with terms and calculations?

    Hello
    How do I create a query with terms and calculations?
    For example, I have this table


    Start | End |     At work |     Mandatory
    ------------------------------------------------------------------------------------
    1ST JANUARY 13 | JANUARY 11, 13.     Office |          1
    JANUARY 14, 13. 25 JANUARY 13 |     Ministry of the Interior.     0
    04-MRZ-13 | 15-MRZ-13 |     Office |          0
    FEBRUARY 11, 13. FEBRUARY 22, 13.     Office |          1


    Now, if the workplace of the column = office and required column = 0
    the new 'price' column should calculate: (end-start) * $25.00
    and if workplace = Office and required column = 1
    the 'price' column must calculate: (end-start) * $20.60
    any other $0.00

    I tried with the case statement, but I didn't know how
    to calculate my values and display in the virtual column 'price '.

    Something like
    case
    When Working_Place = 'Office' and mandatory = 1
    then...
    else ' 0.00'. "
    end PRICE
    ?????


    Or is that not possible?

    Published by: DB2000 on 12.03.2013 05:09

    Use CASE:

    select  start_dt,
            end_dt,
            working_place,
            mandatory,
            case
              when working_place = 'Office' and mandatory = 0 then (end_dt - start_dt) * 25
              when working_place = 'Office' and mandatory = 1 then (end_dt - start_dt) * 20.60
              else 0
            end price
      from  tbl
    /
    
    START_DT  END_DT    WORKING_PLA  MANDATORY      PRICE
    --------- --------- ----------- ---------- ----------
    01-JAN-13 11-JAN-13 Office               1        206
    14-JAN-13 25-JAN-13 Home Office          0          0
    04-MAR-13 15-MAR-13 Office               0        275
    11-FEB-13 22-FEB-13 Office               1      226.6
    
    SQL> 
    

    SY.

  • the two equii join and natural join are equall.will both display the output of the same

    the two equii join and natural join are equall.will both display even

    output?

    Hello
    It keeps you a little test and check yourself?

    See the link below.

    http://psoug.org/reference/joins.html

    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> CREATE TABLE parents (
      2  person_id  NUMBER(5),
      3  adult_name VARCHAR2(20),
      4  comments   VARCHAR2(40))
      5  PCTFREE 0;
    
    Table created.
    
    SQL>
    SQL> CREATE TABLE children (
      2  parent_id    NUMBER(5),
      3  person_id    NUMBER(5),
      4  child_name   VARCHAR2(20),
      5  comments     VARCHAR2(40))
      6  PCTFREE 0;
    
    Table created.
    
    SQL>
    SQL> INSERT INTO parents VALUES (1, 'Dan', 'So What');
    
    1 row created.
    
    SQL> INSERT INTO parents VALUES (2, 'Jack', 'Who Cares');
    
    1 row created.
    
    SQL> INSERT INTO children VALUES (1, 2, 'Anne', 'Who Cares');
    
    1 row created.
    
    SQL> INSERT INTO children VALUES (1, 1, 'Julia', 'Yeah Right');
    
    1 row created.
    
    SQL> INSERT INTO children VALUES (2, 1, 'Marcella', 'So What');
    
    1 row created.
    
    SQL> COMMIT;
    
    Commit complete.
    
    SQL>
    SQL> SELECT adult_name, child_name
      2  FROM parents NATURAL JOIN children;
    
    ADULT_NAME           CHILD_NAME
    -------------------- --------------------
    Jack                 Anne
    Dan                  Marcella
    
    SQL> select adult_name,child_name from parents a, children b
      2  where a.person_id=b.person_id;
    
    ADULT_NAME           CHILD_NAME
    -------------------- --------------------
    Jack                 Anne
    Dan                  Julia
    Dan                  Marcella
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  select adult_name,child_name from parents a, children b
      2* where a.person_id=b.parent_id
    SQL> /
    
    ADULT_NAME           CHILD_NAME
    -------------------- --------------------
    Dan                  Anne
    Dan                  Julia
    Jack                 Marcella
    
    SQL>
    

    Kind regards
    Avinash

  • I can ONLY connect to the internet with IE7 and Outlook Express

    I have Win XP SP3, home wired network, Netgear router, cable internet, Lenovo desktop.
    I can run IE 7 and Outlook Express and connect to the internet very well with these.  However, I can not connect using FireFox.  Windows Update returns an error and does NOT connect to scan my computer and display the necessary updates.  I just installed tax program this year HR CD block and it is unable to connect to internet to download the updates.  I used IE7 to go to the web site of the tax program to download the update manually, but it doesn't connect either.  I also can't complete installation OF Adobe (Digital Editions) program because it must connect to the internet in order to make a registration.

    I have disabled the Windows Firewall, do not have a configured proxy.  So, I can browse the internet with IE7 and get email with Outlook express.  I went on the site from Google Chrome to try to download it and install it that (using IE7 of course), but after I press the "Download" button, IE7 says that it cannot connect to perform the download.

    I scanned this forum and not seen similar symptoms that would allow me to reach a solution.  Everyone knows about this issue and how to resolve?

    P.S. I have two other laptops Win XP which CAN completely connect to internet with IE and Firefox via the same router and the modem cable.

    I tried trojan remover and none of the things in the menu utils found any problems.

    But it turns out that my problem was a hidden/partial copy of Symantec Client Firewall that I thought was deleted.  Over the months some programs had been updated and Symantec didn't know about them, so it was blocking their access: FROM Adobe, HR Block, IE8, Firefox, etc.  Given that I have not seen it listed in the start menu and it was not listed in Add/Remove Programs, I didn't have to try to remove it.  And it was not poping up to tell me of a new program attempts to access the Internet.

    I used the Symantec tool to remove all THE stuff of Symantec and it cleared up my connection problems.  I then reinstalled Symantec Client Security (antivirus and firewall) and turned off the Windows Firewall.

  • Hello friends, I have a license with terms of the photo with Photoshop and Lightroom applications installed on my iMac. Question: With this license can I install these applications also in my notebook? Using the same license.

    Hello friends, I have a license with terms of the photo with Photoshop and Lightroom applications installed on my iMac. Question: With this license can I install these applications also in my notebook? Using the same license.

    Yes, individual licenses, ranging up to allow two simultaneous, activations facilities.

    subscriptions allow mounting on an unlimited number of computers.  connection is limited to a maximum of two computers at a time.

  • To get a trial free Adobe Photoshop Lightroom CC TRY (install) times the CC with Lightroom and Photoshop CC or just Lightroom CC?

    To get a trial free Adobe Photoshop Lightroom CC TRY (install) times the CC with Lightroom and Photoshop CC or just Lightroom CC? I installed only the Lightrrom CC and when I opened it up it reads 'Adobe Photoshop Lightroom CC' but I think I should TRY (install) the CC of Photoshop?

    OK, the plan of photography includes photoshop and photoshop lightroom.

Maybe you are looking for

  • iPad Pro - questions before you buy

    I buy the iPad Pro 12.9 ". I have an old computer Intel iMac with Leopard (I know - obsolete). My questions: -Can I connect the iPad to my computer and access to the files of my iMac to download on the internet on my iPad? -Can I connect a Kensiingto

  • Satellite Pro A300D - reinstalled XP - now its does not work

    Recently, I had a virus on my laptop Toshiba Satellite Pro A300D-14O, which meant that I had to take it to get reinstalled Windows.This tech guy who I gave it to a do. However, now, the sound does not seem to work properly.The volume on the laptop wh

  • Computer laptop HP Windows 8 does not connect to internet through wired or wireless

    My portable 64-bit Windows 8 is telling me wired LAN not connected not Realted PCIe FE Family Controller and wireless LAN not connected Microsoft Wi - Fi Direct virtual card. My laptop product # is anb C2M44UA #ABA series # {personal info deleted}.  

  • BlackBerry Smartphones No way to lock my blackberry 8820

    I've updated the software on my blackberry 8820 at 4.5.0.110.   The lock icon is now gone, and the backberry never seems to lock on its own. Needless to say, it's bad. If I put it in my pocket, it will start to deal on its own. How to retrieve the lo

  • Unable to show the custom workflow

    Hello worldI use Jdeveloper with JDeveloper 11.1.1.8 extension 11.1.1.7 and Webceter Portal Builder 1.8.I created a workflow in Jdeveloper and deployed in WC_spaces server. I added the workflow to shared resources. When I try to access this workflow