SQL - Group By / Order by question

I have a table MESSAGE with two columns.
SQL> desc message
Name Null? Type
MESSAGE_TEXT VARCHAR2(50)
MESSAGE_DATE DATE
My requirements are:
1) Display MESSAGE_TEXT and MESSAGE_DATE (Date only, no time component) in MESSAGE_DATE order (including time component).
2) Do not show multiple rows which have the same MESSAGE_TEXT and trunc(MESSAGE_DATE).
Given the following data:
SQL> select * from message;
MESSAGE_TEXT MESSAGE_DATE
Message Group 1 10/15/2002 13:00:00
Message Group 1 10/15/2002 14:00:00
Message Group 1 10/16/2002 15:00:00
Message Group 2 10/15/2002 14:00:00
Message Group 2 10/15/2002 16:00:00
Message Group 3 10/15/2002 13:30:00
Message Group 3 10/15/2002 17:00:00
I should return:
MESSAGE_TEXT MESSAGE_DATE
Message Group 1 10/15/2002
Message Group 3 10/15/2002
Message Group 2 10/15/2002
Message Group 1 10/16/2002
My first attempt to do this was:
SELECT MESSAGE_TEXT
, TO_CHAR(MESSAGE_DATE,'MM/DD/YYYY') FDATE
FROM MESSAGE
GROUP BY MESSAGE_TEXT, TO_CHAR(MESSAGE_DATE,'MM/DD/YYYY')
ORDER BY FDATE
but this did not work because it returned:
MESSAGE_TEXT FDATE
Message Group 1 10/15/2002
Message Group 2 10/15/2002
Message Group 3 10/15/2002
Message Group 1 10/16/2002
which violates requirement 1). Message Group 3 should appear before Message Group 2 because 13:30 comes before 14:00.
I ended up doing the following:
SELECT MESSAGE_TEXT
, TO_CHAR(MESSAGE_DATE,'MM/DD/YYYY') FDATE
FROM MESSAGE M1
WHERE NOT EXISTS
(SELECT *
FROM MESSAGE M2
WHERE M2.MESSAGE_TEXT = M1.MESSAGE_TEXT
AND TRUNC(M2.MESSAGE_DATE) = TRUNC(M1.MESSAGE_DATE)
AND M2.MESSAGE_DATE < M1.MESSAGE_DATE)
ORDER BY M1.MESSAGE_DATE
This gives me the right results, but surely there is a better way or ways. Please help.

SELECT   message_text,
         message_date_only AS message_date
FROM     (SELECT   message_text,
                   TO_CHAR (message_date, 'MM/DD/YYYY') AS message_date_only,
                   MIN (message_date) AS min_message_date_and_time
          FROM     message
          GROUP BY message_text, TO_CHAR (message_date, 'MM/DD/YYYY'))
ORDER BY min_message_date_and_time;
MESSAGE_TEXT    MESSAGE_DATE
Message Group 1 10/15/2002
Message Group 3 10/15/2002
Message Group 2 10/15/2002
Message Group 1 10/16/2002
4 rows selected.

