How the PivotTable in the query?

Hi all

SELECT COUNT (C.entity_id) as Entity_Id,

e.Description IN the region,

d.business_initials AS business_group

Of

(SELECT a.entity_id,

a.Region,

B.business_group

Ms_fcr_entity_reg a.,

ms_fcr_entity_bus b

WHERE a.entity_id = b.entity_id

AND B.business_group NOT IN ('Citi Commercial Bank - (BCC)', ' Global Consumer Group - (GCG) ")

) C,.

ms_fcr_business_group_data d,

e ms_fcr_managed_geography

WHERE C.region = e.managed_geography_id

AND C.business_group = d.business_group_id

Group E.DESCRIPTION,

d.business_initials;

my putting is like that

entity_id region market

190. THE NAM BCC

40 NAM COR

CPB NAM 106

189 NAM GCG

168 NAM ICG

40 NAM MLS

but I need output like this

AREA BG (CWB) BG (COR) BG (CPB) BG (GCG) BG (ICG) BG (MLS)

NAM 190 40 106 189 168 40

Thank you

Dale

Try this,

WITH T1 AS
(SELECT COUNT (C.entity_id) as Entity_Id,

e.Description IN the region,

d.business_initials AS business_group

Of

(SELECT a.entity_id,

a.Region,

B.business_group

Ms_fcr_entity_reg a.,

ms_fcr_entity_bus b

WHERE a.entity_id = b.entity_id

AND B.business_group NOT IN ('Citi Commercial Bank - (BCC)', ' Global Consumer Group - (GCG) ")

) C,.

ms_fcr_business_group_data d,

e ms_fcr_managed_geography

WHERE C.region = e.managed_geography_id

AND C.business_group = d.business_group_id

Group E.DESCRIPTION,

d.business_initials
)
SELECT * FROM T1
PIVOT (MAX (entity_id) AS BG FOR (MARKET) IN ('BCC' "COR", "Mutual FUND", "MCM", "ICG", "MLS"))
;

Tags: Database

Similar Questions

  • Can we make several Off features in a collection of panels and how the query-off based on the example?

    Mr President.

    Can we make several Off features in a collection of panels and how the query-off based on the example?

    Concerning

    Once again, no jdev version?

    It must be really hard to remember ehich version you are working.

    Would have given a quick glance in the docs

    featuresOff java.util.Set Yes a list separated by spaces of the features by default to disable to the panelCollection. Values supported are

    That is the answer to a message.

    The second answer is that qbe is filtering tables. If you fund the table without filter you have not the qbe.

    Timo

  • How the query tool is active?

    Hello!

    I am writing a plugin Photoshop to disable itself when certain tools are active.

    I added a reminder to the select event, based on the example of the listener and I am especially pleased with the results.

    Here is my callback function:

    http://pastebin.com/dWGRVTEw

    However, I have three problems with this method:

    (1) Photoshop does not send the active tool to plugins at startup.

    (2) in an older version of Photoshop, some tools are not all trigger the callback.

    (3) if the user selects a tool preset, my reminder Gets the string of the class 'toolPreset', any type of tool is selected in the preset.

    So my question is this: is there a better way to get the current active tool?

    Is there by chance a way to query, rather than rely on an event reminder?

    I've looked through the plugin API docs but can't find anything that looked relevant.

    Please notify.

    Thank you

    Guillaume

    Hello

    So after having received very useful assistance and suggestions from Chris Cox and Tom Ruark, here is what I did.

    (3) I added a new feature that uses the function Get of PSActionControlProcs. With that, I am able to correctly query the active tool when I receive a reminder to select event.

    Here's the code for this function: http://pastebin.com/HSW98Y7g

    Note that this will not work for older versions than CS3.

    (2) I can nothing what should I do for this.

    (1) I register an event slowed at startup reminder and call my request during the first callback function. I then cancel the reminder of the idle event. If I see that the request failed, then I guess that it is an older version of PS, and I use the old method for the select event reminder.

    I hope this helps someone!

    Do not hesitate to contact me if you need more details.

    See you soon,.

    Guillaume

  • How to activate the query suggestions

    How the query suggestions can be enabled in the Firefox address bar?

    You're welcome... good to know you got it working.

  • How can I get a query in the search field to open in a new tab or a new window, and the current window?

    How can I get a query in the search field to open in a new tab or a new window, and the current window?

    If you are looking through the search bar in the Navigation toolbar, this preference can be changed to research it open in a tab.

    Type of topic: config in the address bar and press ENTER. Then answer "I'll be careful." Type this pref in the search at the top.

    Browser.Search.openintab = double click to switch to true

  • When, on my home page, I click on the link "transparent popup" in the query "did you mean: transparent popup", NO RESULTS appear in this new tab; How to solve?

    I had trouble due, apparently, to a file named popuptransparent [dot] xul, which I have 3 cases on my computer (Win XP/Firefox last v.). Using my window of AVG home page, I get "popuptransparent" (try to fix) and the results appear OK. But then when I click to a new tab, on the "transparent popup" link in the query "did you mean: transparent popup", NO RESULTS appear in this new tab. In addition, when I reload then the Panel of AVG which sought to 'popuptransparent' in the first place, it, too, shows now no results. Or a panel shows Google now no results. They show the quantity of results, but just white screens for the results themselves.

    Links https://support.mozilla.org/en-US/questions/948804?esab=a & as = aaq and https://support.mozilla.org/en-US/questions/952141?esab=a & as = aaq brings me. I re-installed Firefox v. 20.0.1 nothing works. How to fix?

    Should I remove it from my computer all 3 of these instances of xul [dot]?

    Regarding the problem of searching, you can check the extension "Disconnect"? I think it could affect the Google sites and third parties who use Google. You can disable or try its button Options here:

    Firefox orange (or the Tools menu) button > addons > Extensions category

    While you're there, you can disable all extensions essential and unrecognized. When in doubt, turn off.

    After restarting Firefox, did you notice a difference?

    Could you explain in more detail the next part?

    Should I remove it from my computer all 3 of these instances of xul [dot]?

    Is this something that came in a security sweep? What question do you think they are originally? They are located in a folder extensions?

  • How to store the query string value in the scope of the session in webcenter spaces?

    Hello

    I want to store the query string value (which is given from URL) in the sessionScope variable. According to the value of sessionScope beacause I went some components inside my taskflow. Can someone help me how to store this value in the scope of the session. I use webcenter spaces for my application development.

    Thank you

    Ashok.

    Please see the article below

    How to pass a parameter of argument the query URL to a parameter input workflow? (Doc ID 1545808.1).

  • How to make the query more efficient

    Hi all

    I use the following query in my app that works very well. Although I'm not an expert in PL/SQL, can someone please suggest how can I make the query more efficient? Because I use the same contract for every query table. Only difference is that in the name of the condition column. Again I am showing same column comments for each request. I was wondering if I can join these 3 and do 1 single request if possible

    DECLARE
    v_CONTRACTNO varchar2(100);
    v_CHILDCONTRACTNO varchar2(100);
    v_SOURCESYSTEM varchar2(100);
    
    BEGIN
    begin
    SELECT comments
    into v_CONTRACTNO
    from user_col_comments
      where TABLE_NAME = 'CONTRACT'
    and COLUMN_NAME = 'CONTRACTNO';
    end;
    begin
    SELECT comments
    into v_CHILDCONTRACTNO
    from user_col_comments
      where TABLE_NAME = 'CONTRACT'
    and COLUMN_NAME = 'CHILDCONTRACTNO';
    end;
    begin
    SELECT comments
    into v_SOURCESYSTEM
    from user_col_comments
      where TABLE_NAME = 'CONTRACT'
    and COLUMN_NAME = 'SOURCESYSTEM';
    end;
    END;
    

    Thanks in advance...

    Concerning

    Nabila

    Hi, Nabila,

    The nabila Islam wrote:

    Hi all

    I use the following query in my app that works very well. Although I'm not an expert in PL/SQL, can someone please suggest how can I make the query more efficient? Because I use the same contract for every query table. Only difference is that in the name of the condition column. Again I am showing same column comments for each request. I was wondering if I can join these 3 and do 1 single request if possible

    1. DECLARE
    2. v_CONTRACTNO varchar2 (100);
    3. v_CHILDCONTRACTNO varchar2 (100);
    4. v_SOURCESYSTEM varchar2 (100);
    5. BEGIN
    6. Start
    7. SOME comments
    8. in v_CONTRACTNO
    9. of user_col_comments
    10. where TABLE_NAME = 'CONTRACT '.
    11. and COLUMN_NAME = 'CONTRACTNO ';
    12. end;
    13. Start
    14. SOME comments
    15. in v_CHILDCONTRACTNO
    16. of user_col_comments
    17. where TABLE_NAME = 'CONTRACT '.
    18. and COLUMN_NAME = 'CHILDCONTRACTNO ';
    19. end;
    20. Start
    21. SOME comments
    22. in v_SOURCESYSTEM
    23. of user_col_comments
    24. where TABLE_NAME = 'CONTRACT '.
    25. and COLUMN_NAME = 'SOURCESYSTEM ';
    26. end;
    27. END;

    Thanks in advance...

    Concerning

    Nabila

    Of course, you can get all 3 values in a query.  Here's one way:

    SELECT contractno, childcontractno, sourcesystem

    IN v_contractno, v_childcontractno, v_sourcesystem

    Of user_col_comments

    PIVOT (MIN (comments)

    FOR column_name IN ('CONTRACTNO' AS contractno

    'CHILDCONTRACTNO' AS childcontractno

    'SOURCESYSTEM' AS sourcesystem

    )

    )

    WHERE table_name = 'CONTRACT '.

    ;

    But I doubt that it makes things very slow.   If your PL/SQL performance is poor, I suspect that the cause is somewhere that you haven't posted.

  • SQL query takes too long to run (1 h 25 min)... pls help how to set up the query.

    Hello

    Could someone please help how to tune the query as its takes a long time to retrieve the results.

    Select

    col1,

    col2,

    col3,

    COL4,

    col5,

    col6,

    col7,

    COL8,

    col9,

    col10,

    Col11,

    col12,

    Sum (volume1),

    Sum (volume2),

    Sum (volume3),

    Sum (volume4),

    Sum (volume5),

    Sum (volume6),

    Sum (volume7),

    Sum (volume8),

    Sum (volume9),

    Sum (volume10),

    Sum (volume11),

    Sum (volume12),

    Sum (volume13),

    Sum (volume14),

    Sum (volume15),

    Sum (volume16),

    Sum (volume17),

    Sum (Volume18),

    Sum (volume19),

    Sum (volume20),

    Sum (rate1),

    Sum (rate2),

    Sum (rate3),

    Sum (rate4),

    Sum (rate5),

    Sum (rate6),

    Sum (rate7),

    Sum (rate8),

    Sum (rate9),

    Sum (rate10),

    Sum (rate11),

    Sum (rate12),

    Sum (rate13),

    Sum (rate14),

    Sum (rate15),

    Sum (rate16),

    Sum (rate17),

    Sum (rate18)

    Sum (rate19),

    Sum (rate20)

    Of

    Table 1 - 13, 25, 99, 400 records

    Table2 - 13, 45, 1000 records

    Table 3 - 4, 50, 000 records

    Table 4 - 1,00,000 records

    table5 - 30 000 records

    where tabl1.col1 = table2.col2,

    Table1.Col1 = table3.col1.

    table2.col2 = table3.col2...

    Group

    Sum (volume1),

    Sum (volume2),

    Sum (volume3),

    Sum (volume4),

    Sum (volume5),

    Sum (volume6),

    Sum (volume7),

    Sum (volume8),

    Sum (volume9),

    Sum (volume10),

    Sum (volume11),

    Sum (volume12),

    Sum (volume13),

    Sum (volume14),

    Sum (volume15),

    Sum (volume16),

    Sum (volume17),

    Sum (Volume18),

    Sum (volume19),

    Sum (volume20),

    Sum (rate1),

    Sum (rate2),

    Sum (rate3),

    Sum (rate4),

    Sum (rate5),

    Sum (rate6),

    Sum (rate7),

    Sum (rate8),

    Sum (rate9),

    Sum (rate10),

    Sum (rate11),

    Sum (rate12),

    Sum (rate13),

    Sum (rate14),

    Sum (rate15),

    Sum (rate16),

    Sum (rate17),

    Sum (rate18)

    Sum (rate19),

    Sum (rate20)

    Thank you

    Prasad.

    > Could someone please help how to tune the query as its takes a long time to retrieve the results.

    The query you posted is obviously fake.

    If you ask to give us a request that you do not post and we cannot see.

    For real?

  • How can I set the default value of a selection in the Query Panel with table.

    Hi Experts,

    JDev 12.1.3.0.0

    I have a view Criteria (contains a attribute with LOV). and the named criteria is dragged as a query with Table Panel.

    In the user interface, the LOV is now visible in the query Panel. Suppose that the LOV has 3 values: 'Manual', 'Other' and 'portfolio '.

    How can I set a default value for the choice of a select. ?

    Thank you

    Roy

    refer to:

    Andrejus Baranovskis Blog: Dynamic value by default for the field in query ADF search

    but rather to express as in the bellows of the image, choose literal and let 2

  • How to execute the query automatically when a query is added, Panel

    Hello

    Jdev: 12.1.3

    I added a queryPanel (af:query) on my Page. Everything works fine when I do a search.

    I wish I had the original Version to run the query that is executed automatically when loading the page. How can this be achieved?

    What I have to do this explicitly, or is it a property that I can use?

    See you soon

    AJ

    You can generate the default display criteria again, setting the mode to automatic query.

    You generate default criteria by adding each attribute to a criterion without specifying and literal bind variable.

    Timo

  • How to exclude the result of the query of account?

    I am stuck how can I update my request.

    Can anyone help please?

    CREATE TABLE "LOGON"."LOGON_DATA" 
       ( "CLIENT" VARCHAR2(20 BYTE) NOT NULL ENABLE,
      "ROW_ID" NUMBER NOT NULL ENABLE, 
      "OUR_ACCOUNT" VARCHAR2(1 BYTE), 
      "DATE_OF_LOGON" VARCHAR2(20 BYTE) NOT NULL ENABLE, 
      "LOGON_ID" NUMBER NOT NULL ENABLE, 
        );
    

    SAMPLE of DATA (for a "client" for a day):

    PETER123,021,N,10-01-2015,121514
    PETER123,022,,10-01-2015,121514
    PETER123,023,N,10-01-2015,221514
    PETER123,024,Y,10-01-2015,221514
    PETER123,025,Y,10-01-2015,221514
    PETER123,026,Y,10-01-2015,221514
    PETER123,027,Y,10-01-2015,221514
    PETER123,028,N,10-01-2015,221514
    PETER123,029,,10-01-2015,221559
    PETER123,030,Y,10-01-2015,221600
    PETER123,189,N,10-01-2015,225601
    PETER123,201,Y,10-01-2015,233539
    

    ...

    10 million lines

    12 c - 12.1.0.1.1 - I used 'insert' in SQL Developer to load Oracle data.

    The query below counts everything after the first 'our_account' = there is found and excludes in double "logon_id" County, but...

    WITH    got_first_row_id    AS
    (
        SELECT  client, logon_id
        ,       row_id
        ,       MIN ( CASE
                          WHEN  our_account  = 'Y'
                          THEN  row_id
                      END
                    ) OVER (PARTITION BY  client)   AS first_row_id
        FROM    LOGON_DATA
        where date_of_logon = '10-01-2015'
    )
    SELECT    client, COUNT(DISTINCT logon_id) AS cnt
    FROM      got_first_row_id
    WHERE     row_id  > first_row_id 
    GROUP BY  client
    order by COUNT(DISTINCT logon_id) desc;
    

    .. .but how can I also exclude "logon_id" number which is + 1 in the previous result?

    i.e.

    If my result will be logon_id = 225500 - I don't want to count the 225501 but I count on 225502

    The query must rely to the extent indicated in pink:

    PETER123, 021, N-10-01-2015, 121514

    PETER123, 022, 10-01-2015, 121514

    PETER123, 023, N-10-01-2015, 221514

    PETER123, 024, Y, 10-01-2015, 221514

    PETER123, 025, Y, 10-01-2015, 221514

    PETER123, 026, Y, 10-01-2015, 221514

    PETER123, 027, Y, 10-01-2015, 221514

    PETER123, 028, N-10-01-2015, 221514

    PETER123, 029, 10-01-2015, 221559

    PETER123, 030, Y, OCTOBER 1 00

    PETER123, 189, N-10-01-2015, 225601

    PETER123, 201, Y, 10-01-2015, 233539

    the expected result would be

    customer, cnt

    PETER123, 4

    Very appreciated for any help.

    Using

    If I understand your problem, the implementation in your case might be like this:

    WITH evaluated_logons AS

    (SELECT

    customer,

    logon_id,

    ROW_ID,

    MIN (DECODE (our_account, 'Y', row_id)) compared to first_row_id (partition by customer).

    LAG (logon_id, 1, -1) on previous_logon_id (partition sales order by logon_id)

    OF logon_data

    WHERE date_of_logon = TO_DATE (1 October 2015 ', 'MM DD YYYY')

    )

    SELECT

    customer,

    Count (*) AS cnt

    Of evaluated_logons

    WHERE

    -do not count Y first

    ROW_ID > first_row_id

    -count only nonsequtive logon_ids

    AND previous_logon_id + 1<>

    Customer GROUP

    NTC to ORDER BY DESC

    ;

  • How we force a query to use transparently a hint, even if the index is not given in the query as a query rewriting.

    How we force a query to use transparently a hint, even if the index is not given in the query as a query rewriting.

    For example:

    If the user runs a query select deptno, avg (sal) from emp group by deptno;

    We want the optimizer to use a hint of result_cache with this request, and it should be transparent to the user.

    Query should be rewritten to seamlessly

    Select / * + result_cache * / deptno, avg (sal)

    WCP

    Group of deptno;

    How can this feature we make? Please advice.

    I checked the possibility of SPM and contours, but it is not clear if this rewrite is possible here.

    Thank you and best regards,

    Vikas Krishna

    Surely dbms_advanced_rewrite is designed for this situation?

  • How does whitespace or null values or characters set effect set in the query?

    Hi all

    I have a question about client side Oracle database tools. I have Oracle 11g installed on the server and I use PL/SQL developer tool to retrieve information from the server and then I copy paste this query in PL SQL Developer my company built in box of function of the application that executes the same query as client tools and the results.

    When I write the request by spaces of the Tools client-side IE the PL/SQL developer tool and copy paste at my request of builtin company gives slow down me execution, but if I remove the white of the query space by copying the application of PL/SQL developer(client side tool) to Notepad first and then copy back at my request and gives me a faster execution.

    For example:

    Original Request: with whitespace

    Select

    *

    Of

    Double

    Ask without spaces faster tracks:

    Select * twice;

    I want to the reason behind this slow execution and also if you could explain in detail would be great that I am no expert oracle.

    Also, I wanted to know that character set parameters from the client side tools slow running query? As I copy the request of PL/SQL developer tool

    Thank you

    HP

    HP, I have has been suggest you determine if the difference in performance is due to how the application prepares and processes SQL or if the difference is in Oracle.  If you can duplicate the issue in Oracle using SQLPLus then you can use the Oracle tools such as autotrace, SQL, trace etc... to determine how Oracle handles each request.  On the other hand if the time of execution in SQLPLus is the same then you know that the problem lies in the application.  Depending on whether you have access to the source you can or will not be able to track down the issue and resolve it.  Otherwise always paste the capture into the plan text and edit it to remove the unnecessary lines before copying them the text into your application tool.

    - -

    HTH - Mark D Powell.

  • How to remove the additional summary of the result of the query

    All,

    I create a derived table two tables and then join the result then using function group but the result is to summarize a number of additional time, can correct all my request. Here are the tables and relevant data.

    CREATE TABLE SHP_DW_TEMP_DEL_WEIGHT_TB

    (

    CUSTOMER_ID NUMBER DEFAULT NULL,

    NUMBER OF CARRIER_ID,

    DATE OF BILL_DATE,

    VARCHAR2 (200 BYTE) SERVICE,

    NUMBER OF WEIGHT,

    Create_date DATE default sysdate,

    SHIPPER_ID NUMBER DEFAULT NULL

    )

    CREATE TABLE SHP_DW_TEMP_DEL_SPEND_TB

    (

    CUSTOMER_ID NUMBER DEFAULT null,

    NUMBER OF CARRIER_ID,

    DATE OF BILL_DATE,

    VARCHAR2 (200 BYTE) SERVICE,

    NUMBER OF COST,

    Create_date DATE default sysdate,

    SHIPPER_ID NUMBER DEFAULT of null

    )

    CREATE TABLE SHP_DW_INTERM_TB

    (

    JAVA_SESSION_ID VARCHAR2 (1000 BYTE),

    USER_ID NUMBER,

    CUSTOMER_ID NUMBER DEFAULT NULL,

    CLIENT_NAME VARCHAR2 (100 BYTE),

    NUMBER OF CARRIER_ID,

    CARRIER_NAME VARCHAR2 (100 BYTE),

    NUMBER OF IS_LTL_CARRIER

    SHIPPER_GROUP_ID NUMBER DEFAULT NULL,

    SHIPPER_ID NUMBER DEFAULT NULL,

    SHIPPER_NAME VARCHAR2 (100 BYTE),

    CREATE_DATE DATE DEFAULT SYSDATE,

    FREIGHT_RANK NUMBER DEFAULT of null

    )

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (FEBRUARY 25, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 602, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 243, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), ' FIRST INTERNATIONAL AIRPORT THE NIGHT ', 1.8, TO_DATE (MARCH 25, 2014 04:28:29 ',' ' DD/MM/YYYY HH24:MI:SS));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 8203.5, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (4 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 2351.1, (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 2979.7, (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (FEBRUARY 25, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 8622.1, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (4 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 10358.4, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (18 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', 2899, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (FEBRUARY 25, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 2597.1, (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (4 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 121, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (18 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 9015.5, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_WEIGHT_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, WEIGHT, CREATE_DATE)

    Values

    (664, 22, TO_DATE (18 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 729, TO_DATE (MARCH 25, 2014 04:28:29 ',' DD/MM/YYYY HH24:MI:SS'));))

    COMMIT;

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (FEBRUARY 25, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 356.65, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 181.19, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), ' FIRST INTERNATIONAL AIRPORT THE NIGHT ', 134.45, TO_DATE (MARCH 21, 2014 03:13:16 ',' ' DD/MM/YYYY HH24:MI:SS));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (4 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 7267.92, (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 27755.2, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (11 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 8192.35, (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (FEBRUARY 25, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 26388.53, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (18 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 8825.98, (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (4 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 31653.45, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (FEBRUARY 25, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL PRIORITY OVERNIGHT', TO_DATE 7901.07, (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (4 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 167.73, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (18 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL FEDEX GROUND', 959.85, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    Insert into msidw. SHP_DW_TEMP_DEL_SPEND_TB

    (CUSTOMER_ID, CARRIER_ID, BILL_DATE, SERVICE, COST, CREATE_DATE)

    Values

    (664, 22, TO_DATE (18 FEBRUARY 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'AIRPORT INTERNATIONAL ECONOMY' 28209.22, TO_DATE (MARCH 21, 2014 03:13:16 ',' DD/MM/YYYY HH24:MI:SS'));))

    COMMIT;

    Insert into msidw.shp_dw_interm_tb

    (java_session_id, user_id, customer_id, client_name, carrier_id, carrier_name, is_ltl_carrier, shipper_group_id, shipper_id, shipper_name, create_date, freight_rank)

    Values

    ("E52AFB0183301775CD882C214A34F54F", 18686, 664, NULL, 22,)

    "FedEx", 0, NULL, NULL, NULL,

    TO_DATE('04/05/2014_00:00:00',_'MM/DD/YYYY_HH24:MI:SS'), 0);

    Insert into msidw.shp_dw_interm_tb

    (java_session_id, user_id, customer_id, client_name, carrier_id, carrier_name, is_ltl_carrier, shipper_group_id, shipper_id, shipper_name, create_date, freight_rank)

    Values

    ("E52AFB0183301775CD882C214A34F54F", 18686, 664, NULL, 23,)

    'DHL', 0, NULL, NULL, NULL,

    TO_DATE('04/05/2014_00:00:00',_'MM/DD/YYYY_HH24:MI:SS'), 0);

    Insert into msidw.shp_dw_interm_tb

    (java_session_id, user_id, customer_id, client_name, carrier_id, carrier_name, is_ltl_carrier, shipper_group_id, shipper_id, shipper_name, create_date, freight_rank)

    Values

    ("CA5AC1C5630D70B2E80E8E2A427DA249", 18686, 664, NULL, 21,)

    'UPS', 0, NULL, NULL, NULL,

    TO_DATE('04/05/2014_00:00:00',_'MM/DD/YYYY_HH24:MI:SS'), 0);

    Insert into msidw.shp_dw_interm_tb

    (java_session_id, user_id, customer_id, client_name, carrier_id, carrier_name, is_ltl_carrier, shipper_group_id, shipper_id, shipper_name, create_date, freight_rank)

    Values

    ("CA5AC1C5630D70B2E80E8E2A427DA249", 18686, 664, NULL, 22,)

    "FedEx", 0, NULL, NULL, NULL,

    TO_DATE('04/05/2014_00:00:00',_'MM/DD/YYYY_HH24:MI:SS'), 0);

    Insert into msidw.shp_dw_interm_tb

    (java_session_id, user_id, customer_id, client_name, carrier_id, carrier_name, is_ltl_carrier, shipper_group_id, shipper_id, shipper_name, create_date, freight_rank)

    Values

    ("CA5AC1C5630D70B2E80E8E2A427DA249", 18686, 664, NULL, 23,)

    'DHL', 0, NULL, NULL, NULL,

    TO_DATE('04/05/2014_00:00:00',_'MM/DD/YYYY_HH24:MI:SS'), 0);

    Insert into msidw.shp_dw_interm_tb

    (java_session_id, user_id, customer_id, client_name, carrier_id, carrier_name, is_ltl_carrier, shipper_group_id, shipper_id, shipper_name, create_date, freight_rank)

    Values

    ("E52AFB0183301775CD882C214A34F54F", 18686, 664, NULL, 21,)

    'UPS', 0, NULL, NULL, NULL,

    TO_DATE('04/05/2014_00:00:00',_'MM/DD/YYYY_HH24:MI:SS'), 0);

    COMMIT;

    This is the query:

    SELECT

    DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M,

    DER_COST_PER_POUND_INTL_MONTH. SERVICE,

    DER_COST_PER_POUND_INTL_MONTH. WEIGHT,

    DER_SPEND_BY_SERV_INTL_MONTHLY. COST

    Of

    (

    SELECT CUSTOMER_ID, CARRIER_ID, to_char (SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE, 'MM - YY') as BILL_DATE_M,

    (CASE

    WHEN (LIKE '% GROUND INTERNATIONAL %' service

    OR service LIKE '% INTERNATIONAL HOME DELIVERY %'

    OR a service LIKE ' % international airport FEDEX GROUND-PRP %'

    OR a service LIKE ' % international airport FEDEX GROUND-RTLABEL %'

    OR a service LIKE '% international airport FEDEX GROUND %'

    OR service LIKE ' % STANDARD.

    OR service LIKE ' % worldwide %.

    )

    AND (NOT LIKE '% FEDEX INTL ECONOMY FRT %' service

    AND service NOT LIKE ' % of the ECONOMY of FEDEX INTL.

    "AND NOT AS service ' % airport % OF CARGO OF the ECONOMY".

    "AND NOT AS service ' % airport % OF the ECONOMY.

    AND NOT LIKE '% ECONOMY MAILSERVICE % INTL' service

    AND NOT LIKE «% % ECONOMY» service

    AND NOT LIKE '% FEDEX EXPRESS SAVER % INTL' service

    AND NOT LIKE '% WW SAVER %' service

    AND NOT LIKE '% CANADIAN % SAVER' service

    AND NOT LIKE '% UPS SAVER %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY FRT %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY %' service

    AND NOT LIKE '% MAILSERVICE INTL PRIORITY %' service

    AND service NOT AS '% PRIORITY % PROPOSED international airport'

    AND service NOT AS

    'INTERNATIONAL PRIORITY DIRECTDISTRIBUTION % AIRPORT %'

    AND service NOT LIKE '% ACCELERATED %.

    AND service NOT AS ' % international airport 1 DAY FREIGHT %'

    AND service NOT AS ' international airport FIRST NIGHT % %'

    AND NOT AS '% FEDEX INTERNATIONAL FIRST' service

    AND service NOT AS '% international airport MAILSERVICE-BONUS %'

    AND service NOT AS '% UNKNOWN CODE % BASIC SERVICES international airport'

    )

    THEN "ground".

    END

    ) service.

    weight,

    shipper_id

    OF SHP_DW_TEMP_DEL_WEIGHT_TB

    where

    SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE > = trunc (add_months ((CASE WHEN sysdate < next_day (trunc (sysdate, 'MY')-1, 'MONDAY'), trunc(sysdate,'MON')-1 ELSE END sysdate), - 12), "MM") and SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE < trunc (last_day (add_months ((CASE WHEN sysdate < next_day (trunc (sysdate, 'MY')-1, 'MONDAY'), trunc(sysdate,'MON')-1 ELSE END sysdate), - 1)))

    and extract (bill_date months) = 02

    and customer_id = 664

    GROUP BY

    CARRIER_ID, CUSTOMER_ID, to_char (SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE, "MM - YY"), service, weight, SHIPPER_ID

    ) DER_COST_PER_POUND_INTL_MONTH,.

    (

    SELECT CUSTOMER_ID, CARRIER_ID, to_char (SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE, 'MM - YY') as BILL_DATE_M,

    (CASE

    WHEN (LIKE '% GROUND INTERNATIONAL %' service

    OR service LIKE '% INTERNATIONAL HOME DELIVERY %'

    OR a service LIKE ' % international airport FEDEX GROUND-PRP %'

    OR a service LIKE ' % international airport FEDEX GROUND-RTLABEL %'

    OR a service LIKE '% international airport FEDEX GROUND %'

    OR service LIKE ' % STANDARD.

    OR service LIKE ' % worldwide %.

    )

    AND (NOT LIKE '% FEDEX INTL ECONOMY FRT %' service

    AND service NOT LIKE ' % of the ECONOMY of FEDEX INTL.

    "AND NOT AS service ' % airport % OF CARGO OF the ECONOMY".

    "AND NOT AS service ' % airport % OF the ECONOMY.

    AND NOT LIKE '% ECONOMY MAILSERVICE % INTL' service

    AND NOT LIKE «% % ECONOMY» service

    AND NOT LIKE '% FEDEX EXPRESS SAVER % INTL' service

    AND NOT LIKE '% WW SAVER %' service

    AND NOT LIKE '% CANADIAN % SAVER' service

    AND NOT LIKE '% UPS SAVER %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY FRT %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY %' service

    AND NOT LIKE '% MAILSERVICE INTL PRIORITY %' service

    AND service NOT AS '% PRIORITY % PROPOSED international airport'

    AND service NOT AS

    'INTERNATIONAL PRIORITY DIRECTDISTRIBUTION % AIRPORT %'

    AND service NOT LIKE '% ACCELERATED %.

    AND service NOT AS ' % international airport 1 DAY FREIGHT %'

    AND service NOT AS ' international airport FIRST NIGHT % %'

    AND NOT AS '% FEDEX INTERNATIONAL FIRST' service

    AND service NOT AS '% international airport MAILSERVICE-BONUS %'

    AND service NOT AS '% UNKNOWN CODE % BASIC SERVICES international airport'

    )

    THEN "ground".

    END

    ) service.

    COST,

    SHIPPER_ID

    OF SHP_DW_TEMP_DEL_SPEND_TB

    where

    SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE > = trunc (add_months ((CASE WHEN sysdate < next_day (trunc (sysdate, 'MY')-1, 'MONDAY'), trunc(sysdate,'MON')-1 ELSE END sysdate), - 12), "MM") and SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE < trunc (last_day (add_months ((CASE WHEN sysdate < next_day (trunc (sysdate, 'MY')-1, 'MONDAY'), trunc(sysdate,'MON')-1 ELSE END sysdate), - 1)))

    and extract (bill_date months) = 02

    and customer_id = 664

    GROUP OF CUSTOMER_ID, CARRIER_ID, to_char (SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE, "MM - YY"), service, COST, SHIPPER_ID

    ) DER_SPEND_BY_SERV_INTL_MONTHLY,.

    SHP_DW_INTERM_TB

    WHERE

    (NVL (DER_SPEND_BY_SERV_INTL_MONTHLY. CUSTOMER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. CUSTOMER_ID,-1))

    AND (DER_SPEND_BY_SERV_INTL_MONTHLY. CARRIER_ID = DER_COST_PER_POUND_INTL_MONTH. CARRIER_ID)

    AND (DER_SPEND_BY_SERV_INTL_MONTHLY. BILL_DATE_M = DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M)

    AND (DER_SPEND_BY_SERV_INTL_MONTHLY. SERVICE = DER_COST_PER_POUND_INTL_MONTH. (SERVICE) - MNKB

    AND (NVL (DER_SPEND_BY_SERV_INTL_MONTHLY. SHIPPER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. SHIPPER_ID,-1))

    AND (NVL (SHP_DW_INTERM_TB. CUSTOMER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. CUSTOMER_ID,-1))

    AND (SHP_DW_INTERM_TB. CARRIER_ID = DER_COST_PER_POUND_INTL_MONTH. CARRIER_ID)

    AND (NVL (SHP_DW_INTERM_TB. SHIPPER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. SHIPPER_ID,-1))

    AND

    (

    SHP_DW_INTERM_TB. JAVA_SESSION_ID in ('CA5AC1C5630D70B2E80E8E2A427DA249')

    AND

    SHP_DW_INTERM_TB. User_id in (18686)

    AND

    SHP_DW_INTERM_TB.IS_LTL_CARRIER (0)

    )

    GROUP BY

    DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M,

    DER_COST_PER_POUND_INTL_MONTH. WEIGHT,

    DER_SPEND_BY_SERV_INTL_MONTHLY. COST,

    DER_COST_PER_POUND_INTL_MONTH. SERVICE

    order of DER_COST_PER_POUND_INTL_MONTH.service

    The result I want is

    Billing date

    Service Weight Cost
    04/02/14
    On the ground
    121
    167.73
    11/02/14
    On the ground
    243
    181.19
    18/02/2014
    On the ground
    729
    959.85
    25/02/2014
    On the ground
    602
    356.65

    The above query gives each weight mapped to each cost, so the resulting values are summarizing to greater value than the above expected values.

    Can someone help me please how do I change my request to get my desired result.

    Kind regards

    Mr Kishore N. badin.

    SELECT DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M,

    DER_COST_PER_POUND_INTL_MONTH. SERVICE,

    DER_COST_PER_POUND_INTL_MONTH. WEIGHT,

    DER_SPEND_BY_SERV_INTL_MONTHLY. COST

    IN (SELECT CUSTOMER_ID,

    CARRIER_ID,

    TO_CHAR (SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE, 'DD-MM-YY') as BILL_DATE_M,

    BOX WHEN (LIKE '% GROUND INTERNATIONAL %' service

    OR service LIKE '% INTERNATIONAL HOME DELIVERY %'

    OR a service LIKE ' % international airport FEDEX GROUND-PRP %'

    OR a service LIKE ' % international airport FEDEX GROUND-RTLABEL %'

    OR a service LIKE '% international airport FEDEX GROUND %'

    OR service LIKE ' % STANDARD.

    OR service LIKE ' % worldwide %.

    )

    AND (NOT LIKE '% FEDEX INTL ECONOMY FRT %' service

    AND service NOT LIKE ' % of the ECONOMY of FEDEX INTL.

    "AND NOT AS service ' % airport % OF CARGO OF the ECONOMY".

    "AND NOT AS service ' % airport % OF the ECONOMY.

    AND NOT LIKE '% ECONOMY MAILSERVICE % INTL' service

    AND NOT LIKE «% % ECONOMY» service

    AND NOT LIKE '% FEDEX EXPRESS SAVER % INTL' service

    AND NOT LIKE '% WW SAVER %' service

    AND NOT LIKE '% CANADIAN % SAVER' service

    AND NOT LIKE '% UPS SAVER %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY FRT %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY %' service

    AND NOT LIKE '% MAILSERVICE INTL PRIORITY %' service

    AND service NOT AS '% PRIORITY % PROPOSED international airport'

    AND service NOT AS '% airport international PRIORITY DIRECTDISTRIBUTION %'

    AND service NOT LIKE '% ACCELERATED %.

    AND service NOT AS ' % international airport 1 DAY FREIGHT %'

    AND service NOT AS ' international airport FIRST NIGHT % %'

    AND NOT AS '% FEDEX INTERNATIONAL FIRST' service

    AND service NOT AS '% international airport MAILSERVICE-BONUS %'

    AND service NOT AS '% UNKNOWN CODE % BASIC SERVICES international airport'

    )

    THEN "ground".

    END of service,

    weight,

    shipper_id

    OF SHP_DW_TEMP_DEL_WEIGHT_TB

    where SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE > =.

    trunc (add_months (BOX WHEN sysdate< next_day(trunc(sysdate,'mon')="" -="">

    'MONDAY '.

    )

    THEN trunc (sysdate, 'MY') - 1

    Of ANOTHER sysdate

    END,

    -12

    ),

    "MM".

    )

    and SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE

    trunc (last_day (add_months (BOX WHEN sysdate< next_day(trunc(sysdate,'mon')="" -="">

    'MONDAY '.

    )

    THEN trunc (sysdate, 'MY') - 1

    Of ANOTHER sysdate

    END,

    -1

    )

    )

    )

    and extract (bill_date months) = 02

    and customer_id = 664

    GROUP CARRIER_ID,

    CUSTOMER_ID,

    TO_CHAR (SHP_DW_TEMP_DEL_WEIGHT_TB. BILL_DATE, 'DD-MM-YY'),

    service, weight, SHIPPER_ID

    ) DER_COST_PER_POUND_INTL_MONTH,.

    (SELECT CUSTOMER_ID,

    CARRIER_ID,

    TO_CHAR (SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE, 'DD-MM-YY') as BILL_DATE_M,

    BOX WHEN (LIKE '% GROUND INTERNATIONAL %' service

    OR service LIKE '% INTERNATIONAL HOME DELIVERY %'

    OR a service LIKE ' % international airport FEDEX GROUND-PRP %'

    OR a service LIKE ' % international airport FEDEX GROUND-RTLABEL %'

    OR a service LIKE '% international airport FEDEX GROUND %'

    OR service LIKE ' % STANDARD.

    OR service LIKE ' % worldwide %.

    )

    AND (NOT LIKE '% FEDEX INTL ECONOMY FRT %' service

    AND service NOT LIKE ' % of the ECONOMY of FEDEX INTL.

    "AND NOT AS service ' % airport % OF CARGO OF the ECONOMY".

    "AND NOT AS service ' % airport % OF the ECONOMY.

    AND NOT LIKE '% ECONOMY MAILSERVICE % INTL' service

    AND NOT LIKE «% % ECONOMY» service

    AND NOT LIKE '% FEDEX EXPRESS SAVER % INTL' service

    AND NOT LIKE '% WW SAVER %' service

    AND NOT LIKE '% CANADIAN % SAVER' service

    AND NOT LIKE '% UPS SAVER %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY FRT %' service

    AND NOT LIKE '% FEDEX INTL PRIORITY %' service

    AND NOT LIKE '% MAILSERVICE INTL PRIORITY %' service

    AND service NOT AS '% PRIORITY % PROPOSED international airport'

    AND service NOT AS '% airport international PRIORITY DIRECTDISTRIBUTION %'

    AND service NOT LIKE '% ACCELERATED %.

    AND service NOT AS ' % international airport 1 DAY FREIGHT %'

    AND service NOT AS ' international airport FIRST NIGHT % %'

    AND NOT AS '% FEDEX INTERNATIONAL FIRST' service

    AND service NOT AS '% international airport MAILSERVICE-BONUS %'

    AND service NOT AS '% UNKNOWN CODE % BASIC SERVICES international airport'

    )

    THEN "ground".

    END of service,

    COST,

    SHIPPER_ID

    OF SHP_DW_TEMP_DEL_SPEND_TB

    where SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE > =.

    trunc (add_months (BOX WHEN sysdate< next_day(trunc(sysdate,'mon')="" -="">

    'MONDAY '.

    )

    THEN trunc (sysdate, 'MY') - 1

    Of ANOTHER sysdate

    END,

    -12

    ),

    "MM".

    )

    and SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE

    trunc (last_day (add_months (BOX WHEN sysdate< next_day(trunc(sysdate,'mon')="" -="">

    'MONDAY '.

    )

    THEN trunc(sysdate,'MON')-1

    Of ANOTHER sysdate

    END,

    -1

    )

    )

    )

    and extract (bill_date months) = 02

    and customer_id = 664

    CUSTOMER_ID GROUP,

    CARRIER_ID,

    TO_CHAR (SHP_DW_TEMP_DEL_SPEND_TB. BILL_DATE, 'DD-MM-YY'),

    service, COST, of SHIPPER_ID

    ) DER_SPEND_BY_SERV_INTL_MONTHLY,.

    SHP_DW_INTERM_TB

    WHERE (NVL (DER_SPEND_BY_SERV_INTL_MONTHLY. CUSTOMER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. CUSTOMER_ID,-1))

    AND (DER_SPEND_BY_SERV_INTL_MONTHLY. CARRIER_ID = DER_COST_PER_POUND_INTL_MONTH. CARRIER_ID)

    AND (DER_SPEND_BY_SERV_INTL_MONTHLY. BILL_DATE_M = DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M)

    AND (DER_SPEND_BY_SERV_INTL_MONTHLY. SERVICE = DER_COST_PER_POUND_INTL_MONTH. (SERVICE) - MNKB

    AND (NVL (DER_SPEND_BY_SERV_INTL_MONTHLY. SHIPPER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. SHIPPER_ID,-1))

    AND (NVL (SHP_DW_INTERM_TB. CUSTOMER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. CUSTOMER_ID,-1))

    AND (SHP_DW_INTERM_TB. CARRIER_ID = DER_COST_PER_POUND_INTL_MONTH. CARRIER_ID)

    AND (NVL (SHP_DW_INTERM_TB. SHIPPER_ID,-1) = NVL (DER_COST_PER_POUND_INTL_MONTH. SHIPPER_ID,-1))

    AND (SHP_DW_INTERM_TB. JAVA_SESSION_ID in ('CA5AC1C5630D70B2E80E8E2A427DA249')

    AND SHP_DW_INTERM_TB. User_id in (18686)

    AND SHP_DW_INTERM_TB.IS_LTL_CARRIER (0)

    )

    GROUP OF DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M,

    DER_COST_PER_POUND_INTL_MONTH. WEIGHT,

    DER_SPEND_BY_SERV_INTL_MONTHLY. COST,

    DER_COST_PER_POUND_INTL_MONTH. SERVICE

    order DER_COST_PER_POUND_INTL_MONTH. BILL_DATE_M, DER_COST_PER_POUND_INTL_MONTH.service

    BILL_DATE_M SERVICE WEIGHT COST
    02/04/14 On the ground 121 167.73
    02/11/14 On the ground 243 181.19
    18/02/14 On the ground 729 959.85
    25/02/14 On the ground 602 356.65

    Concerning

    Etbin

  • How can rewrite the query statement effectively

    Hi gurus,

    BANNER

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

    Oracle Database 10g Release 10.2.0.4.0 - Production 64-bit

    PL/SQL Release 10.2.0.4.0 - Production

    CORE 10.2.0.4.0 Production

    AMT for Linux: release 10.2.0.4.0 - Production

    NLSRTL Version 10.2.0.4.0 - Production

    Table scripts


    CREATE TABLE WAREHOUSE

    (

    IDZONE VARCHAR2 (6 BYTE) NOT NULL,

    ZONE_CREATEDATE DATE NOT NULL,

    DATE OF DT_WAREHOUSE,

    DATE OF DT_POSTING

    )

    AREA ID, ZONE_CREATEDATE is PK

    CREATE TABLE ZONE_VIEW

    (

    IDZONE VARCHAR2 (6 BYTE) NOT NULL,

    ZONE_CREATEDATE DATE NOT NULL,

    ZONE_NUM NUMBER (2) NOT NULL,

    DATE OF TRANX_DATE

    )

    ID of the AREA, ZONE_CREATEDATE, ZONE_NUM is PK

    Query

    SELECT ID area, zone_createdate

    Of

    (

    SELECT ID area, zone_createdate,

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

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

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

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

    OF zone_view

    GROUP BY IDZone, zone_createdate

    ) zrn

    WHERE zrn.region_18 <>0

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

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

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

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

    );

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

    Any help or suggestion would be appreciated

    Thanks in advance

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

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

    (a) filter values of zone_num

    (b) move the audit only

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

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

    SELECT ID area, zone_createdate

    Of

    (

    SELECT ID area, zone_createdate,

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

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

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

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

    OF zone_view

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

    and zone_num (18, 110, 135, 140)

    GROUP BY IDZone, zone_createdate

    ) zrn

    WHERE zrn.region_18 <> 0

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

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

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

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

    )

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

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

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

    and using the expression in the query box:

    SELECT ID area, zone_createdate

    Of

    (

    SELECT ID area, zone_createdate,

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

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

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

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

    OF zone_view

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

    and zone_num (18, 110, 135, 140)

    GROUP BY IDZone, zone_createdate

    ) zrn

    WHERE zrn.region_18 <> 0

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

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

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

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

    )

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

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

    | ID | Operation | Name |

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

    |   0 | SELECT STATEMENT |              |

    |*  1 |  FILTER                          |              |

    |   2.   VIEW                           |              |

    |*  3 |    FILTER                        |              |

    |   4.     HASH GROUP BY.              |

    |   5.      ANTI NESTED LOOPS.              |

    |   6.       INLIST ITERATOR.              |

    |*  7 |        INDEX RANGE SCAN | ZV_F1 |

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

    |*  9 |        INDEX UNIQUE SCAN | WAREHOUSE_PK |

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

    | * 11 |    INDEX UNIQUE SCAN | WAREHOUSE_PK |

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

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

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

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

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

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

    Good luck.

Maybe you are looking for

  • ENVY 750-197c: still cannot successfully connect to wifi?

    Hello! I received my new desktop PC (a 750-197 c ENVY) probably about two weeks ago. Since then, I was not able to connect to wifi. The office came with Win 10 which I really didn't yet, so I went down to Win 8. After not being is not able to connect

  • Ethernet, Wifi will not work on MacbookPro... mystery...

    The last time he randomly sets itself after that I tried everything nothing helped. WiFi and Ethernet are not macbook pro connect. Knowing both the cable and wifi are functional and are working on another computer so no problem with connection suppor

  • excellent easy text

    I'm currently updated all of our programs of LabVIEW 7.1 to LabVIEW 2011.  I'm working on PC has Windows 7 and MS Office 2010. One of my programs use the simple text Excel function.  However, when opened in LabVIEW 2011, the list of errors poster as

  • I can't access the pdf attachments, they have foreign air

    I can't access the pdf attachments, they look foreign, what is the best way/program to view pdf files

  • transfer large files

    I'm trying to transfer a large file video AVCHD 7.3 GB of my portable hp7 to a flash drive or drive hard usb. Despite trying various devices and have more than enough detached 450 GB of memory! When I try to move the file, I get an error message sayi