Query with join optimization research and details of the extra column

I have the following SQL used for a report that comes out some stats (with some research of names). There is a good chance it is probably possible to optimize with better SQL, but I also hope to add an additional column, which I'm not sure.

I want the extra column at one percent, which is total % of the lines of the value of the units, for the combination of category/group.

Oracle SQL is v11.2.0

Here's the SQL code, as it is currently:

select a.date_adjusted, 
       a.task_name,
       sum(case when a.units_adjusted is not null then a.units_adjusted else a.units_original end) Units, 
       b.group_name, 
       b.category_name
from   actuals_intake a
left join
-- lookups to obtain group and category names from their ID's in the groupings table
       (select c.task_id, 
               d.group_name, 
               e.category_name, 
               c.business_unit_id
        from   task_groupings c,
               task_groups d,
               task_categories e
        where  c.group_id = d.id
        and    c.business_unit_id = d.business_unit_id
        and    c.category_id = e.id
        and    c.business_unit_id = e.business_unit_id
) b
on    a.task_id = b.task_id
and   a.business_unit_id = b.business_unit_id
where a.business_unit_id = :P10_SELECT_BUSINESS_UNIT
and   a.date_adjusted between to_date(:P10_DATE_START, 'dd-mon-yyyy') and to_date(:P10_DATE_END, 'dd-mon-yyyy')
group by a.date_adjusted, a.task_name, b.group_name, b.category_name
order by a.date_adjusted, b.category_name, b.group_name
 

This will set up the tables and data:

CREATE TABLE ACTUALS_INTAKE (
ID NUMBER,
DATE_ORIGINAL DATE,
TASK_NAME VARCHAR2(500 CHAR),
TASK_ID NUMBER,
UNITS_ORIGINAL NUMBER,
BUSINESS_UNIT_ID NUMBER,
SUB_UNIT_ID NUMBER,
DATE_ADJUSTED DATE,
UNITS_ADJUSTED NUMBER
);
CREATE TABLE TASK_CATEGORIES (
ID NUMBER, 
CATEGORY_NAME VARCHAR2(100 CHAR), 
BUSINESS_UNIT_ID NUMBER
);
CREATE TABLE TASK_GROUPS (
ID NUMBER, 
GROUP_NAME VARCHAR2(100 CHAR), 
BUSINESS_UNIT_ID NUMBER
);
CREATE TABLE TASK_GROUPINGS (
TASK_ID NUMBER, 
GROUP_ID NUMBER, 
CATEGORY_ID NUMBER, 
BUSINESS_UNIT_ID NUMBER
);
 
 
INSERT ALL
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (1, '03/15/2014', 'Task One', 1, 200, 10, null, '03/15/2014', null)
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (2, '03/15/2014', 'Task Two', 2, 30, 10, null, '03/15/2014', null)
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (3, '03/15/2014', 'Task Three', 3, 650, 10, null, '03/15/2014', null)
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (4, '03/15/2014', 'Task Four', 4, 340, 10, null, '03/15/2014', null)
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (5, '03/14/2014', 'Task Four', 4, 60, 10, null, '03/15/2014', null)
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (6, '03/15/2014', 'Task Five', 5, 15, 10, null, '03/15/2014', null)
INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED)
VALUES (7, '03/15/2014', 'Task Six', 6, 40, 10, null, '03/15/2014', null)
SELECT 1 FROM DUAL;
 
 
INSERT ALL
INTO TASK_GROUPS (ID, GROUP_NAME, BUSINESS_UNIT_ID)
VALUES (1, 'Group One', 10)
INTO TASK_GROUPS (ID, GROUP_NAME, BUSINESS_UNIT_ID)
VALUES (2, 'Group Two', 10)
INTO TASK_GROUPS (ID, GROUP_NAME, BUSINESS_UNIT_ID)
VALUES (3, 'Group Three', 10)
select 1 from dual;

 
INSERT ALL
INTO TASK_CATEGORIES (ID, CATEGORY_NAME, BUSINESS_UNIT_ID)
VALUES (1, 'Category A', 10)
INTO TASK_CATEGORIES (ID, CATEGORY_NAME, BUSINESS_UNIT_ID)
VALUES (2, 'Category A', 10)
INTO TASK_CATEGORIES (ID, CATEGORY_NAME, BUSINESS_UNIT_ID)
VALUES (3, 'Category B', 10)
select 1 from dual;

 
INSERT ALL
INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID)
VALUES (1, 1, 1, 10)
INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID)
VALUES (2, 1, 1, 10)
INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID)
VALUES (3, 2, 2, 10)
INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID)
VALUES (4, 2, 3, 10)
INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID)
VALUES (5, 3, 3, 10)
INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID)
VALUES (6, 3, 3, 10)
select 1 from dual;
 