Similar Messages

  • XML Publisher nested grouping, sum and order by question

    Please help in nested group by, sum and order by question
    My Data look like this:
    <Header>
    <Line1>
         <Part Number></Part Number>
              <Component>
                   <Component1></Component1>
                   <Component1 Amount></Component1 Amount>
              </Component>
              <Component>
                   <Component2></Component2>
                   <Component2 Amount></Component2 Amount>
              </Component>
    </Line1>
    <Line2>
         <Part Number></Part Number>
              <Component>
                   <Component1></Component1>
                   <Component1 Amount></Component1 Amount >
              </Component>
              <Component>
                   <Component2></Component2>
                   <Component2 Amount ></Component2 Amount >
              </Component>
    </Line2>
    </Header>
    I want to print report which is:
    1. Group by part number, component and sum the amount for a part number/component
    2. Order by part number, component
    Here is rtf file for XML publisher report
    <?for-each-group:G_LINES;PART_NUMBER?>
    <?sort:G_LINES;PART_NUMBER;'ascending';data-type='text'?>
    <?if:BREAKDOWN_COUNT>0?>
    Part Number: <?PART_NUMBER?>     Quantity: <?sum (current-group()/SHIP_QTY)?>          Part Count:<?count(current-group()/PART_NUMBER)?>     Breakdown Count:<?count(G_BREAKDOWN/COMPONENT)?>
    <?for-each:current-group()?>
    <?for-each-group:G_BREAKDOWN;COMPONENT?>
    Component: <?COMPONENT?>          Price: <?COMPONENT_PRICE?>
    <?end-for-each?>
    <?end-for-each?>
    <?end if?>
    <?end-for-each?>
    If I add <?sort:G_BREAKDOWN;COMPONENT;'ascending';data-type='text'?> inside G_BREAKDOWN grouping it gives error.
    My XML data file
    <?xml version="1.0"?>
    <!-- Generated by Oracle Reports version 6.0.8.25.0 -->
    <NI_COMMERCIAL_INVOICE_XMLP>
    <LIST_G_HEADER>
    <G_HEADER>
    <COMM_INV_NUMBER>C/901000598</COMM_INV_NUMBER>
    <COMM_INV_VERSION_NUMBER>1</COMM_INV_VERSION_NUMBER>
    <SHIP_FROM_NAME>National Instruments Europe Corp.</SHIP_FROM_NAME>
    <SHIP_FROM_ADDR>H-4031, Debrecen, Hatar ut 1/A</SHIP_FROM_ADDR>
    <SHIP_FROM_CITY></SHIP_FROM_CITY>
    <SHIP_FROM_STATE></SHIP_FROM_STATE>
    <SHIP_FROM_POSTAL_CODE></SHIP_FROM_POSTAL_CODE>
    <SHIP_FROM_COUNTRY>Hungary</SHIP_FROM_COUNTRY>
    <SHIP_TO_NAME>National Instruments Corporation (NIEC)</SHIP_TO_NAME>
    <FORMATTED_SHIP_TO_ADDR>11500 N Mopac Expwy
    Austin, TX 78759-3504
    United States</FORMATTED_SHIP_TO_ADDR>
    <SHIP_TO_ADDR1>11500 N Mopac Expwy</SHIP_TO_ADDR1>
    <SHIP_TO_ADDR2></SHIP_TO_ADDR2>
    <SHIP_TO_ADDR3></SHIP_TO_ADDR3>
    <SHIP_TO_ADDR4></SHIP_TO_ADDR4>
    <SHIP_TO_CITY>Austin</SHIP_TO_CITY>
    <SHIP_TO_STATE>TX </SHIP_TO_STATE>
    <SHIP_TO_POSTAL_CODE>78759-3504</SHIP_TO_POSTAL_CODE>
    <SHIP_TO_COUNTRY>US</SHIP_TO_COUNTRY>
    <SHIP_TO_EMAIL_ADDR></SHIP_TO_EMAIL_ADDR>
    <BILL_TO_ORG_ID>807737</BILL_TO_ORG_ID>
    <SHIPPED_VIA>UPS</SHIPPED_VIA>
    <DELIVERY_TERM>DDU</DELIVERY_TERM>
    <TEXT_FILE_SEPARATOR></TEXT_FILE_SEPARATOR>
    <DELIVERY_COUNT>4</DELIVERY_COUNT>
    <HEADER_WAYBILL></HEADER_WAYBILL>
    <LIST_G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629769</DELIVERY_ID>
    <ORDER_HEADER_ID>1431282</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004434</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-387</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4565737</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>26818</INVENTORY_ITEM_ID>
    <PART_NUMBER>777459-23</PART_NUMBER>
    <PART_DESC>SCC-AI04, 2-CHANNEL ISOLATED ANALOG INPUT</PART_DESC>
    <PART_CUSTOM_DESC>SCC-AI04, Automatic Data Processing Plug-In Board</PART_CUSTOM_DESC>
    <PLANNER_CODE>SCXIH-MPS</PLANNER_CODE>
    <HTS_CODE>8471.80.9000</HTS_CODE>
    <TARIC_CODE>8471.80.0000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>158</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>4</ORIG_SHIP_QTY>
    <UNIT_PRICE>158</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>158</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>4</SHIP_QTY>
    <EXTENDED_PRICE>632</EXTENDED_PRICE>
    <UNIT_WEIGHT>.16</UNIT_WEIGHT>
    <NET_WEIGHT>.64</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/01 NIC</WAYBILL>
    <BREAKDOWN_COUNT>0</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE></BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE></BREAKDOWN_VALUE>
    <COMPONENT></COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE></COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO></COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629769</DELIVERY_ID>
    <ORDER_HEADER_ID>1431282</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004434</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-387</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4579950</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>143949</INVENTORY_ITEM_ID>
    <PART_NUMBER>779475-01</PART_NUMBER>
    <PART_DESC>SCC-68 I/O CONNECTOR BLOCK WITH 4 SCC SIGNAL CONDITIONING MODULE SLOTS</PART_DESC>
    <PART_CUSTOM_DESC>SCC-68, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>DAQH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>144</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>10</ORIG_SHIP_QTY>
    <UNIT_PRICE>144</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>144</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>10</SHIP_QTY>
    <EXTENDED_PRICE>1440</EXTENDED_PRICE>
    <UNIT_WEIGHT>1.06</UNIT_WEIGHT>
    <NET_WEIGHT>10.6</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/01 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>50</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>10</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>20</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>1370</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629822</DELIVERY_ID>
    <ORDER_HEADER_ID>1425429</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004365</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-372</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4579940</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>22643</INVENTORY_ITEM_ID>
    <PART_NUMBER>777687-20</PART_NUMBER>
    <PART_DESC>SCXI-1320 TEMPERATURE SENSOR TERMINAL BLOCK, CAST</PART_DESC>
    <PART_CUSTOM_DESC>SCXI-1320, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>SCXIH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>82</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>1</ORIG_SHIP_QTY>
    <UNIT_PRICE>82</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>82</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>1</SHIP_QTY>
    <EXTENDED_PRICE>82</EXTENDED_PRICE>
    <UNIT_WEIGHT>.57</UNIT_WEIGHT>
    <NET_WEIGHT>.57</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/02 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>5</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>1</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>2</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>75</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629822</DELIVERY_ID>
    <ORDER_HEADER_ID>1427673</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004391</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-377</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4579948</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>143949</INVENTORY_ITEM_ID>
    <PART_NUMBER>779475-01</PART_NUMBER>
    <PART_DESC>SCC-68 I/O CONNECTOR BLOCK WITH 4 SCC SIGNAL CONDITIONING MODULE SLOTS</PART_DESC>
    <PART_CUSTOM_DESC>SCC-68, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>DAQH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>144</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>13</ORIG_SHIP_QTY>
    <UNIT_PRICE>144</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>144</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>13</SHIP_QTY>
    <EXTENDED_PRICE>1872</EXTENDED_PRICE>
    <UNIT_WEIGHT>1.06</UNIT_WEIGHT>
    <NET_WEIGHT>13.78</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/02 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>65</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>13</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>26</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>1781</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2630021</DELIVERY_ID>
    <ORDER_HEADER_ID>1429687</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004410</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-383</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4578220</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>61816</INVENTORY_ITEM_ID>
    <PART_NUMBER>777687-14</PART_NUMBER>
    <PART_DESC>SCXI-1314 FRONT MOUNTING TERMINAL BLOCK</PART_DESC>
    <PART_CUSTOM_DESC>SCXI-1314, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>SCXIH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>120</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>4</ORIG_SHIP_QTY>
    <UNIT_PRICE>120</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>120</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>4</SHIP_QTY>
    <EXTENDED_PRICE>480</EXTENDED_PRICE>
    <UNIT_WEIGHT>.68</UNIT_WEIGHT>
    <NET_WEIGHT>2.72</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/03 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>20</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>4</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>452</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>8</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2630054</DELIVERY_ID>
    <ORDER_HEADER_ID>1435114</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004463</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-396</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4580160</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>96909</INVENTORY_ITEM_ID>
    <PART_NUMBER>778729-01</PART_NUMBER>
    <PART_DESC>NI PCI-4474, 4 INPUTS, 24-BIT DYNAMIC SIGNAL ACQUISITION</PART_DESC>
    <PART_CUSTOM_DESC>PCI-4474, Automatic Data Processing Plug-In Board</PART_CUSTOM_DESC>
    <PLANNER_CODE>INSTRHMPS</PLANNER_CODE>
    <HTS_CODE>8471.80.4000</HTS_CODE>
    <TARIC_CODE>8471.80.0000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>960</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>4</ORIG_SHIP_QTY>
    <UNIT_PRICE>960</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>960</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>4</SHIP_QTY>
    <EXTENDED_PRICE>3840</EXTENDED_PRICE>
    <UNIT_WEIGHT>.68</UNIT_WEIGHT>
    <NET_WEIGHT>2.72</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/04 NIC</WAYBILL>
    <BREAKDOWN_COUNT>0</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE></BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE></BREAKDOWN_VALUE>
    <COMPONENT></COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE></COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO></COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    </LIST_G_LINES>
    </G_HEADER>
    </LIST_G_HEADER>
    </NI_COMMERCIAL_INVOICE_XMLP>
    I want my report for part number (which has multiple component) look like:
    Part Number: 779475-01     Quantity: 23          Part Count:2     Breakdown Count:6
    Component: CD          Amount: 115
    Component: IP          Amount: 3151
    Component: Paper          Amount: 46
    Any help or suggestion is appreciated
    RK Shah
    [email protected]

    I am using the latest 10.1.3.2.1 build 87.
    The output that I see is :
    Part Number: 777687-14 Quantity: 4 Part Count:1 Breakdown Count:3
    Component: CD
    Count: 4
    Sum of Component Price: 20
    Component: IP
    Count: 0
    Sum of Component Price: 452
    Component: Paper
    Count: 0
    Sum of Component Price: 8
    Part Number: 777687-20 Quantity: 1 Part Count:1 Breakdown Count:3
    Component: CD
    Count: 1
    Sum of Component Price: 5
    Component: Paper
    Count: 0
    Sum of Component Price: 2
    Component: IP
    Count: 0
    Sum of Component Price: 75
    Part Number: 779475-01 Quantity: 23 Part Count:2 Breakdown Count:3
    Component: CD
    Count: 23
    Sum of Component Price: 115
    Component: Paper
    Count: 0
    Sum of Component Price: 46
    Component: IP
    Count: 0
    Sum of Component Price: 3151
    and the XML data that I used is :
    <?xml version="1.0"?>
    <!-- Generated by Oracle Reports version 6.0.8.25.0 -->
    <NI_COMMERCIAL_INVOICE_XMLP>
    <LIST_G_HEADER>
    <G_HEADER>
    <COMM_INV_NUMBER>C/901000598</COMM_INV_NUMBER>
    <COMM_INV_VERSION_NUMBER>1</COMM_INV_VERSION_NUMBER>
    <SHIP_FROM_NAME>National Instruments Europe Corp.</SHIP_FROM_NAME>
    <SHIP_FROM_ADDR>H-4031, Debrecen, Hatar ut 1/A</SHIP_FROM_ADDR>
    <SHIP_FROM_CITY></SHIP_FROM_CITY>
    <SHIP_FROM_STATE></SHIP_FROM_STATE>
    <SHIP_FROM_POSTAL_CODE></SHIP_FROM_POSTAL_CODE>
    <SHIP_FROM_COUNTRY>Hungary</SHIP_FROM_COUNTRY>
    <SHIP_TO_NAME>National Instruments Corporation (NIEC)</SHIP_TO_NAME>
    <FORMATTED_SHIP_TO_ADDR>11500 N Mopac Expwy
    Austin, TX 78759-3504
    United States</FORMATTED_SHIP_TO_ADDR>
    <SHIP_TO_ADDR1>11500 N Mopac Expwy</SHIP_TO_ADDR1>
    <SHIP_TO_ADDR2></SHIP_TO_ADDR2>
    <SHIP_TO_ADDR3></SHIP_TO_ADDR3>
    <SHIP_TO_ADDR4></SHIP_TO_ADDR4>
    <SHIP_TO_CITY>Austin</SHIP_TO_CITY>
    <SHIP_TO_STATE>TX </SHIP_TO_STATE>
    <SHIP_TO_POSTAL_CODE>78759-3504</SHIP_TO_POSTAL_CODE>
    <SHIP_TO_COUNTRY>US</SHIP_TO_COUNTRY>
    <SHIP_TO_EMAIL_ADDR></SHIP_TO_EMAIL_ADDR>
    <BILL_TO_ORG_ID>807737</BILL_TO_ORG_ID>
    <SHIPPED_VIA>UPS</SHIPPED_VIA>
    <DELIVERY_TERM>DDU</DELIVERY_TERM>
    <TEXT_FILE_SEPARATOR></TEXT_FILE_SEPARATOR>
    <DELIVERY_COUNT>4</DELIVERY_COUNT>
    <HEADER_WAYBILL></HEADER_WAYBILL>
    <LIST_G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629769</DELIVERY_ID>
    <ORDER_HEADER_ID>1431282</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004434</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-387</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4565737</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>26818</INVENTORY_ITEM_ID>
    <PART_NUMBER>777459-23</PART_NUMBER>
    <PART_DESC>SCC-AI04, 2-CHANNEL ISOLATED ANALOG INPUT</PART_DESC>
    <PART_CUSTOM_DESC>SCC-AI04, Automatic Data Processing Plug-In Board</PART_CUSTOM_DESC>
    <PLANNER_CODE>SCXIH-MPS</PLANNER_CODE>
    <HTS_CODE>8471.80.9000</HTS_CODE>
    <TARIC_CODE>8471.80.0000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>158</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>4</ORIG_SHIP_QTY>
    <UNIT_PRICE>158</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>158</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>4</SHIP_QTY>
    <EXTENDED_PRICE>632</EXTENDED_PRICE>
    <UNIT_WEIGHT>.16</UNIT_WEIGHT>
    <NET_WEIGHT>.64</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/01 NIC</WAYBILL>
    <BREAKDOWN_COUNT>0</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE></BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE></BREAKDOWN_VALUE>
    <COMPONENT></COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE></COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO></COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629769</DELIVERY_ID>
    <ORDER_HEADER_ID>1431282</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004434</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-387</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4579950</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>143949</INVENTORY_ITEM_ID>
    <PART_NUMBER>779475-01</PART_NUMBER>
    <PART_DESC>SCC-68 I/O CONNECTOR BLOCK WITH 4 SCC SIGNAL CONDITIONING MODULE SLOTS</PART_DESC>
    <PART_CUSTOM_DESC>SCC-68, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>DAQH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>144</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>10</ORIG_SHIP_QTY>
    <UNIT_PRICE>144</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>144</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>10</SHIP_QTY>
    <EXTENDED_PRICE>1440</EXTENDED_PRICE>
    <UNIT_WEIGHT>1.06</UNIT_WEIGHT>
    <NET_WEIGHT>10.6</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/01 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>50</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>10</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>20</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>1370</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629822</DELIVERY_ID>
    <ORDER_HEADER_ID>1425429</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004365</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-372</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4579940</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>22643</INVENTORY_ITEM_ID>
    <PART_NUMBER>777687-20</PART_NUMBER>
    <PART_DESC>SCXI-1320 TEMPERATURE SENSOR TERMINAL BLOCK, CAST</PART_DESC>
    <PART_CUSTOM_DESC>SCXI-1320, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>SCXIH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>82</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>1</ORIG_SHIP_QTY>
    <UNIT_PRICE>82</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>82</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>1</SHIP_QTY>
    <EXTENDED_PRICE>82</EXTENDED_PRICE>
    <UNIT_WEIGHT>.57</UNIT_WEIGHT>
    <NET_WEIGHT>.57</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/02 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>5</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>1</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>2</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>75</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2629822</DELIVERY_ID>
    <ORDER_HEADER_ID>1427673</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004391</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-377</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4579948</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>143949</INVENTORY_ITEM_ID>
    <PART_NUMBER>779475-01</PART_NUMBER>
    <PART_DESC>SCC-68 I/O CONNECTOR BLOCK WITH 4 SCC SIGNAL CONDITIONING MODULE SLOTS</PART_DESC>
    <PART_CUSTOM_DESC>SCC-68, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>DAQH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>144</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>13</ORIG_SHIP_QTY>
    <UNIT_PRICE>144</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>144</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>13</SHIP_QTY>
    <EXTENDED_PRICE>1872</EXTENDED_PRICE>
    <UNIT_WEIGHT>1.06</UNIT_WEIGHT>
    <NET_WEIGHT>13.78</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/02 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>65</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>13</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>26</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>1781</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2630021</DELIVERY_ID>
    <ORDER_HEADER_ID>1429687</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004410</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-383</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4578220</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>61816</INVENTORY_ITEM_ID>
    <PART_NUMBER>777687-14</PART_NUMBER>
    <PART_DESC>SCXI-1314 FRONT MOUNTING TERMINAL BLOCK</PART_DESC>
    <PART_CUSTOM_DESC>SCXI-1314, Screw Terminals</PART_CUSTOM_DESC>
    <PLANNER_CODE>SCXIH-MPS</PLANNER_CODE>
    <HTS_CODE>8536.90.4000</HTS_CODE>
    <TARIC_CODE>8536.90.1000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>120</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>4</ORIG_SHIP_QTY>
    <UNIT_PRICE>120</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>120</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>4</SHIP_QTY>
    <EXTENDED_PRICE>480</EXTENDED_PRICE>
    <UNIT_WEIGHT>.68</UNIT_WEIGHT>
    <NET_WEIGHT>2.72</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/03 NIC</WAYBILL>
    <BREAKDOWN_COUNT>3</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>CD</COMPONENT>
    <COMPONENT_DESC>Test1</COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>20</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2803.00.0050</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE>Test1</COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY>4</COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>IP</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>452</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE>HTS CODE</BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE>8536.90.4000</BREAKDOWN_VALUE>
    <COMPONENT>Paper</COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE>8</COMPONENT_PRICE>
    <COMPONENT_HTS_CODE>2839.90.0000</COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO>HU</COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    <G_LINES>
    <DELIVERY_ID>2630054</DELIVERY_ID>
    <ORDER_HEADER_ID>1435114</ORDER_HEADER_ID>
    <ORDER_NUMBER>10004463</ORDER_NUMBER>
    <CUST_PO_NUMBER>310986-396</CUST_PO_NUMBER>
    <ORDER_LINE_ID>4580160</ORDER_LINE_ID>
    <INVENTORY_ITEM_ID>96909</INVENTORY_ITEM_ID>
    <PART_NUMBER>778729-01</PART_NUMBER>
    <PART_DESC>NI PCI-4474, 4 INPUTS, 24-BIT DYNAMIC SIGNAL ACQUISITION</PART_DESC>
    <PART_CUSTOM_DESC>PCI-4474, Automatic Data Processing Plug-In Board</PART_CUSTOM_DESC>
    <PLANNER_CODE>INSTRHMPS</PLANNER_CODE>
    <HTS_CODE>8471.80.4000</HTS_CODE>
    <TARIC_CODE>8471.80.0000</TARIC_CODE>
    <COUNTRY_OF_ORIGIN>HU</COUNTRY_OF_ORIGIN>
    <ORDER_CURRENCY_CODE>USD</ORDER_CURRENCY_CODE>
    <ORIG_UNIT_PRICE>960</ORIG_UNIT_PRICE>
    <ORIG_SHIP_QTY>4</ORIG_SHIP_QTY>
    <UNIT_PRICE>960</UNIT_PRICE>
    <PRICE_CALC_STEP_NUMBER>100</PRICE_CALC_STEP_NUMBER>
    <PRICE_CALC_CURRENCY_CODE>USD</PRICE_CALC_CURRENCY_CODE>
    <PRICE_CALC_UNIT_PRICE>960</PRICE_CALC_UNIT_PRICE>
    <PRICE_CALC_CONV_RATE>1</PRICE_CALC_CONV_RATE>
    <SHIP_QTY>4</SHIP_QTY>
    <EXTENDED_PRICE>3840</EXTENDED_PRICE>
    <UNIT_WEIGHT>.68</UNIT_WEIGHT>
    <NET_WEIGHT>2.72</NET_WEIGHT>
    <ACQ_SOURCE_CODE></ACQ_SOURCE_CODE>
    <ACQ_ORDER_NUMBER></ACQ_ORDER_NUMBER>
    <ACQ_SOURCE_ORDER_NUMBER></ACQ_SOURCE_ORDER_NUMBER>
    <ACQ_SELLING_PRICE>0</ACQ_SELLING_PRICE>
    <SUBINVENTORY>NIEC Stage</SUBINVENTORY>
    <SHIP_TO_SITE_USE_ID>807736</SHIP_TO_SITE_USE_ID>
    <FREIGHT_COST>0</FREIGHT_COST>
    <PAYMENT_TERMS>NIH InterCo</PAYMENT_TERMS>
    <WAYBILL>901000598/04 NIC</WAYBILL>
    <BREAKDOWN_COUNT>0</BREAKDOWN_COUNT>
    <LIST_G_BREAKDOWN>
    <G_BREAKDOWN>
    <BREAKDOWN_TYPE></BREAKDOWN_TYPE>
    <BREAKDOWN_VALUE></BREAKDOWN_VALUE>
    <COMPONENT></COMPONENT>
    <COMPONENT_DESC></COMPONENT_DESC>
    <COMPONENT_CUSTOM_DESC></COMPONENT_CUSTOM_DESC>
    <COMPONENT_PRICE></COMPONENT_PRICE>
    <COMPONENT_HTS_CODE></COMPONENT_HTS_CODE>
    <COMPONENT_TARIC_CODE></COMPONENT_TARIC_CODE>
    <COMPONENT_COO></COMPONENT_COO>
    <COMPONENT_QTY></COMPONENT_QTY>
    </G_BREAKDOWN>
    </LIST_G_BREAKDOWN>
    </G_LINES>
    </LIST_G_LINES>
    </G_HEADER>
    </LIST_G_HEADER>
    </NI_COMMERCIAL_INVOICE_XMLP>

  • EA1 - SQL Formatter issues (JOINs and GROUPs and ORDER BY oh my ;)

    Great job with improving the SQL Formatter, but it still has some bugs that need to be worked out.
    The key words JOIN and it's modifiers INNER, LEFT, RIGHT and FULL OUTER are not recognized as master key words. As such they end up flush against the left margin Also when GROUP BY and/or ORDER BY key words are present in an outer most select statement the other key words are not indented far enough to be right aligned with the end of the word BY and are indented too far to be right aligned with the word GROUP or ORDER. In sub queries, GROUP and ORDER BY are correctly right aligned with their respective SELECT statements.

    We're picking up and collating the Formatter issues. I'll add these.
    Specific bug for these #7013462
    Sue

  • Getting first row in a group by order by sql

    Hi all,
    I'm having problems with the query below. What I want is to get a count of hotelid and group it then take the top result. My problem is that the version of oracle that I'm using is giving me errors because of the nested group by, order by. Is there any way around this?
    SELECT *
    FROM (SELECT agentid, hotelid, COUNT(hotelid) AS COUNT
    FROM akorders a, akworklist_summary b
    WHERE a.agentid = 1408946 AND
    a.akorderid = b.akorderid
    GROUP BY agentid, hotelid
    ORDER BY COUNT DESC)
    WHERE ROWNUM < 2
    TIA!
    Brian

    SELECT agentid, hotelid, COUNT(hotelid) AS COUNT
    FROM akorders a, akworklist_summary b
    WHERE a.agentid = 1408946 AND
    a.akorderid = b.akorderid
    GROUP BY agentid, hotelid
    HAVING COUNT(*) = (SELECT MAX(icount)
                       FROM (SELECT agentid, hotelid, COUNT(hotelid) AS icount
                             FROM akorders a, akworklist_summary b
                             WHERE a.agentid = 1408946 AND
                                   a.akorderid = b.akorderid
                                   GROUP BY agentid, hotelid ))

  • Need Help With SQL GROUP BY and DISTINCT

    I am working on a project and need to display the total of each order based on the order id. For instance I want to display the order id, customer id, order date, and then the extension price (ol_quantity * inv_price).
    I would then like a total displayed for order # 1 and then move on to order #2.
    Here is my SQL code :
    SELECT DISTINCT orders.o_id, customer.c_id, inv_price * ol_quantity
    FROM orders, customer, inventory, order_line
    GROUP BY orders.o_id, customer.c_id, inv_price, ol_quantity
    ORDER BY orders.o_id;
    When my code is run it displays the order id, customer id and inv_price * quantity (extension price) but no order total for the order number and a new group is not started when a new order number is started....they are all clumped together.
    Any help is greatly appreciated!!

    Hi,
    user12036843 wrote:
    I am working on a project and need to display the total of each order based on the order id. For instance I want to display the order id, customer id, order date, and then the extension price (ol_quantity * inv_price).
    I would then like a total displayed for order # 1 and then move on to order #2.
    Here is my SQL code :
    SELECT DISTINCT orders.o_id, customer.c_id, inv_price * ol_quantity
    FROM orders, customer, inventory, order_line
    GROUP BY orders.o_id, customer.c_id, inv_price, ol_quantity
    ORDER BY orders.o_id;
    When my code is run it displays the order id, customer id and inv_price * quantity (extension price) but no order total for the order number and a new group is not started when a new order number is started....they are all clumped together.
    Any help is greatly appreciated!!Sorry, it's unclear what you want.
    Whenever you post a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.
    Do you want the output to contain one row for each row in the table, plus an extra row for each distinct order, showing something about the order as a whole (e.g., total inv_price or average extension_price)? If so, you need GROUP BY ROLLUP or GROUP BY GROUPING SETS .
    If you want one row of output for each row of the table, but you want to include something that reflects the group as a whole (again, e.g, total inv_prive or average extension_pcie), then you can us analytic functions. (Most of the aggregate functions, such as SUM and AVG have analytic counterparts that can get the same results without collapsing the result set down to one row per group.)
    Here's an example of how to use GROUP BY GROUPING SETS.
    Way we're interested in employees' salary and commission from the scott.emp table:
    SELECT       deptno
    ,       ename
    ,       sal
    ,       comm
    FROM       scott.emp
    ORDER BY  deptno
    ,            ename
    ;Output:
    `   DEPTNO ENAME             SAL       COMM
            10 CLARK            2450
            10 KING             5000
            10 MILLER           1300
            20 ADAMS            1100
            20 FORD             3000
            20 JONES            2975
            20 SCOTT            3000
            20 SMITH             800
            30 ALLEN            1600        300
            30 BLAKE            2850
            30 JAMES             950
            30 MARTIN           1250       1400
            30 TURNER           1500          0
            30 WARD             1250        500Now say we want to add the total income (sal + comm, or just sal if there is no comm) to each row, and also to add a row for each department showing the total sal, comm and income in that department, like this:
    `   DEPTNO ENAME             SAL       COMM     INCOME
            10 CLARK            2450                  2450
            10 KING             5000                  5000
            10 MILLER           1300                  1300
            10                  8750                  8750
            20 ADAMS            1100                  1100
            20 FORD             3000                  3000
            20 JONES            2975                  2975
            20 SCOTT            3000                  3000
            20 SMITH             800                   800
            20                 10875                 10875
            30 ALLEN            1600        300       1900
            30 BLAKE            2850                  2850
            30 JAMES             950                   950
            30 MARTIN           1250       1400       2650
            30 TURNER           1500          0       1500
            30 WARD             1250        500       1750
            30                  9400       2200      11600(This relies on the fact that ename is unique.) Getting those results is pretty easy, using GROUPING SETS:
    SELECT       deptno
    ,       ename
    ,       SUM (sal)          AS sal
    ,       SUM (comm)          AS comm
    ,       SUM ( sal
               + NVL (comm, 0)
               )               AS income
    FROM       scott.emp
    GROUP BY  GROUPING SETS ( (deptno)
                             , (deptno, ename)
    ORDER BY  deptno
    ,            ename
    ;Notice that we're displaying SUM (sal) on each row. Most of the rows in the output are "groups" consisting of only one row from the table, so the SUM (sa) for that goup will be the sal for the one row in the group.
    Edited by: Frank Kulash on Nov 23, 2011 2:03 PM
    Added GROUPING SET example

  • Sql group function

    I am trying to calculate the average cost of the books for each customer. The output should contain the customer#, name and the average order.
    This is the code I have:
    SELECT AVG(SUM((retail-cost)*quantity))
    FROM orders JOIN orderitems USING (order#)
    JOIN books USING (isbn)
    JOIN customers USING (customer#)
    GROUP BY order#, customer#;
    I get either, over 8000 for the average order or about 33 for the average order when I don't include the name, customer number or anything else in the code. If I add any other information, I get:
    SELECT customer#, AVG(SUM((retail-cost)*quantity))
    ERROR at line 1:
    ORA-00937: not a single-group group function
    I'm sure there is something small that I am missing, but cannot see it.

    Hi,
    Whenever you have a question, you should post a little sample data and the results you want to get from that data.
    I don't know where you're coming from, or where you want ot go, so it's hard to give you good directions. All I have is your current route plan, which must be incorrect, or else you wouldn't be asking anything.
    I see you are nesting aggregate functions. That's very rare in real life, and the result is always to produce one row of output, regardless of what's in the GROUP BY clause.
    I suspect you want to do a SUM in a sub-query, and then do AVG on the results in the main query. Without seeing your sample data and desired results, I'm just guessing.

  • What are the key fields used to group double orders in t-code SDD1?

    What are the key fields used to group double orders in t-code SDD1?
    Cheers,
    VT

    Hi,
    You can group the duplicate sales documents with the help of the following fields,
    Sold-To-Party,Document type,date and sales area details.
    Regards,
    Gopal.

  • Use Handling Units to group production orders?

    Hello,
    can I use Handling Units to group production orders together? We have a workcenter where all our orders go through and we'd like to group, say, the morning's orders in a single HU on which we could post a single transaction (batch?) instead of posting on each and every order.
    Thanks,
    Jonathan

    Please check OSS note 793168.

  • XK03 can be restricted by account group in order to prevent general users

    Hello Gurus,
    Please advise, if XK03 can be restricted by account group in order to prevent general user population from displaying employee data ?
    I understand that XK03 has auth object  F_LFA1_GRP for account group in which I restricted with 03 and particular account groups but still the test is failing because the test user is able to view employee data.
    Please suggest..
    Regard's
    Salman

    Hi Alex,
    Thank you !
    By your last update, do you mean auth group or account group? If you are talking about auth group then this auth object F_LFA1_BEK (XK03) has auth group.
    I checked the F_LFA1_GRP  is active in SU24. Is there something which i need to look in F_LFA1_BEK for particular auth group after restricting the auth object F_LFA1_GRP with account group ?
    Thank you for your valuable suggestions
    Regard's
    Salman

  • Query for Group by & order by

    Hi all,
    I have a table name as angdata77 having attributes like asigno..
    i want to retrieve data from angdata77 by using both group by & order by clauses.. for total count..
    am using the query as
    select asigno,count(*) from angdata77 group by asigno order by asigno;
    Is there any other query for retrieving the data from angdata77
    Thanks in Advance,
    Venkatesh J.

    885756 wrote:
    Ya it's good.. Performance also good while retrieving data...
    I want to know other Possibilities also sir...There will be no better alternative for this, because this is the most simple and straight forward way to get the output you are looking for..
    Go ahead without any confusion... :)

  • Problem with group by/order by clause when using huge data

    Hi,
    I'm using below query on my table of size more than 210 million rows.
    SELECT booking_date FROM T_UTR
    WHERE four_eyes_status = 'A' AND booking_date <= '01-jul-2005' AND booking_date >= '01-jan-2004'
    AND invoice_id IS NULL AND link_id = 12345
    AND billing_indicator = 'L'
    GROUP BY booking_date ORDER BY booking_date
    If I'm skipping last line "GROUP BY booking_date ORDER BY booking_date", its giving me immediate result, but, because of group by/order by, the query may take 30 seconds to 2 minutes based on the data fetched for the date range. It may vary from 2 to 2 million rows, & grouping by for so many rows at run time will automatically take some time.
    Here I want to know, is there any procedure in oracle(any function based index) so that I can store/retrieve distinct values for link_id, & booking_date without grouping them at run time. Or the performance of the query can be increased
    Thanks
    Deepak

    Hi,
    You can use Materialized Views as stated earlier - specifically by using Query Rewrite. If the conditions on columns "four_eyes_status", "invoice_id", and "billing_indicator" never change in your query - then you can create a Materialized View that is targeted for those conditions and has lower cardinality (since you aren't grouping by those columns). The "COUNT(*)" allows the use of the DISTINCT operator in addition to "GROUP BY' as well for Query Rewrite.
    Create the Materialized View like this:
    CREATE MATERIALIZED VIEW test_mv1
    BUILD IMMEDIATE
    USING NO INDEX
    REFRESH FORCE ON DEMAND
    ENABLE QUERY REWRITE
    AS
    SELECT booking_date
         , link_id
         , COUNT(*) AS count_star
    FROM T_UTR
    WHERE four_eyes_status = 'A'
      AND invoice_id IS NULL
      AND billing_indicator = 'L'
    GROUP BY booking_date
           , link_id ;To improve performance further - create an index on the "LINK_ID" column like this:
    CREATE INDEX test_mv1_link_id_idx
    ON test_mv1 (link_id);Then - gather stats immediately on the Materialized View so that the CBO can use it for rewriting your original query - like this:
    BEGIN
       DBMS_STATS.gather_table_stats (ownname               => USER
                                    , tabname               => 'TEST_MV1'
                                    , partname              => NULL
                                    , estimate_percent      => DBMS_STATS.auto_sample_size
                                    , block_sample          => FALSE
                                    , method_opt            => 'FOR ALL COLUMNS SIZE 1'
                                    , degree                => NULL
                                    , granularity           => 'ALL'
                                    , cascade               => TRUE
                                    , no_invalidate         => FALSE
    END;
    /Now - the CBO should be able to rewrite your original query to use the Materialized View - provided you set up your session for Query Rewrite like this:
    ALTER SESSION SET query_rewrite_enabled = TRUE;
    ALTER SESSION SET query_rewrite_integrity = ENFORCED; -- set this to whatever staleness you can tolerate - see the docs for details...Now - after setting up your session - try running your query with autotrace to see if it was rewritten...
    Good luck!
    Message was edited by:
    PDaddy

  • GROUP BY & ORDER BY  in a Report

    How to Implement GROUP BY & ORDER BY in a Report?

    Hi,
    Order by: It is possible to sort the char value according to the values (asc or desc) of an atribute of this char...is this what you were looking for?
    Group by: May be can be achieved by drilldwon sequence, with the grouping char to the left of the char values to be grouped...again, is this what you had in mind?

  • Please help: WebLogic + BI + SQL Group Authenticator

    Hi all, i have big problem with solution on my company project. I please somebody help me.
    This is my problem:
    I have bifoundation_domain :
    WebLogic Server Version: 10.3.5.0
    EM 11g
    Oracle Business Intelligence 11.1.1.7.0
    with this structure:
    bifoundation_domain
    |- AdminServer
    |- bi_cluster
      |- bi_server1
    So and i need use Weblogic embedded LDAP (DefaultAuthenticator in realms security providers) and i need loading GROUPS from DATABASE. I read and tried a lot of articles, blogs, manuals but
    within positive result.
    My procedure is:
    In WLS console :
    - create jdbc datasource with name "bip_apps_DS"
    - create BI SQL Group provider (with name BIGroupLoader) with this settings
    <sec:authentication-provider xmlns:ext="http://xmlns.oracle.com/weblogic/security/extension" xsi:type="ext:bisql-group-providerType">
      <sec:name>BIGroupLoader</sec:name>
      <sec:control-flag>OPTIONAL</sec:control-flag>
      <ext:data-source-jndi-name>bip_apps_DS</ext:data-source-jndi-name>
      <ext:sql-list-member-groups>SELECT ROLE_NAME FROM V_SYS_AUTH_ROLES WHERE LOGIN_NAME = ?</ext:sql-list-member-groups>
      <ext:sql-list-groups>SELECT NAME FROM UA_ROLES WHERE NAME LIKE ?</ext:sql-list-groups>
      <ext:sql-group-exists>SELECT NAME FROM UA_ROLES WHERE NAME = ?</ext:sql-group-exists>
      <ext:sql-is-member>SELECT LOGIN_NAME FROM V_SYS_AUTH_ROLES WHERE ROLE_NAME = ? AND LOGIN_NAME = ?</ext:sql-is-member>
      <ext:sql-get-group-description>SELECT DESCRIPTION FROM UA_ROLES WHERE NAME = ?</ext:sql-get-group-description>
    </sec:authentication-provider>
    (my DB schema is correct)
    and i move him on first place in providers list.
    So after these steps in WLS console i see in security realm->groups my groups from DB. Everything is OK.
    Now i need use GROUPS from my database in EM in the context of create BI users roles (maping BI application roles on GROUPS (enterprise roles)).
    So i created a database adapter for the Virtualized Identity Store
    this is it:
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <adapters schvers="303" version="1" xmlns="http://www.octetstring.com/schemas/Adapters" xmlns:adapters="http://www.w3.org/2001/XMLSchema-instance">
      <dataBase id="directoryType" version="0">
      <root>%ROOT%</root>
      <active>true</active>
      <serverType>directoryType</serverType>
      <routing>
      <critical>true</critical>
      <priority>50</priority>
      <inclusionFilter/>
      <exclusionFilter/>
      <plugin/>
      <retrieve/>
      <store/>
      <visible>Yes</visible>
      <levels>-1</levels>
      <bind>true</bind>
      <bind-adapters/>
      <views/>
      <dnpattern/>
      </routing>
      <pluginChains xmlns="http://xmlns.oracle.com/iam/management/ovd/config/plugins">
      <plugins>
      <plugin>
      <name>VirtualAttribute</name>
      <class>oracle.ods.virtualization.engine.chain.plugins.virtualattr.VirtualAttributePlugin</class>
      <initParams>
      <param name="ReplaceAttribute" value="uniqueMember={cn=%uniquemember%,ou=people,ou=myrealm,dc=bifoundation_domain}"/>
      </initParams>
      </plugin>
      </plugins>
      <default>
      <plugin name="VirtualAttribute"/>
      </default>
      <add/>
      <bind/>
      <delete/>
      <get/>
      <modify/>
      <rename/>
      </pluginChains>
      <driver>oracle.jdbc.driver.OracleDriver</driver>
      <url>%URL%</url>
      <user>%USER%</user>
      <password>%PASSWORD%</password>
      <ignoreObjectClassOnModify>false</ignoreObjectClassOnModify>
      <includeInheritedObjectClasses>true</includeInheritedObjectClasses>
      <maxConnections>10</maxConnections>
      <mapping>
      <joins/>
      <objectClass name="groupofuniquenames" rdn="cn">
      <attribute ldap="cn" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
      <attribute ldap="description" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
      <attribute ldap="uniquemember" table="V_SYS_AUTH_ROLES" field="LOGIN_NAME" type=""/>
      </objectClass>
      </mapping>
      <useCaseInsensitiveSearch>true</useCaseInsensitiveSearch>
      <connectionWaitTimeout>10</connectionWaitTimeout>
      <oracleNetConnectTimeout>0</oracleNetConnectTimeout>
      <validateConnection>false</validateConnection>
      </dataBase>
    </adapters>
    and run command to register:
    ./libovdadapterconfig.sh -adapterName BIGroupLoader -adapterTemplate bi_sql_groups_adapter_template.xml
    -host localhost -port 7001 -userName weblogic -domainPath /OFM/BI/user_projects/domains/bifoundation_domain
    -dataStore DB -root ou=people,ou=myrealm,dc=bifoundation_domain -contextName default -dataSourceJNDIName bip_apps_DS
    Adapter is creatted successfully within errors!
    I restarted managed server(bi_server1) and AdminServer, all bi commponets etc. BUT WITHOUT RESULT. I still dont see GROUPS in Enterprise manager in
    BI->coreapplication->security->application roles
    I tried set in security setting of webLogic domain in EM virtualize=true.
    This procedure is described on all sites but not funkcionaly for me. Do you know somebody where is mistake? Etc. need i installing OVD server? I dont know. Please helm me. after 10 days i really hopeless :( ..so sorry for my english

    If you are still looking for sol? send me email  [email protected]

  • Please help: WebLogic + BI + Bi SQl Group Loader

    Hi all, i have big problem with solution on my company project. I please somebody help me.
    This is my problem:
    I have bifoundation_domain :
    WebLogic Server Version: 10.3.5.0
    EM 11g
    Oracle Business Intelligence 11.1.1.7.0
    with this structure:
    bifoundation_domain
    |- AdminServer
    |- bi_cluster
      |- bi_server1
    So and i need use Weblogic embedded LDAP (DefaultAuthenticator in realms security providers) and i need loading GROUPS from DATABASE. I read and tried a lot of articles, blogs, manuals but
    within positive result.
    My procedure is:
    In WLS console :
    - create jdbc datasource with name "bip_apps_DS"
    - create BI SQL Group provider (with name BIGroupLoader) with this settings
    <sec:authentication-provider xmlns:ext="http://xmlns.oracle.com/weblogic/security/extension" xsi:type="ext:bisql-group-providerType">
      <sec:name>BIGroupLoader</sec:name>
      <sec:control-flag>OPTIONAL</sec:control-flag>
      <ext:data-source-jndi-name>bip_apps_DS</ext:data-source-jndi-name>
      <ext:sql-list-member-groups>SELECT ROLE_NAME FROM V_SYS_AUTH_ROLES WHERE LOGIN_NAME = ?</ext:sql-list-member-groups>
      <ext:sql-list-groups>SELECT NAME FROM UA_ROLES WHERE NAME LIKE ?</ext:sql-list-groups>
      <ext:sql-group-exists>SELECT NAME FROM UA_ROLES WHERE NAME = ?</ext:sql-group-exists>
      <ext:sql-is-member>SELECT LOGIN_NAME FROM V_SYS_AUTH_ROLES WHERE ROLE_NAME = ? AND LOGIN_NAME = ?</ext:sql-is-member>
      <ext:sql-get-group-description>SELECT DESCRIPTION FROM UA_ROLES WHERE NAME = ?</ext:sql-get-group-description>
    </sec:authentication-provider>
    (my DB schema is correct)
    and i move him on first place in providers list.
    So after these steps in WLS console i see in security realm->groups my groups from DB. Everything is OK.
    Now i need use GROUPS from my database in EM in the context of create BI users roles (maping BI application roles on GROUPS (enterprise roles)).
    So i created a database adapter for the Virtualized Identity Store
    this is it:
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <adapters schvers="303" version="1" xmlns="http://www.octetstring.com/schemas/Adapters" xmlns:adapters="http://www.w3.org/2001/XMLSchema-instance">
      <dataBase id="directoryType" version="0">
      <root>%ROOT%</root>
      <active>true</active>
      <serverType>directoryType</serverType>
      <routing>
      <critical>true</critical>
      <priority>50</priority>
      <inclusionFilter/>
      <exclusionFilter/>
      <plugin/>
      <retrieve/>
      <store/>
      <visible>Yes</visible>
      <levels>-1</levels>
      <bind>true</bind>
      <bind-adapters/>
      <views/>
      <dnpattern/>
      </routing>
      <pluginChains xmlns="http://xmlns.oracle.com/iam/management/ovd/config/plugins">
      <plugins>
      <plugin>
      <name>VirtualAttribute</name>
      <class>oracle.ods.virtualization.engine.chain.plugins.virtualattr.VirtualAttributePlugin</class>
      <initParams>
      <param name="ReplaceAttribute" value="uniqueMember={cn=%uniquemember%,ou=people,ou=myrealm,dc=bifoundation_domain}"/>
      </initParams>
      </plugin>
      </plugins>
      <default>
      <plugin name="VirtualAttribute"/>
      </default>
      <add/>
      <bind/>
      <delete/>
      <get/>
      <modify/>
      <rename/>
      </pluginChains>
      <driver>oracle.jdbc.driver.OracleDriver</driver>
      <url>%URL%</url>
      <user>%USER%</user>
      <password>%PASSWORD%</password>
      <ignoreObjectClassOnModify>false</ignoreObjectClassOnModify>
      <includeInheritedObjectClasses>true</includeInheritedObjectClasses>
      <maxConnections>10</maxConnections>
      <mapping>
      <joins/>
      <objectClass name="groupofuniquenames" rdn="cn">
      <attribute ldap="cn" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
      <attribute ldap="description" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
      <attribute ldap="uniquemember" table="V_SYS_AUTH_ROLES" field="LOGIN_NAME" type=""/>
      </objectClass>
      </mapping>
      <useCaseInsensitiveSearch>true</useCaseInsensitiveSearch>
      <connectionWaitTimeout>10</connectionWaitTimeout>
      <oracleNetConnectTimeout>0</oracleNetConnectTimeout>
      <validateConnection>false</validateConnection>
      </dataBase>
    </adapters>
    and run command to register:
    ./libovdadapterconfig.sh -adapterName BIGroupLoader -adapterTemplate bi_sql_groups_adapter_template.xml
    -host localhost -port 7001 -userName weblogic -domainPath /OFM/BI/user_projects/domains/bifoundation_domain
    -dataStore DB -root ou=people,ou=myrealm,dc=bifoundation_domain -contextName default -dataSourceJNDIName bip_apps_DS
    Adapter is creatted successfully within errors!
    I restarted managed server(bi_server1) and AdminServer, all bi commponets etc. BUT WITHOUT RESULT. I still dont see GROUPS in Enterprise manager in
    BI->coreapplication->security->application roles
    I tried set in security setting of webLogic domain in EM virtualize=true.
    This procedure is described on all sites but not funkcionaly for me. Do you know somebody where is mistake? Etc. need i installing OVD server? I dont know. Please helm me.

    Hi,
    You will not be able to see groups that you have defined in database in EM. To assign a database group to a role in EM go to BI->coreapplication->security->application roles & search for groups locate Advance Option at the bottom and check the box "Check to enter principal name here instead of searching from above. This option can be used for advanced scenarios related to custom authenticators". Now select Groups under Type and enter the name (exactly same) of the database group manually. Now you should be able to assign database groups to users authenticated through weblogic embedded LDAP.
    Thanks

  • Add new payment group to order.

    I want to add extra payment group to order.I can use order.addpaymentgroup and addrelationship.is this right approach?
    I read somewhere it's not good approach to add relationship this way.
    Please ssuggest how can i add new payment group to order.

    You dont need to create the relationship explicitly. OrderManager, PaymentGroupManager, CommerceItemManager etc gives some method to support split payment groups and that will create the relationship.
    For example, in case if you want to use half of the order amount to one Payment Group called PG1 and remaining to PG2, you can use the below approach.
    OrderManager.addOrderAmountToPaymentGroup(Order, PG1.id (payment group id), amount), this method will create a relationship and assign the amount to that payment group.
    Next, you need to set the remaining amount to PG2,
    OrderManager.addRemainingItemAmountToPaymentGroup(Order, PG2.id), this will add the remaining amount to PG2 and create the relationship.
    Similiar methods are available in the manager classes mentioned above, check API docs for details.
    Cheers
    R

Maybe you are looking for

  • ICloud not restoring my photos in the camera roll. HELP ! :(

    Apparently I had to reset my iphone but before doing this I checked if my back up was updated with icloud and IT WAS! After sucessfully completing the reset process I found out that all my stuff is back (contacts, notes, reminders etc.) EXCEPT the ph

  • Where can I purchase a Windows 7 Pro or Windows 8 Pro recovery discs?

    Guys, I have a Thinkpad T500 which I installed an Oracle Linux OS. Now I want to restore my gear to a Windows 7 or Windows 8 pro. My question is where can I buy from Lenovo the said recovery discs? P.S. I lost my recovery discs and I need one to reco

  • Calling Adobe Interactive Form from a selection screen

    Hi, I have to design an interactive adobe form online scenario,it goes like this : A certain tcode will call a selection screen when we enter values in the selection screen it will open an adobe form,which will have a submit button,on clicking the bu

  • Down payment query

    hi, Do down payment requests entered through FBA1 (Transaction type-A, Special GL indicater-F) show up in FBL5N report? I have one credit item of $1000 showing as open item in FBL5N. And if I go in BSID table it shows two open itemsof $1000, one cred

  • PS: planned costs by activity type

    Hi experts, I have a problem about an activity type. I have created an activity type and planned it on a cost center. This activity type is inserted in a work center with standard formala key "SAP003". I insert my activity type in an internal process