Purchase DETAILS QUERY

Dear All
I had written a Document Level query for one of my client for Purchase Details. I am getting expected output for all except Freight details. If if run the query and if there is Multiple Freight Line in the document, then the query throw multiple lines in the output.
For example in a document if i have 2 lines in the freight screen (Freight & Cutting & loading charges) then the query throws the output in 2 lines (one for freight and one for cutting exp). But remaining all fields such as Basic amt,Doctotal & all tax amounts including bed,cess & hecess comes correct.
Can anybody help me in solving this query since it's very urgent.
Following is the query (including some UDF's)
SELECT  T0.[U_PRNo],  T0.[DocNum] AS 'PO Number', T0.[DocDate] as 'Date of PO', T0.[CardName] as 'Vendor Name', T0.[DocDueDate] as 'Date of Delivery as per PO',sum(t1.linetotal) as 'Basic',
T15.linetotal as 'Freight  & P&F Amt', t0.DiscSum as 'Discount',
Sum(T2.TaxSum) as 'BEDAmt',
Sum(T3.TaxSum) as 'ECeSSAmt',
Sum(T4.TaxSum) as 'HECess Amt',
Sum(T5.TaxSum) as 'AED Amt',
Sum(T6.TaxSum) as 'CST along with Excise Amt',
Sum(T7.TaxSum) as 'CST Amt',
Sum(T8.TaxSum) as 'VAT Amt',
Sum(T9.TaxSum) as 'VAT along with Excise Amt',
SUM(T10.TaxSum) as 'CST on Freight Amt',
Sum(T11.TaxSum) as 'VAT on Freight Amt',
Sum(T12.TaxSum) as 'BED on Freight',
Sum(T13.TaxSum) as 'CESS on Freight',
Sum(T14.TaxSum) as 'HECESS on Freight',
t0.[DocTotal] as 'Total of PO',
t16.PymntGroup
FROM OPOR T0  INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry
left outer join por3 t15 on t15.docentry = t1.docentry
left outer join octg t16 on t16.groupnum = t0.groupnum
LEFT OUTER JOIN POR4 T2 ON T2.DocEntry=T0.DocEntry and T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum
                  LEFT OUTER JOIN POR4 T3 ON T3.DocEntry=T0.DocEntry and T0.DocEntry=T3.DocEntry AND T3.staType=-60 AND T1.LineNum=T3.LineNum
                  LEFT OUTER JOIN POR4 T4 ON T4.DocEntry=T0.DocEntry and T0.DocEntry=T4.DocEntry AND T4.staType=7 AND T1.LineNum=T4.LineNum
                  LEFT OUTER JOIN POR4 T5 ON T5.DocEntry=T0.DocEntry and T0.DocEntry=T5.DocEntry AND T5.staType=-80 AND T1.LineNum=T5.LineNum
                  LEFT OUTER JOIN POR4 T6 ON T6.DocEntry=T0.DocEntry and T0.DocEntry=T6.DocEntry AND T6.staType=13 AND T1.LineNum=T6.LineNum
                  LEFT OUTER JOIN POR4 T7 ON T7.DocEntry=T0.DocEntry and T0.DocEntry=T7.DocEntry AND T7.staType=4 AND T1.LineNum=T7.LineNum
                  LEFT OUTER JOIN POR4 T8 ON T8.DocEntry=T0.DocEntry and T0.DocEntry=T8.DocEntry AND T8.staType=1 AND T1.LineNum=T8.LineNum
LEFT OUTER JOIN POR4 T9 ON T9.DocEntry=T0.DocEntry and T0.DocEntry=T9.DocEntry AND T9.staType=14 AND T1.LineNum=T9.LineNum
LEFT OUTER JOIN POR4 T10 ON T10.DocEntry=T0.DocEntry and T0.DocEntry=T10.DocEntry AND T10.staType=26 AND T1.LineNum=T10.LineNum
LEFT OUTER JOIN POR4 T11 ON T11.DocEntry=T0.DocEntry and T0.DocEntry=T11.DocEntry AND T11.staType=25 AND T1.LineNum=T11.LineNum
LEFT OUTER JOIN POR4 T12 ON T12.DocEntry=T0.DocEntry and T0.DocEntry=T12.DocEntry AND T12.staType=22 AND T1.LineNum=T12.LineNum
LEFT OUTER JOIN POR4 T13 ON T13.DocEntry=T0.DocEntry and T0.DocEntry=T13.DocEntry AND T13.staType=23 AND T1.LineNum=T13.LineNum
LEFT OUTER JOIN POR4 T14 ON T14.DocEntry=T0.DocEntry and T0.DocEntry=T14.DocEntry AND T14.staType=24 AND T1.LineNum=T14.LineNum
WHERE T0.[DocDate] between '[%1]' and '[%2]'
group by T0.[U_PRNo],  T0.[DocNum], T0.[DocDate], T0.[CardName], T0.[DocDueDate],t0.[DocTotal],t0.DiscSum,t16.PymntGroup,T15.linetotaL
regards
KARTHIK

Hello Karthik,
Try this
SELECT Distinct T0.U_PRNo, T0.DocNum AS 'PO Number', T0.DocDate as 'Date of PO', T0.CardName as 'Vendor Name', T0.DocDueDate as 'Date of Delivery as per PO',sum(t1.linetotal) as 'Basic',
sum(T15.linetotal) as 'Freight & P&F Amt', t0.DiscSum as 'Discount',
Sum(T2.TaxSum) as 'BEDAmt',
Sum(T3.TaxSum) as 'ECeSSAmt',
Sum(T4.TaxSum) as 'HECess Amt',
Sum(T5.TaxSum) as 'AED Amt',
Sum(T6.TaxSum) as 'CST along with Excise Amt',
Sum(T7.TaxSum) as 'CST Amt',
Sum(T8.TaxSum) as 'VAT Amt',
Sum(T9.TaxSum) as 'VAT along with Excise Amt',
SUM(T10.TaxSum) as 'CST on Freight Amt',
Sum(T11.TaxSum) as 'VAT on Freight Amt',
Sum(T12.TaxSum) as 'BED on Freight',
Sum(T13.TaxSum) as 'CESS on Freight',
Sum(T14.TaxSum) as 'HECESS on Freight',
t0.DocTotal as 'Total of PO',
t16.PymntGroup
FROM OPOR T0 INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry
left outer join por3 t15 on t15.docentry = t1.docentry
left outer join octg t16 on t16.groupnum = t0.groupnum
LEFT OUTER JOIN POR4 T2 ON T2.DocEntry=T0.DocEntry and T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum
LEFT OUTER JOIN POR4 T3 ON T3.DocEntry=T0.DocEntry and T0.DocEntry=T3.DocEntry AND T3.staType=-60 AND T1.LineNum=T3.LineNum
LEFT OUTER JOIN POR4 T4 ON T4.DocEntry=T0.DocEntry and T0.DocEntry=T4.DocEntry AND T4.staType=7 AND T1.LineNum=T4.LineNum
LEFT OUTER JOIN POR4 T5 ON T5.DocEntry=T0.DocEntry and T0.DocEntry=T5.DocEntry AND T5.staType=-80 AND T1.LineNum=T5.LineNum
LEFT OUTER JOIN POR4 T6 ON T6.DocEntry=T0.DocEntry and T0.DocEntry=T6.DocEntry AND T6.staType=13 AND T1.LineNum=T6.LineNum
LEFT OUTER JOIN POR4 T7 ON T7.DocEntry=T0.DocEntry and T0.DocEntry=T7.DocEntry AND T7.staType=4 AND T1.LineNum=T7.LineNum
LEFT OUTER JOIN POR4 T8 ON T8.DocEntry=T0.DocEntry and T0.DocEntry=T8.DocEntry AND T8.staType=1 AND T1.LineNum=T8.LineNum
LEFT OUTER JOIN POR4 T9 ON T9.DocEntry=T0.DocEntry and T0.DocEntry=T9.DocEntry AND T9.staType=14 AND T1.LineNum=T9.LineNum
LEFT OUTER JOIN POR4 T10 ON T10.DocEntry=T0.DocEntry and T0.DocEntry=T10.DocEntry AND T10.staType=26 AND T1.LineNum=T10.LineNum
LEFT OUTER JOIN POR4 T11 ON T11.DocEntry=T0.DocEntry and T0.DocEntry=T11.DocEntry AND T11.staType=25 AND T1.LineNum=T11.LineNum
LEFT OUTER JOIN POR4 T12 ON T12.DocEntry=T0.DocEntry and T0.DocEntry=T12.DocEntry AND T12.staType=22 AND T1.LineNum=T12.LineNum
LEFT OUTER JOIN POR4 T13 ON T13.DocEntry=T0.DocEntry and T0.DocEntry=T13.DocEntry AND T13.staType=23 AND T1.LineNum=T13.LineNum
LEFT OUTER JOIN POR4 T14 ON T14.DocEntry=T0.DocEntry and T0.DocEntry=T14.DocEntry AND T14.staType=24 AND T1.LineNum=T14.LineNum
WHERE T0.DocDate between '%1' and '%2'
group by T0.U_PRNo, T0.DocNum, T0.DocDate, T0.CardName, T0.DocDueDate,t0.DocTotal,t0.DiscSum,t16.PymntGroup

Similar Messages

  • Warehouse wise Detailed query Report

    Please share detailed report on Warehouse wise, it consists of Purchase,Goods Receipt, Inventory Transfer,Invoices, sales return

    Hi Jain,
    Execute the query in RSRT or in RRMX. To Check how much time it is taking to execute this querry?? To get this information, Goto SE11> Give table name RSDDSTAT_DM in BI7.0 or RSDDSTAT in BW3.x> Display -> Contents-> Give from date and to date values as today, user name as Ur user name, and give the query name--> execute.
    Now u'll get a list with fields like Object name(Report name), Time read, Infoprovider name(Multiprovider), Partprovider name (Cube), Aggregate name... etc. If the time read is less than 100,000,000 (100 sec) is acceptable. If the time read is more than 100 sec then it is recommended to create Aggregates for that query to increase performance.
    Here in this table u'll find detailed Query Runtime Statistics.
    Hope thsi helps you..
    Regards,
    Ramki.

  • Passing YTD selection from a main query to a detailed query using RRI

    Hi,
    We have created two queries: one main query on an infocube for aggregated data, one detailed query on the feeding DSO for data at the level of sales document items.
    Both queries show monthly and YTD (year-to-date) actual cost figures.
    The user enters for instance the month of 05.2005 on the main query in a variable ZP_MONTH.
    A user exit variable ZS_YTD is calculated so that the interval 01.2005 - 05.2005 is stored in ZS_YTD.
    Revenues in the month are displayed in one column.
    Revenues in the YTD period are displayed in another column.
    Assume the data is displayed by document types.
    Then the user should select the document type and perform a jump target (Goto) to the detailed query to see which sales document items are contributing to the total revenues behind the document type.
    We have defined a ZS_YTD_2 variable on the detailed query.  It is used in the field assignments in the RSBBS transaction to receive the 0CALMONTH selection (in our case 01.2005 - 05.2005).  Then on the detailed query, we defined another userexit variable to capture the selected month based on ZS_YTD_2.
    Our issue is that when the user goes from the main query to the detailed query, the variable screen of the detailed query is being displayed with the variable ZS_YTD_2 open and the user can even change the selection there.
    Is it possible to remove the display of this intermediate variable screen?
    Thanks.

    Well.  If you unflag the variable for ready for input on the detailed query, then it is not possible for that variable to receive the period selected on the main query.  Even worse, the query crashes with the message that the variable is not correctly defined.
    Any other suggestion?
    Thanks.

  • Purchase register query based on down payment invoice

    Hai All,
    I am creating an invoice based on purchase order.The vat  tax is being calculated in the downpayment. I want the vat to be displayed in the downpayment invoice as well as the a/p invoice but i m not getting it in the a/p invoice. Pls guide me with the linking of tables to get the query working. I have formatted the fields req but could not link the tables...Pls guide me with that...
    Thanks & Regards,
    Neela

    Hi Neela,
    Check the thread.
    Re: Purchase register query based on down payment invoice
    FROM PCH1 T0
    INNER JOIN OPCH T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
    LEFT OUTER JOIN PCH12 T3 ON T1.DocEntry = T3.DocEntry
    LEFT JOIN ODPI T4 ON T1.CardCode = T4.CardCode
    INNER JOIN DPO1 T5 ON T0.ItemCode = T5.ItemCode
    Close the thread, if issue solved.
    Regards,
    Madhan.

  • In-App Purchase Details Access

    Is there a way to access In-App purchase Details of an IOS app in an Objective Program

    To Contact iTunes Support and request assistance Click  Here

  • Reference a field from master query in detail query

    Hi,
    Please tell me how do I reference a field say incident_no in my master query to a detail query.
    like
    detail.incident_no != master.incident_no
    I am joining both the queries using a link. But still I need to reference another field from the first query in my second query. I thought this was possible using formula columns or trigger's. Please help.

    Hey Vadim,
    That worked. How come.. You know I did it several times before and all it said was, that it was going to create a new parameter field called so and so.
    Good, so does it work just this time or always ? just kidding. Reports is so unpredictable, at least for me.
    Thanks Vadim,
    Joe.

  • Partywise & Itemwise purchase register query

    Dear Expert,
    I am new in SAP.
    I need Partywise & Itemwise purchase register query.
    BR
    Deep

    Dear Deep,
    Welcome To SAP Community Network Forum...
    Check this link...
    http://forums.sdn.sap.com/thread.jspa?messageID=6730337#6730337
    Thanks,
    Srujal Patel

  • My purchase details

    Dear sir,
    The given below my subscription purchase details, but still i can not get that subscrition
    First payment was taken on: Aug 4, 2013
    Next payment will be taken on: Sep 14, 2013
    Order reference: [removed for privacy]
    Total amount: $8.99

    Please visit the link below for possible answers;
    https://support.skype.com/en/faq/FA10416/why-isn-t-my-subscription-working
    Yet, if still needed, you can also contact customer support for further assistance or instructions. Just open the link pasted below to see the instructions on how to get in touch with customer service -
    https://support.skype.com/en/faq/FA1170/how-can-i-contact-skype-customer-service
    IF YOU FOUND OUR POST USEFUL THEN PLEASE GIVE "KUDOS". IF IT HELPED TO FIX YOUR ISSUE PLEASE MARK IT AS A "SOLUTION" TO HELP OTHERS. THANKS!
    ALTERNATIVE SKYPE DOWNLOAD LINKS | HOW TO RECORD SKYPE VIDEO CALLS | HOW TO HANDLE SUSPICIOS CALLS AND MESSAGES

  • Have uninstalled LR4 to start again. I have not retained original purchase details. How do I re download?

    Have uninstalled LR4 to start again. I have not retained original purchase details. How do I re download?

    Lightroom - all versions
    Windows
    http://www.adobe.com/support/downloads/product.jsp?product=113&platform=Windows
    Mac
    http://www.adobe.com/support/downloads/product.jsp?product=113&platform=Macintosh

  • Detailed Query Runtime Statistics - Substeps of Data manager Event

    Dear All,
    I am using the report for 0TCT_MC02_Q0200 to analyse the Detailed Query Runtime Statistics.
    The report shows that the Event 9000 (Data manager Event) took a time of 109 seconds.
    I would like to know as to what does the 9000 Data Manager Event that takes 109 seconds do for me.
    What is it doing for 109 seconds ????
    Can I have more details about the substeps of Data manager Event and time taken by them ???  Any Table or a report would suffice my requriement.
    Thanks
    Regards
    Shalabh

    Hi Jain,
    Execute the query in RSRT or in RRMX. To Check how much time it is taking to execute this querry?? To get this information, Goto SE11> Give table name RSDDSTAT_DM in BI7.0 or RSDDSTAT in BW3.x> Display -> Contents-> Give from date and to date values as today, user name as Ur user name, and give the query name--> execute.
    Now u'll get a list with fields like Object name(Report name), Time read, Infoprovider name(Multiprovider), Partprovider name (Cube), Aggregate name... etc. If the time read is less than 100,000,000 (100 sec) is acceptable. If the time read is more than 100 sec then it is recommended to create Aggregates for that query to increase performance.
    Here in this table u'll find detailed Query Runtime Statistics.
    Hope thsi helps you..
    Regards,
    Ramki.

  • ESOA: Enterprise Service for Purchase Requisition Query.

    Hi,
    I am not sure whether I am posting this question to the right forum, if not then please let me know the correct route.
    I am trying to test the standard enterprise service for purchase requisition query response. It brings all the purchase requisitions even though they are deleted and not appearing in MD04.
    Is there a way I can restrict and get only active purchase requistion. I am using the service PurchaseRequestItemByProductAndOrganisationalDataQueryResponse_In

    Not Answered.

  • I want to download free apps for iphone 4s but when downloading it is asking for payment info. the application are free but why it is asking for purchase details...please help me...

    I want to download free apps for iphone 4s but when downloading it is asking for payment info. the application are free but why it is asking for purchase details...please help me...

    In iTunes, click "Store", sign in with your Apple I.D. After singing in, click "Store" again, select "View my Account", re-enter your password and your account info will be displayed.
    Click "Edit" in front of "payment information" and select "None"

  • I'm trying to download a free game but it's says purchase details

    Hi can someone help me please I'm trying to download free games which I've done many times before now it's sayin purchase details wen its a free game

    Hey Jessy_vicky,
    Thanks for the question. Try changing your payment information to “None”. If you are unable to select “None” as a payment option, see the following resource:
    Why can’t I select None when I edit my payment information?
    http://support.apple.com/kb/TS5366
    Using an existing iTunes Store or App Store account
    If you have an unpaid balance or payment due, you can't select None as your payment type. To see which order you need to pay for, view your purchase history. When you sign in to the store, you may see a message that there was a billing issue with your last order. Click the Billing Info button to see the order.
    After you pay for the order, you can change your payment information to None.
    Additional Information:
    iTunes Store: My credit card's security code or zip code does not match my bank's records
    http://support.apple.com/kb/TS1646
    iTunes Store & Mac App Store: About payment card authorization holds
    http://support.apple.com/kb/HT3702
    Thanks,
    Matt M.

  • Pulling open invoices, and paid invoices with details (Query Help).

    Hello All,
    I am sure I messed something up in my joins. I am looking to pull a report of all invoices OINV for a month, then list details of any payment (if it is paid) next to it from RCT2. It is giving me a list of all of the paid invoices, but even though I have a LEFT JOIN it is not listing any of the invoices without payments.
    This is where I am now from the report wizard in Crystal.
    SELECT "OINV"."DocNum", "OINV"."SlpCode", "OINV"."CardCode", "OINV"."DocTotal", "OINV"."U_Commission", "OSLP"."SlpName", "RCT2"."DcntSum", "ORCT"."TaxDate", "OINV"."DocEntry", "OINV"."TotalExpns", "OINV"."CANCELED", "ORCT"."Canceled", "ORCT"."DocNum", "RCT2"."InvType"
    FROM   ("DBName"."dbo"."OINV" "OINV" LEFT OUTER JOIN "DBName"."dbo"."OSLP" "OSLP" ON "OINV"."SlpCode"="OSLP"."SlpCode")
    INNER JOIN ("DBName"."dbo"."ORCT" "ORCT" INNER JOIN "DBName"."dbo"."RCT2" "RCT2" ON "ORCT"."DocNum"="RCT2"."DocNum")
    ON "OINV"."DocEntry"="RCT2"."DocEntry"
    WHERE  "OINV"."CANCELED"='N' AND "ORCT"."Canceled"='N' AND "RCT2"."InvType"<=N'14'
    ORDER BY "OINV"."SlpCode", "ORCT"."DocNum", "ORCT"."TaxDate"
    Thank you in advance for any help you can give me.

    Hello Kiran,
    I thought about that, but my purposes for running the report is to determine commission based on the date that the invoice was paid, I need the TaxDate in ORCT as it relates to the payment in RCT2.
    Removing the ORCT.cancelled condition and the RCT2.invtype conditions now pulls all of the invoices, paid and unpaid. I know now I cant have them in my query, when the record does not exist in ORCT it doesnt have a value for cancelled, and when there is no record in RCT2 there is no invtype, and is filtered.
    Maybe I can say where ORCT.Canelled = 'N' OR ORCT.Cancelled = NULL, but I dont know if that would work.

  • Master-details query to XML file?

    Hi:
    I'm new in XML and Oracle. I want to create XML file from two tables (master-details).
    I made a small serach and tried some examples:
    Say we have these tables:
    CREATE TABLE "TEST_XML"
    (     "ID" NUMBER,
         "NAME" VARCHAR2(15),
         "AMOUNT" NUMBER,
         CONSTRAINT "TEST_XML_PK" PRIMARY KEY ("ID") ENABLE
    CREATE TABLE "TEST_XML2"
    (     "ID2" NUMBER,
         "NAME2" VARCHAR2(20),
         "AMOUNT2" NUMBER
    ALTER TABLE "TEST_XML2" ADD CONSTRAINT "TEST_XML2_FK" FOREIGN KEY ("ID2")
         REFERENCES "TEST_XML" ("ID") ENABLE
    INSERT INTO TEST_XML VALUES (1,'A',50);
    INSERT INTO TEST_XML VALUES (2,'B',30);
    INSERT INTO TEST_XML VALUES (3,'C',70);
    INSERT INTO TEST_XML2 VALUES (1,'AA',10);
    INSERT INTO TEST_XML2 VALUES (1,'AB',20);
    INSERT INTO TEST_XML2 VALUES (1,'AC',20);
    INSERT INTO TEST_XML2 VALUES (2,'BA',10);
    INSERT INTO TEST_XML2 VALUES (2,'BB',20);
    INSERT INTO TEST_XML2 VALUES (3,'CA',20);
    INSERT INTO TEST_XML2 VALUES (3,'CB',40);
    INSERT INTO TEST_XML2 VALUES (3,'CC',10);
    I want a query to create XML file contains data from TEST_XML table and for each row the related data from TEST_XML2 table.
    I did some tries (working in iSQL*PLUS):
    SET SERVEROUTPUT ON
    DECLARE
    v_ctx DBMS_XMLGEN.ctxType;
    v_file Utl_File.File_Type;
    v_xml CLOB;
    v_more BOOLEAN := TRUE;
    BEGIN
    -- Create XML document from query.
    v_ctx := DBMS_XMLGEN.newContext('select id,name,amount,cursor (select id2,name2,amount2 from test_xml2 t2 where t2.id2=t1.id) val from test_xml t1');
    DBMS_XMLGEN.setMaxRows(v_ctx, 10);
    DBMS_XMLGEN.setRowsetTag(v_ctx, 'CLAIM');
    -- Output XML document to file.
    v_file := Utl_File.FOpen('TEST_DIR', 'test1.xml', 'w');
    WHILE v_more
    LOOP
    v_xml := DBMS_XMLGEN.GetXML(v_ctx,0);
    EXIT WHEN dbms_xmlgen.getNumRowsProcessed(v_ctx) =0;
    Utl_File.Put(v_file,v_xml);
    END LOOP;
    Utl_File.FClose(v_file);
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,255));
    Utl_File.FClose(v_file);
    END;
    But hte output wasn't as I wanted:
    <CLAIM>
    <ROW>
    <ID>1</ID>
    <NAME>A</NAME>
    <AMOUNT>50</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AA</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AB</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AC</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    <ROW>
    <ID>3</ID>
    <NAME>C</NAME>
    <AMOUNT>70</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CA</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CB</NAME2>
    <AMOUNT2>40</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CC</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    <ROW>
    <ID>2</ID>
    <NAME>B</NAME>
    <AMOUNT>30</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>2</ID2>
    <NAME2>BA</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>2</ID2>
    <NAME2>BB</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    </CLAIM>
    Notice that for each details (from TEST_XML2) there is <VAL> tag which I don't need beside i want a query which is applicable on all environments.
    May anyone help me please......
    Regards,
    Saad

    The following looks like it produces your desired output. I used the WITH to simulate your two tables so I didn't have to CREATE them. This runs on 10.2.0.1. I'm not sure what bugs you are referring to as SQL/XML is stable in 10g that I have seen. I'm sure some bugs exist somewhere in it, just not with this usage. Just start with the SELECT statement to run on your system.
    WITH test_xml AS
    (SELECT 1 ID, 'A' name, 50 amount FROM DUAL UNION ALL
    SELECT 2, 'B', 30  FROM DUAL UNION ALL
    SELECT 3, 'C', 70  FROM DUAL),
    test_xml2 AS
    (SELECT 1 ID2, 'AA' name2, 10 amount2 FROM DUAL UNION ALL
    SELECT 1, 'AB', 20  FROM DUAL UNION ALL
    SELECT 1, 'AC', 20  FROM DUAL UNION ALL
    SELECT 2, 'BA', 10  FROM DUAL UNION ALL
    SELECT 2, 'BB', 20  FROM DUAL UNION ALL
    SELECT 2, 'BC', 20  FROM DUAL UNION ALL
    SELECT 3, 'CA', 20  FROM DUAL UNION ALL
    SELECT 3, 'CB', 40  FROM DUAL UNION ALL
    SELECT 3, 'CC', 10  FROM DUAL)
    SELECT XMLElement("CLAIM",
             XMLAgg(
               XMLElement("ROW",
                 XMLForest(id "ID",
                           name "NAME",
                           amount "AMOUNT"),
                 (SELECT XMLAgg(XMLElement("VAL_ROW",
                                 XMLForest(id2 "ID2",
                                           name2 "NAME2",
                                           amount2 "AMOUNT2")))
                          FROM test_xml2 t2
                         WHERE t2.id2=t1.id)
      FROM test_xml t1This solution works in any environment where you can issue a SQL statement from, be it SQL*Plus, PL/SQL, Java, etc.

Maybe you are looking for

  • Problem with Individual Registration of HTMLDB app schema with SSO

    I have successfully registered HTML DB instance as partner application to SSO and it works well. Then, I also want to try with Individual registration of partner application schemas on the same HTML DB instance. I have followed every steps in 'How-To

  • Apple script to join wireless network

    Hi, i was wondering if anyone had a resource or an actual script that they know of that would allow me to join a wireles network. the network name is "earth", and the ssid is hidden. the security is wep 40/128 - bit ACSII thank you

  • Change fonts in "Notes" ?!?

    Maybe I'm too dumb for this device but I couldn't find anywhere how to change fonts in "Notes" on my iTouch.....and I con't really believe Apple hasn't considered this... Any clues ?

  • Installing Oracle 10g on Solaris 7

    Hi, Can I install Oracle 10g R2 on Solaris 9? I tried searching for the answer on various forums but could not find anything direct. Thanks in advance!!

  • Working with objects \ beans inside a Swing.JTextPane

    javax.swing.text.html specifically javax.swing.text.html.ObjectVeiw Class Is it possible to set the size of on object, which is an instance of type Component Example Although these beans work fine, I can not set the width and height properties while