Results will look like this. The last column is what I want the extra column to look like:

Date_Adjusted TaskName Units of GroupName Category_Name Units %
15/03/2014A task200Group 1Category A87
15/03/2014Task 230Group 1Category A13
15/03/2014Task 3650Group twoCategory A100
15/03/2014Task 515Group threeCategory B27
15/03/2014Task 640Group threeCategory B73
15/03/2014Task 4400Group twoCategory B100

Hope all that makes sense... Anyone able to help me do this effectively?

Hello

Use the analytical RATIO_TO_REPORT function to calculate the % of units column.

If you're serious about performance, please refer to the Forum:

Re: 3. how to improve the performance of my query? / My query is slow.

Do you really need an outer join?  Inner joins are faster.  With the given sample data, they produce the same results.

COALESCE may be a little faster than the CASE.

Try this:

WITH got_units AS

(

SELECT a.date_adjusted,

a.Task_Name,

sum of units (COALESCE (a.units_adjusted, a.units_original));

b.group_name,

b.category_name

of actuals_intake one

the left join - or just JOINED

-research for the group names and category of their ID in the table of groupings

(select c.task_id,

d.group_name,

e.category_name,

c.business_unit_id

of task_groupings c,.

task_groups d,

e task_categories

where d.id = c.group_id

and c.business_unit_id = d.business_unit_id

and c.category_id = e.id

and c.business_unit_id = e.business_unit_id

) b

On a.task_id = b.task_id

and a.business_unit_id = b.business_unit_id

-where a.business_unit_id =: P10_SELECT_BUSINESS_UNIT - if necessary

- and a.date_adjusted between to_date (: P10_DATE_START, 'Mon-dd-yyyy') and to_date (: P10_DATE_END, ' mon-dd-yyyy "")

Group of a.date_adjusted, a.task_name, b.group_name, b.category_name

)

SELECT u.*

ROUND (100 * RATIO_TO_REPORT (units) OVER (PARTITION BY groupname)

category_name

)

) AS units_pct

OF got_units u

ORDER BY date_adjusted, category_name, GroupName

;

Thanks for the display of the data of the sample; It is very useful.  Don't try to insert strings, for example, March 15, 2014", in DATE columns.  TO_DATE allows to convert strings to DATEs.

Tags: Database

Similar Questions

  • After saving a file PDF with a layer of Spot UV, all the highlights and details in the tones are flattened in the overprint preview. What I'm missing here?

    I'm trying to print business cards with a Spot UV coating. I have a layer above the work with a spot color (set to Green by request of the printer). Below is a logo, essentially a red circle with a few highlights and depth. My question is that, after exporting a PDF file, all of the highlights and details on the red circle disappear in the overprint preview (it is there when I hide Spot UV layer, but missing when I'm hiding the color of the task). What can I do to keep this information?

    Thank you!

    I managed to solve the problem and embarrass me in the process. It wasn't a problem with the settings, but rather a "stowaway" duplicate of a red circle that lurked on the layer UV Spot on top of all the details. Thanks for your help, but it seems that my problems require a different kind of forum!

  • I changed the my imac with a new drive and I lost the original CD/DVD which came with the new Mac.

    I changed the my imac with a new drive and I lost the original CD/DVD which came with the new Mac.

    and when I go to install the mac lion antiracism apple with reticle logo means error

    what can I do with these

    Please help money

    You can get the replacement system install & Restore CD/DVD of the customer support of Apple - to the United States, (800) 767-2775-for a sum low S & h. you will need to have the model or the serial number of your Mac available.

    If you are not in the United States, you may need to go through the regional Apple Store that serves your location to find the phone number. Here is a list of links to all - http://store.apple.com/Catalog/US/Images/intlstoreroutingpage.html , another resource: International Support Phone #s.

  • Why my front panel opens with a white background and most of the invisible control

    When I open my vi and several others, they open with a white background and most of the controls not returned as theis

    After I resize it looks like it should

    It's probably somewhat similar to these problems of crazy object.

    Sometimes copy/paste works because it takes your code on a VI that could have a corruption and put in a cool VI.  In your case, the corruption could be linked to the control itself and he just copied over in the new VI.  Money controls are a relatively recent creation which added some fancy appearances.  They don't seem to be the style that is most likely to have some behind the bugs of scenes from the styles of controls that were longer.

    If you have a shared services provider, or if a person nor jump here and wants to study, they want to can see your VI and understand what goes wrong.  If this isn't the case, I hope that what you've done has solved the problem and you can spend without return.

  • my pc runs research and fills in the forms she self... who runs it?

    My pc runs research and fills in the forms by itself. I did al worm and Trojan research...

    Hi geddus,

    1. what research program do you use?

    2. what security software is installed on your computer?

    (a) I recommend you run a virus scan online from the link given below and check if the problem persists.

    Microsoft safety scanner

    Also, make sure that you have the latest update of the software antivirus installed on your computer, so that it works correctly.

    (b) you can also download & run Microsoft Security Essentials on your computer.

    Hope the helps of information.
    Please post back and we do know.

  • I bought Adobe Acrobat Standard DC with a new computer and only got the Adobe Reader software.  How can I get the software I purchased?

    I bought Adobe Acrobat Standard DC with a new computer and only got the Adobe Reader software.  How can I get the software I purchased?

    Hi debc6197,

    Download Acrobat Standard DC following the steps in this document KB, download and install Adobe Acrobat DC if it is a subscription (make sure that you are connected using the Adobe ID, in which you have a subscription for Acrobat Standard DC.) or if it is a perpetual license download using this link Download Adobe Acrobat products. Standard, Pro | DC, XI, X

    Kind regards
    Nicos

  • Hi, I need to activate my Adobe CS3 on a new computer because my old is dead and I'm having trouble. Tried the average normal recording then connected with my Adobe ID and can see the software code and activation already registered. How to get o

    Hi, I need to activate my Adobe CS3 on a new computer because my old is dead and I'm having trouble. Tried the average normal recording then connected with my Adobe ID and can see the software code and activation already registered. How to get it on my computer saved?

    If your two activation is used, you need to call Adobe. Install CS3 point of activation and call Adobe at this time here.  They help in cases like your My drive crashed and I replaced it. Could not disable the activation of the accident.  I've done that twice in the years I use PS for about 20 years

    To see your key, you must click on the product in your products and services Adobe page.

  • Where can I get the complete list of features and details of the v28

    Where can I get the complete list of features and details of the v28, I searched a lot but could not find the official list of features.

    Try this:

    http://helpx.Adobe.com/Digital-Publishing-Suite/help/whats-new-release.html

  • I use windows 7. How to change and be sure the default column width in Windows Explorer

    I use windows 7. How to change and be sure the default column width in Windows Explorer

    Hi Jimsw,

    ·         If it works well before?

    ·         You did changes to the computer before the show?

    Explorer Windows will remember changed settings, check if this not happen as planned.

    Follow the suggestions below for a possible solution:

    Method 1: I suggest running the fix of the article and check if it helps.

    Diagnose and repair Windows files and folders problems automatically

    http://support.Microsoft.com/mats/windows_file_and_folder_diag/

    Method 2: You can increase the width of the selected columns and apply the settings to all files and check.

    a. right click on an empty space in the Windows Explorer, click on sort by.

    b. now, enter the size required in the Pixel with and click OK.

    Now, click on the drop down menu to organize and click on folder and Search Options.

    Click view and click apply to folders and click OK.

    I hope this helps.

  • Rewrite the query with joins, and group by

    Hello

    It's an interview question.

    Table names: bookshelf_checkout
    virtual library

    And the join condition between these two tables is title

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

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

    Kindly help me on this.

    Thank you
    Suri

    Something like that?

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

    Lukasz

  • Internal XML to the query with join

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

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

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

    Does anyone know a way for me to do this?

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

  • Update query with join statement

    Hi guys, would check how to write a query to update with the inner join statement? The case is like this, I need to update PRD_ID on TBL A as below, based on the information of lookup table. The keys are based on the A03 column to the table time to condition only select records in LOOKUP_TBL where PRD_ID = 110001 then update to TBL_A for those who match the data and FIX_FLT = 1

    I have an update query and it works in SQL SERVER but not in ORACLE

    Update a PRD_ID = B.PRD_ID set

    Inner TBL_A A join B LOOKUP_TBL

    On A.A03 = B.A03

    AND A.FIX_FLT = 1 AND B.PRD_ID = '110001';

    TBL_A

    PRD_IDA03FIX_FLTTXNDATE
    1A11123/10/2010
    1A21110/24/2010
    1A33210/25/2010
    1A43210/26/2010
    1A53127/10/2010

    LOOKUP_TBL

    PRD_IDA03NOTE
    110001A1NULL VALUE
    110001A2NULL VALUE
    110005A3NULL VALUE
    110005A4NULL VALUE
    110001A5NULL VALUE

    You can write updates like this in Oracle.  It's called updatable join views.  Something like this:

    Update
    (select a.prd_id a_prd_id
    b.prd_id b_prd_id
    Inner TBL_A A join B LOOKUP_TBL
    On A.A03 = B.A03
    AND A.FIX_FLT = 1 AND B.PRD_ID = '110001'
    )
    Set a_prd_id = b_prd_id;

    But you must have the constraints appropriate in place, otherwise you will get the error "key preserved table.

  • Update statement with joins of tables and where Clause

    Hi, I have MS SQL background and I try to execute an update statement in Oracle with joins of tables. However, the syntax below does not work but I think it works for MS SQL.

    Basically, the base table must be attached to a master table trend with monthly snapshots, an account will be only an entry for a given date monthly. Where clause must be limited to accounts within a certain range of interest rates.

    The first approach returns command SQL ORA-00933 not correctly completed, and the second approach returns ORA-01427 row below query returns multiple rows. Can anyone help? Thanks in advance!



    1:

    Update PenaltyAll
    Set a.indicator = month (b.)
    of PenaltyAll an inner join Master b on a.acctno = b.accountnumber
    where a.monthend='01/31/2009' and b.date='12/31/2008' and b.apr < 20

    2:

    Update PenaltyAll
    adjustment indicator =
    (select to_char (b., 'MM')
    of PenaltyAll an inner join Master b on a.acctno = b.accountnumber
    "where to_char (a.monthend,'mm/dd/yyyy ') = 31 January 2009"
    (et to_char(b.date,'mm/dd/yyyy') = December 31, 2008 "
    and b.apr < 20)

    Published by: sqlrookie on August 21, 2009 07:04

    I edited my post, that was my mistake, ANC you try now?

  • Overview and details of the records in the same mixing ratio

    Hello, on the bottom I need to mix the results in the summary table and the records in the table of details in the same report.

    To create the scenario:
    CREATE TABLE ALPHA
    (
    ALPHA_ID     NUMBER,
    ALPHA_NR     NUMBER,
    ALPHA_TOTCT     NUMBER,
    ALPHA_FUND     NUMBER
    
    );
    
    ALTER TABLE ALPHA ADD (
         CONSTRAINT ALPHA_PK PRIMARY KEY (ALPHA_ID));
    ALTER TABLE ALPHA ADD (
         CONSTRAINT ALPHA_NR_UNI UNIQUE (ALPHA_NR));
    
    
    INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
    VALUES( 1, 7 );
    INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
    VALUES( 2, 11 );
    INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
    VALUES( 3, 15 );
    INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
    VALUES( 4, 17 );
    
    CREATE TABLE HIST
    (
    HIST_ID     NUMBER,
    HIST_NR NUMBER,
    HIST_ALPHA_NR NUMBER,
    HIST_CT          NUMBER,
    HIST_VAL     NUMBER,
    HIST_DATE     DATE
    
    );
    
    ALTER TABLE HIST ADD (
         CONSTRAINT HIST_PK PRIMARY KEY (HIST_ID));
    ALTER TABLE HIST ADD (
         CONSTRAINT HIST_NR_UNI UNIQUE (HIST_NR));
    ALTER TABLE HIST ADD (
         CONSTRAINT HIST_ALPHA_NR_FK FOREIGN KEY (HIST_ALPHA_NR) REFERENCES ALPHA ( ALPHA_NR ) );
    
    TRUNCATE TABLE HIST;
    
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 1 ,1    ,7 ,1 ,10 , TO_DATE('01.02.2009' , 'dd.mm.yyyy' ) );
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 2 ,6    ,7 ,1 ,10 , TO_DATE('01.05.2009' , 'dd.mm.yyyy' ) );
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 3 ,3    ,7 ,3 ,30 , TO_DATE('01.02.2010' , 'dd.mm.yyyy' ) );
    
    
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 4 ,4    ,11 ,1 ,10 , TO_DATE('01.03.2009' , 'dd.mm.yyyy' ) );
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 5 ,5    ,11 ,-2 ,-20 , TO_DATE('01.06.2010' , 'dd.mm.yyyy' ) );
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 6 ,8    ,11 ,1 ,10 , TO_DATE('01.02.2011' , 'dd.mm.yyyy' ) );
    
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 7 ,2    ,15 ,2 ,20 , TO_DATE('01.03.2009' , 'dd.mm.yyyy' ) );
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 8 ,7    ,15 ,5 ,50 , TO_DATE('01.06.2010' , 'dd.mm.yyyy' ) );
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 9 ,9    ,15 ,-4 ,-40 , TO_DATE('01.02.2011' , 'dd.mm.yyyy' ) );
    
    INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
    VALUES ( 10 ,10    ,17 ,1 ,10 , TO_DATE('01.03.2011' , 'dd.mm.yyyy' ) );
    To update the summary table, I used a view
    CREATE OR REPLACE VIEW HIST_AGG ( HIST_ALPHA_NR,  TOT_CT  , TOT_VAL )
    AS
    SELECT HIST_ALPHA_NR
    ,SUM ( NVL(HIST_CT, 0 ) ) TOT_CT
    ,SUM( NVL(HIST_VAL, 0) )  TOT_VAL
    
    FROM HIST
    GROUP BY HIST_ALPHA_NR;
    
    
    DECLARE
    
    CURSOR cur
    IS
    SELECT
    HIST_ALPHA_NR
    ,TOT_CT
    ,TOT_VAL
    FROM HIST_AGG
    ;
    
    BEGIN
    FOR rec IN cur
    LOOP
    
         UPDATE ALPHA
         SET ALPHA_TOTCT = rec.TOT_CT
         , ALPHA_FUND  = rec.TOT_VAL
         WHERE ALPHA_NR = rec.HIST_ALPHA_NR;
    
    END LOOP;
    
    END;
    First report should the line overview Alpha tracked table of all the detail records of
    HIST table and for each alpha_nr. At the end of report total overview
    alpha of the table.
    "SUMMARY";"ALPHA_NR";"ALPHA_TOTCT";"ALPHA_FUND";
    ;;;;
    ;7;5;50;
    ;7;1;10;01.02.2009
    ;7;1;10;01.05.2009
    ;7;3;30;
    ;11;0;0;
    ;11;1;10;01.03.2009
    ;11;-2;-20;01.06.2010
    ;11;1;10;01.02.2011
    ;15;3;30;
    ;15;2;20;01.03.2009
    ;15;5;50;01.06.2010
    ;15;-4;-40;01.02.2011
    ;17;1;10;
    ;17;1;10;01.03.2011
    "TOTAL_ALPHA_NR";4;9;90;
    Second report should display the overview by period (year), but the timeline
    for example the year 2009 begins from the year 2010. At the end of each year a summary for
    the current state.
    "YEAR";"ALPHA_NR";"ALPHA_TOTCT";"ALPHA_FUND"
    ;;;
    2009;7;0;0
    ;11;0;0
    ;15;0;0
    ;17;0;0
    "Total 2009";4;0;0
    2010;7;2;20
    ;11;1;10
    ;15;2;20
    ;17;0;0
    "Total 2010";4;5;50
    2011;7;5;50
    ;11;-1;-10
    ;15;7;70
    ;17;0;0
    "Total 2011";4;11;110
    2012;7;5;50
    ;11;0;0
    ;15;3;30
    ;17;1;10
    "Total 2012";4;9;90

    Hello

    wucis wrote:
    I now use this selection

    ...
    FROM       hist        h
    ,       alpha        a
    WHERE       h.hist_alpha_nr (+)     = a.alpha_nr
    AND       a.active          = 'Y'
    AND a.alpha_nr >=  NVL ( NULL  , 1 )
    AND a.alpha_nr <=  NVL ( NULL  , 10000 )
    AND a.alpha_date >= NVL ( TO_DATE( '02.01.2008'  , 'dd.mm.yyyy' ) , '01.01.2000' )
    --AND h.hist_date  >= NVL ( TO_DATE( NULL  , 'dd.mm.yyyy' ) , '01.01.2000' )
    --AND h.hist_date <= NVL ( TO_DATE( NULL  , 'dd.mm.yyyy' ) , '02.02.2222')
    ...
    

    The problem is now, if I limit the query about the h.hist_date, the lines disappear when there is no entry in HIST for this ALPHA_NR,
    in particular the line with alpha_nr = 12 disappears.

    When you use the old notation join, outer join, whenever a column of a table is marked with the + sign, then all the conditions in the WHERE clause that references the same table need a sign +. Otherwise, the effect is identical to an inner join.
    Using the old syntax, you must say something like:

    ...
    FROM       hist        h
    ,       alpha        a
    WHERE       h.hist_alpha_nr (+)     = a.alpha_nr
    AND       a.active          = 'Y'
    AND        a.alpha_nr          >=  1
    AND        a.alpha_nr           <=  10000
    AND        a.alpha_date           >=  TO_DATE ('01.01.2000', 'dd.mm.yyyy')
    AND        h.hist_date (+)     >=  TO_DATE ('01.01.2000', 'dd.mm.yyyy')
    AND       h.hist_date (+)     <=  TO_DATE ('02.02.2222', 'dd.mm.yyyy')
    ...
    

    Notice the + sign in the last 2 lines, after the columns in this table of reference h. I find the ANSI join syntax much more clear in this case.

    How you use NVL makes no sense. NVL (NULL, x) returns x, no matter what x is.
    What you trying to do? Perhaps you meant

    AND        NVL (a.alpha_nr, 1)          >=  1
    
  • Internet connection with Windows XP, SP3 and Airport Extreme - the status is always "absorbing network address.

    My Airport Extreme connected my IMac immediately, but I am not able to connect on the side PC. Airport utility does not 'no matter what Airport wireless devices". When you check the status of the internet connection with PC tools, the correct network is indicated and shows an excellent signal strength. The status is: "absorbing the network address. However, nothing happens.

    Under 'Repair the wireless network connection', it shows, "Windows is taking the following steps: your IP address renewal" even once, nothing happens.

    Under hardware I show Atheros Wireless Network Adapter and the mention: "this device works correctly.

    Yet, no network connection. Any help will be greatly appreciated.

    Hello

    Keep the changes and open the wireless. For example, to disable security in the router (turn on when to managed to connect).

    You can also try the wireless in a friends house, or an Internet café to get a frame of reference for this behavior elsewhere.

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

    Wi - Fi in general.

    These steps and tell us where is the breaking point.

    Check the Device Manager for the wireless card valid entry.

    http://www.ezlan.NET/Win7/net_dm.jpg

    If there is no valid entry, remove any entry from fake and re - install the drivers for the wireless card.

    Check network connections to make sure that you have a network icon/entry wireless connection, and that the properties of the icon (right-click on the icon) are correctly configured with the TCP/IPv4 protocol in the properties of network connections.

    http://www.ezlan.NET/Win7/net_connection_tcp.jpg

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

    The wireless card drivers much also install utility wireless of the seller.

    Make sure that if there are teas from Wireless Utility of seller does not work with the native Windows wireless utility (Service WLAN).

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

    Make sure you firewall No. preventing / blocks wireless components to join the network.

    Some 3rd party software firewall continue to block the same aspects it traffic Local, they are turned Off (disabled).

    If possible set up the firewall correctly, otherwise totally uninstall and get rid of its remaining processes that permit the own local network traffic flow.

    If the 3rd party software is uninstalled, or disables, make sure Windows native firewall is active .

    party like Hello and NetMagic 3rd network managers can block local traffic too.

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

    Stack TCP/IP work should look like.

    Right-click on the wireless network connection card, select status, details and see if she got an IP address and the rest of the settings.

    http://www.ezlan.NET/Win7/status-NIC.jpg

    Description is the data of the card making.

    The physical address is MAC of the card number.

    The xx must be a number between 0 and 255 (all xx even number).

    YY should be between 0 and 255

    ZZ should be between 0 and 255 (zz all the same number.)

    The date of the lease must be valid at the present time.

    * Note 1. IP that starts with 169.xxx.xxx.xxx isn't valid functional IP.

    * Note 2. There could be an IPv6 entries too. However, they are not functional for Internet or LAN traffic. They are necessary for Win 7 homegroup special configuration.

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

    A message in the small window that says connected wireless doesn't means that you are really a valid functional connection.

    Above everything is OK, you must be able to connect to the router.

    Connection to the router means that you can enter the IP of the router base in an address bar in one go, being able to connect and configure the router menus see.

    If it doesn't connect to the router, journal newspaper from any computer that can connect to the router wirelessly with a wire, disable wireless security, make sure that the wireless SSID broadcast is enabled and try to connect with no. wireless security.

    Enable security wireless after you eat to make a functional connection.

    Jack - Microsoft MVP, Windows networking. WWW.EZLAN.NET

Maybe you are looking for

  • Automatic capitalization will not turn off

    Until very recently, I had an automatic initial capitalization and double spacing = '.' off. Since the 'upgrade' iOS 10, even if they are shown as 'stop' in the community that they are in fact enabled. How can I disable them? Thank you

  • Satellite L300 - 04P - need driver modem for XP

    Satellite L300 - 04P Canadian version I can't find * device Modem on High Definition Audio Bus * Driver for XP. No help Toshiba tech support not because I'm not supposed to get grad but I would use XP and last time when I checked the Canada was a fre

  • HELP with Scan string timestamp

    Hi all I'm having a little problem here. I have a text file containing statistical data and I need to sync it with other data. To do this, I want to put stamps on each line of data. Right now I have the time in the format 04/07/12 09:05 p So you can

  • Internet connection not working not not for WRT54GS

    Hello I am a user of Windows XP, and I have the internet service from Verizon Dsl high speed. I need to get the internet connection works for my router. I tried to put the modem, the router and the computer off, but its not good. I also tried using t

  • Cannot install the drivers for the wireless card

    Hello people! I G42-415DX laptop and I recently installed Windows 7 but after installation that the wireless network adapter has not worked, I already downloaded and installed the drivers from this site but nothing happened, the wireless network card