Expected results

Dear all,

I use the 10g database.

I have a code, the output is to come as similar 12 January 16 '. But so do 01/12/2016 favorite.

CREATE or REPLACE procedure XXNMCWEB.xxnmc_get_max_leave_end_date

(

p_emp_num in varchar2,

p_rejoin_date to date,

p_recordset on sys_refcursor

)

as

date of vmax_leave_end_date;

date of lv_leave_end_date;

Start

Start

Select date_end max_leave_end_date

in lv_leave_end_date

de)

Select employee_number, grp, min (date_start) max (date_end) date_end date_start

from (select employee_number, date_start, date_end, days,

Sum (SOG) over (order by date_end) grp

-sum (sog) on last_grp (order by date_end lines between unbounded preceding and following unbounded)

(select papf.employee_number, date_start, date_end, absence_days days,

lag(date_end,1) (order date_end) thomas,

-case when lag(date_end,1,date_start) (date_end layout order)! = date_start - 1

then 1

end from sog

of paba, women's wear per_all_people_f per_absence_attendances

where papf.person_id = paba.person_id

and trunc (sysdate) between trunc (papf.effective_start_date) and trunc (papf.effective_end_date)

(and papf.employee_number = p_emp_num)) group by employee_number, sorting grp grp)

where p_rejoin_date between date_start and date_end;

exception

while others then

lv_leave_end_date: = null;

end;

If lv_leave_end_date is null then

Open the p_recordset for

Select max (paa.date_end) max_leave_end_date

in vmax_leave_end_date

the women's wear per_all_people_f

per_absence_attendances PAA

where papf.person_id = paa.person_id

and trunc (sysdate) between trunc (papf.effective_start_date) and trunc (papf.effective_end_date)

and employee_number = p_emp_num

and paa.date_start < = p_rejoin_date;

on the other

Open the p_recordset for

Select double lv_leave_end_date;

end if;

exception

while others then

null;

end xxnmc_get_max_leave_end_date;

/

Thank you

Thank you for all for your great help. Its working fine.

As suggested, I changed, it starts to work.

Tags: Database

Similar Questions

  • % ROWCOUNT SQL does not return the expected result

    I have the following function within a package:

    --Update APPERY_JTI_deleted_USERS table:
    FUNCTION fn_updt_app_jti_dlt_usr(
        p_update_co      IN VARCHAR2,
        p_appery_user_id IN APPERY_JTI_deleted_USERS.appery_user_id%TYPE,
        p_outlet_code    IN APPERY_JTI_deleted_USERS.outlet_code%TYPE)
      RETURN NUMBER
    AS
    lv_sql       VARCHAR2(4000);
    lv_rowcount  NUMBER := 0;
    BEGIN
    
    lv_sql := 'UPDATE APPERY_JTI_deleted_USERS SET '||p_update_co||' = 1 WHERE '||p_update_co||' = 0 AND OUTLET_CODE = '''||p_outlet_code||''' AND APPERY_USER_ID = '''||p_appery_user_id||'''';
    
    --EXECUTE IMMEDIATE lv_sql;
    EXECUTE IMMEDIATE 'BEGIN ' || lv_sql || '; :z := sql%rowcount; END; ' USING OUT lv_rowcount ;
    
    RETURN lv_rowcount;
      
    EXCEPTION
    WHEN OTHERS THEN
      RETURN -1;  
    END fn_updt_app_jti_dlt_usr;
    
    

    The function called several times as part of a job. Basically, the main function (Say M), call a few functions (for example A1... A9). Each of these functions is to do something and updated the application using the above function. Therefore, each of the nine functions will call the above function with different parameters.

    The problem that I am facing is:

    First run, invoke only first of all for the above function will return the positive result ($sql rowcount > 0). When I run M the second time, only first and second calls for the above function will be to return positive results and so on.

    How odd, it's that if I change the values again and run a function M, it will start from the beginning. And what strange more, the dynamic update statement is executed correctly and data are updated successfully. It's just sql rowcount % do not return is not the expected results.

    I tried to run execute immediately without (begin, end). I also tried to run it without HELP ON. It's always the same. I'm really confused, what Miss me here.

    I don't know if this is relevant. But for what it's worth, invoking the function above updates the SAME lines in the table appery_jti_deleted_users that the columns are different. So for all the work, the same lines need to be updated. Each function (A1... A9) will call the above function to update a different column of these lines.

    If you REALLY want to help you having US SHOW, not tell us:

    1. WHAT you do

    2. HOW to

    3. WHAT results you get

    4. WHAT results you expect to get

    First run, invoke only first of all for the above function will return the positive result ($sql rowcount > 0). When I run M the second time, only first and second calls for the above function will be to return positive results and so on.

    How odd, it's that if I change the values again and run a function M, it will start from the beginning. And what strange more, the dynamic update statement is executed correctly and data are updated successfully. It's just sql rowcount % do not return is not the expected results.

    Perhaps that the foregoing is true and maybe he's not. We have NO WAY of knowing because you don't SHOW US anything.

    I tried to run execute immediately without (begin, end). I also tried to run it without HELP ON. It's always the same.

    Yet once you showed us NOTHING >

    You do NOT FOLLOW best practices when you use dynamic sql statements: the sql statement real so that you can print:

    1 SEE what's running - make sure there are no syntax errors, and it seems to be what you wanted

    2 EXECUTE/TEST manually - to see if he really runs without error and see what results it really give.

    3. FIX any syntax or other problems and retest it

    Instrument properly your code and you won't have the problems you are having.

    You should know by now what are the parameters are transmitted when you run the function. So, there are at least three sets of these parameters.

    So you should be able to:

    1 run the instrumented manually function three times

    2. see that all three SQL statements are

    3 manually run these instructions

    4. see that the number of lines is after each execution

    We have no idea of what the output of the function is every time you call it. Apparently, you have, if you save the results of the function somewhere, but you didn't post any of this info.

    We need real details to help you - just listen to your story is not enough.

  • Simple find() return is not the expected results

    I'm new to ColdFusion, but have been programming for a while now.  I have (what seems) an easy problem that I thought would be a simple solution, but I'm currently stuck.  Any guidance would be appreciated!

    I have the following code:

    < cfset brand = Trim (products. BRAND name) / >
    < cfif Find (brand name, ",") >
    < cfset brand = ""' & brand & ' "" / >

    < / cfif >

    My goal is to surround the text with 'if the string contains a comma.  I tried the standard comma, as Chr (44), but neither returned the expected results.

    What I am doing wrong?  The CSV file, creating, is sprayed upward for the name of a company is like 'Test Company, Inc.'

    Please help us save my sanity!  TIA!

    I think the first thing we do is to read the docs.  And if you may have read 'em a little closer... ;-)

    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/functions_e-g_21.html#5177400

    How around two parameters go?

    --

    Adam

  • SQL statement - display expected results

    I have this SQL statement:
     SELECT DISTINCT ch.ch_status,cu.customer_id FROM contract co, contract_history ch, customer cu
          WHERE co.co_id = ch.co_id
          AND co.customer_id = cu.customer_id
          AND (cu.passportno= 'S1234567A' ) 
          AND cu.customer_id != 12345
          AND ch.ch_seqno in (SELECT MAX(ch_seqno) FROM contract_history WHERE co_id = co.co_id) 
          and co.co_id IN (SELECT co_id FROM contract_history 
          GROUP BY co_id HAVING(SUM(CASE WHEN ch_status = 'a' AND (ch_status = 'd' or ch_status = 's' or ch_status = 'o') THEN 1 
                                    WHEN ch_status = 'a' THEN 1
                                    ELSE 0
                                    END) > 0))
          ORDER BY decode(ch.ch_status,'d',1,'a',2,'s',3,'o',4)ASC;
    With the following results:
    CH_STATUS     CUSTOMER_ID
       d                           100
       d                           200
       d                           300
       a                           100
       a                           200
    How am I suppose to change my SQL statement in such a way, the results appear only that?

    Expected results
    CH_STATUS     CUSTOMER_ID
       d                       300
       a                       100
       a                       200
    Only the ch_status 'a' is displayed even if it has the status was "too. However, if customer_id has only a status was ', it will be displayed.

    I don't get what you're trying to do...

    Once you have the slider you can use the cursor... y u still need with clause,...

    But yes its possible

    QL>
    SQL> Declare
      2   Cursor c1 Is
      3   With t As
      4  (
      5  Select 'd' CH_STATUS ,129 CUSTOMER_ID  From dual Union All
      6  Select 'd'           ,62031            From dual Union All
      7  Select 'd'           ,858347           From dual Union All
      8  Select 'a'           ,129              From dual Union All
      9  Select 'a'           ,62031            From dual
     10  ) Select ch_status,customer_id
     11    From
     12  (
     13   Select ch_status, customer_id,
     14          Case When ch_status = 'd' And lag(ch_status) over (Partition By customer_id Order By ch_status) = 'a' Then 0 Else 1 End  new_status
     15   From t
     16   ) Where new_status = 1;
     17
     18   r1 c1%Rowtype;
     19  Begin
     20  Open c1;
     21  Loop
     22  Fetch c1 Into r1;
     23  Exit When c1%Notfound;
     24   dbms_output.put_line(r1.CH_STATUS);
     25  End Loop;
     26  End;
     27  /
    
    a
    a
    d
    
    PL/SQL procedure successfully completed
    
    SQL> 
    
  • Oracle text index does not return the expected results.

    Hello

    My project requires a generic search on 5 different columns and all the VARCHAR2 data type.
    As performance is very slow with AS % search, I try to use for the multi_column_datastore that is recommended for this.

    Here's what I did.

    1 - Create table.
    CREATE TABLE BILLING_SCHEMA.NAMES_TABLE ( 
        ID                  NUMBER(9,0) NOT NULL,
        ENTITY_NUMBER         VARCHAR2(30) NOT NULL,
        GIVEN_NAMES         VARCHAR2(50) NULL,
        SURNAME             VARCHAR2(30) NULL,
        ORGANISATION_NAME     VARCHAR2(60) NULL,
        DISPLAY_NAME        VARCHAR2(100) NULL 
        )
    /
    
     
    My search must be made on the columns ENTITY_NUMBER, GIVEN_NAMES, surname, ORGANISATION_NAME and DISPLAY_NAME.

    2. - insert values into the table
    INSERT INTO NAMES_TABLE VALUES(1, 'GH', NULL, NULL, NULL, 'GROUP OF HOSPITAL')
    /
    INSERT INTO NAMES_TABLE VALUES(2, 'DH', NULL, NULL, NULL, 'DEPARTMENT OF HEALTH')
    /
    INSERT INTO NAMES_TABLE VALUES(3, 'REC', NULL, NULL, NULL, 'DEBTOR FOR RECEIPTS')
    /
    INSERT INTO NAMES_TABLE VALUES(4, 'UN_REC', NULL, NULL, NULL, 'DEBTOR FOR UNMATCHED RECEIPTS')
    /
    INSERT INTO NAMES_TABLE VALUES(5, 'SAM_FUND', NULL, NULL, NULL, 'THE S FUND')
    /
    
     
    3 - create context multi_column_datastore index
    BEGIN
    CTX_DDL.CREATE_PREFERENCE('NAMES_TABLE_MULTI', 'MULTI_COLUMN_DATASTORE');
    CTX_DDL.SET_ATTRIBUTE('NAMES_TABLE_MULTI', 'COLUMNS', 'ENTITY_NUMBER, GIVEN_NAMES, SURNAME, ORGANISATION_NAME, DISPLAY_NAME');
    END;
    
    CREATE INDEX NAMES_TABLE_IDX
    ON NAMES_TABLE(ENTITY_NUMBER)
    INDEXTYPE IS   CTXSYS.CONTEXT
    PARAMETERS ('DATASTORE NAMES_TABLE_MULTI')
    
     
    4 - create the trigger that should update the column ENTITY_NUMBER if everything is inserted/updated
    CREATE OR REPLACE TRIGGER NAMES_TABLE_TRIGGER
    BEFORE INSERT OR UPDATE OF GIVEN_NAMES, SURNAME, ORGANISATION_NAME, DISPLAY_NAME  ON NAMES_TABLE
    FOR EACH ROW
    BEGIN
      :NEW.ENTITY_NUMBER := :NEW.ENTITY_NUMBER;
    END
     
    5. the search query
    SELECT *
    FROM NAMES_TABLE
    WHERE  CONTAINS(ENTITY_NUMBER,'%TH%') > 0
     
    I am so very confused here because the result returned is only
    ID     ENTITY_NUMBER     GIVEN_NAMES     SURNAME     ORGANISATION_NAME     DISPLAY_NAME         
     2      DH                  (null)        (null)         (null)          DEPARTMENT OF HEALTH 
     
    When I wait for him that the 5th inserted record is returned too as it contains "THE S FUND" that begins with "TH".

    When I use the search string '% %' and %, no results are returned, although I expect at least two records in each case.

    I would appreciate help with this.

    Thanks in advance,
    Marilyn

    Published by: user5615580 on 08/03/2011 21:35

    Published by: user5615580 on 08/04/2011 16:33
  • Search app not showing the expected results

    I have a brand new iPad 2 Air and I am on iOS later.  During the common research applications in the App Store like Alaska airlines, Southwest Airlines or Costco or Castlight health, search results do not contain these common applications.  The only way that I could find is the google search on safari and go to app results which will then take me to the correct application of the App Store.  Needless to say, it's frustrating. I'm doing something wrong?  Anyone else with this experience?

    HI I can help you

  • Why is my zero-order hold to not give the expected result?

    I'm trying to reproduce the functionality of the function of the command discrete so that I can use it without having to have a ' loop control and Simulation ".» The attachment desiredresult.vi shows an example of the function to hold discreet order inside the ' loop control and Simulation ".» The other attachment (zeroorderholdquestion.vi) shows my attempt to achieve the same result. I multiplied all index of the loop of the sampling period for the index table for the output y resampled. I have this based on my understanding of the scheme of discrete command waiting given under http://zone.ni.com/reference/en-XX/help/371894G-01/lvsim/sim_dzoh/#details.

    However, I have difficulties to get the frequency of the wave before and after resampling to match to the top. (See attachment for more clarity on what I mean by that). Any suggestions on what I am doing wrong?

    Here, I wrote something similar perhaps to simulate a multi channel, mux, taste and will hold with crosstalk

    http://forums.NI.com/T5/LabVIEW/how-can-I-create-and-sample-and-hold-circuit-in-LabVIEW/m-p/2407256#...

    If time samplerate and hold have a clean report you just need help vi

    Another simple version:

  • Export-Csv not generating expected results


    I'm trying to generate a report from the script of grouping of NETWORK cards, but given the following code I will have to create Excel object and define its elements?

    The Export-Csv option does not work as I expect in this case. Thank you for your help.  The following code:

    ($VMHost in Get-VMHost){

    Foreach ($vSwitch in ($VMHost | Get-VirtualSwitch )){

    $NicTeaming = Get NicTeamingPolicy -VirtualSwitch $vSwitch

    $obj = new-object psobject

    $obj | Add Member -membertype NoteProperty -name home -value $VMHost

    $obj | Add Member -membertype NoteProperty -name vSwitch -value $vSwitch

    $obj | Add Member -membertype NoteProperty -name NumPorts -value $vSwitch. NumPorts

    $obj | Add Member -membertype NoteProperty -name NumPortsAvailable -value $vSwitch. NumPortsAvailable

    $PG = $vSwitch | Get-VirtualPortGroup

    If ($PG. Count-gt 1){

    $obj | Add Member - membertype NoteProperty -nom échanges -valeur ([string] ::join()«, », ($PG)))

    }

    Else {}

    $obj | Add-Member - membertype NoteProperty-trade name-value $PG

    }

    $obj | Add-Member - membertype NoteProperty - name BeaconInterval-$NicTeaming.BeaconInterval value

    $obj | Add-Member - membertype NoteProperty - name LoadBalancingPolicy-$NicTeaming.LoadBalancingPolicy value

    $obj | Add-Member - membertype NoteProperty - name NetworkFailoverDetectionPolicy-$NicTeaming.NetworkFailoverDetectionPolicy value

    $obj | Add-Member - membertype NoteProperty - name NotifySwitches-$NicTeaming.NotifySwitches value

    $obj | Add-Member - membertype NoteProperty - name FailbackEnabled-$NicTeaming.FailbackEnabled value


    If ($NicTeaming.ActiveNic - gt 1) {}

    $obj | Add-Member - membertype NoteProperty-ActiveNic name-value ([string]: join (",", ($NicTeaming.ActiveNic)))

    }

    Else {}

    $obj | Add-Member - membertype NoteProperty - name ActiveNic-$NicTeaming.ActiveNic value

    }

    If ($NicTeaming.StandbyNic - gt 1) {}

    $obj | Add-Member - membertype NoteProperty-StandbyNic name-value ([string]: join (",", ($NicTeaming.StandbyNic)))

    }

    Else {}

    $obj | Add-Member - membertype NoteProperty - name StandbyNic-$NicTeaming.StandbyNic value

    }

    If ($NicTeaming.UnusedNic - gt 1) {}

    $obj | Add-Member - membertype NoteProperty-UnusedNic name-value ([string]: join (",", ($NicTeaming.UnusedNic)))

    }

    Else {}

    $obj | Add-Member - membertype NoteProperty - name UnusedNic-$NicTeaming.UnusedNic value

    }

    $obj | Add-Member - membertype NoteProperty - name CheckBeacon-$NicTeaming.CheckBeacon value

    $obj

    $Report += $obj

    }

    $Report = $Report | Sort-Object VMName

    IF ($Report - don't ' ")

    {$Report |} {Export-Csv NIC - Teaming.csv}

    }

    You declare $report in a table?

    On the first line

    $report = @)

  • I have run this query to get the result as below, but, even if my query is running fine, that I do not get the expected result.

    I'm looking for only column compare to my same target table as a table source.

    My query:


    Select case when column_name_s is null and column_name_t is not null

    then "alter table GRADE_CONVERSION drop | column_name_t | ';'

    When column_name_s is not null and column_name_t is null

    then "alter table GRADE_CONVERSION add | column_name_s | ' ' || data_type_s | « ; »

    else 'alter table modify GRADE_CONVERSION | column_name_t | ' ' || data_type_t | « ; »

    alterations of the end

    from (select s.column_name column_name_s, t.column_name column_name_t,

    s.data_type data_type_s, t.data_type data_type_t

    (select column_name, column_id, data_type

    of all_tab_cols@database

    where owner = 'erhan.

    and table_name = "GRADE_CONVERSION."

    + 1

    full outer join

    (select column_name, column_id, data_type

    of all_tab_cols@database

    where owner = 'sarigul.

    and table_name = "GRADE_CONVERSION."

    + 6

    on s.column_name = t.column_name

    )




    Tables:



    Target table: table GRADE_CONVERSION in sarigul@database


    LETTER_GRADEVARCHAR2 (2)
    GRADE_POINTNUMBER (3.2)
    MAX_GRADENUMBER (3)
    MIN_GRADENUMBER (3)




    Table source: Table GRADE_CONVERSION in erhan@database

    LETTER_GRADEVARCHAR2 (2)
    GRADE_POINTNUMBER (3.2)
    MAX_GRADENUMBER (3)
    MIN_GRADENUMBER (3)
    CREATED_BYVARCHAR2 (30)
    CREATED_DATEDATE
    MODIFIED_BYVARCHAR2 (30)
    MODIFIED_DATEDATE



    want to see output that is similar to this * (please ignore the names of column here it's just a clear example :))


    ALTER table Target_table change BOOK_ID Varchar2 (4);

    ALTER table Target_table I addSBN_10 Varchar2(13), null;

    ALTER table drop TITLE Target_table;

    Erhan_toronto wrote:

    1.I used src.nullable src_nullable and tgt.nullable tgt_nullable but only show Yes as below: but want to see the result as not null or null

    ALTER table TEST_TARGET change the NUMBER of MAX_GRADE (3, 2) Yes

    Ok. So it's all about the Yes and the no decoding to Default Null or Not Null, isn't it?

    So, to test, change one of the table of sample for NOT NULL columns in the source table, and then run the following query:

    with src as
    (
      select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale,
             src.nullable src_nullable
        from user_tab_columns src
       where table_name = 'TEST_SOURCE'
    ),
    tgt as
    (
      select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len, tgt.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale,
             tgt.nullable tgt_nullable
        from user_tab_columns tgt
       where table_name = 'TEST_TARGET'
    ),
    col_details as
    (
      select src.src_table_name, nvl(tgt.tgt_table_name, first_value(tgt_table_name) over(order by tgt_table_name nulls last)) tgt_table_name,
             src.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable,
             tgt.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable
        from src
        left outer join tgt
          on (
              src.src_col_name = tgt.tgt_col_name
             )
    )
    select *
      from (
            select case
                    when tgt_data_type != src_data_type or tgt_data_len != src_data_len or tgt_data_precision != src_data_precision or tgt_data_scale != src_data_scale or src_nullable != tgt_nullable
                      then 'alter table ' || tgt_table_name || ' modify ' || tgt_col_name || ' ' || src_data_type || ' (' ||
                      case when src_data_type in ('DATE') then null
                           else
                                case
                                  when src_data_type in ('VARCHAR', 'VARCHAR2')
                                    then nvl(to_char(src_data_len), ' ') || ') '
                                  else  decode(nvl(src_data_precision, -1), -1, null, nvl(to_char(src_data_precision), ' ') || ', ' || nvl(to_char(src_data_scale), ' ') || ')')
                                end
                      end
                      || decode(src_nullable, 'NO', ' NOT NULL', ' DEFAULT NULL')
                    when tgt_col_name is null
                      then 'alter table ' || tgt_table_name || ' add ' || src_col_name || ' ' || src_data_type ||
                      case when src_data_type in ('DATE') then null
                           else
                                case
                                  when src_data_type in ('VARCHAR', 'VARCHAR2')
                                    then nvl(to_char(src_data_len), ' ') || ') '
                                  else  decode(nvl(src_data_precision, -1), -1, null, nvl(to_char(src_data_precision), ' ') || ', ' || nvl(to_char(src_data_scale), ' ') || ')')
                                end
                      end
                      || decode(src_nullable, 'NO', ' NOT NULL', ' DEFAULT NULL')
                   end alter_statement
              from col_details
            )
    where alter_statement is not null;
    

    Erhan_toronto wrote:

    2. when I run below under user sarigul and erhan I get the result as OWNER, TABLE_NAME, COLUMN_NAME DATA_TYPE... I have a link between two users. They have access to two tables.

    • Select * from all_tab_columns

    where owner = 'erhan' and table_name = "TEST_SOURCE."

    • Select * from all_tab_columns

    where owner = 'sarigul' and table_name = "TEST_TARGET."

    Alright. This means that you both users are on the same database. Only change, you will have to do in the above query is so change user_tab_columns to all_tab_columns and add the OWNER predicate respectively with the clause.

  • outer join does not give the expected results (missing documents)

    Hello
    I have problem with outer join in OBIEE 10 g.

    I'm testing it on the model of simplified database

    STAT table with some statistics of TYPEs
    stat_date, id_type, num
    ..
    ..
    26/03/2003, 20: 1
    26/03/2003, 21: 1
    26/03/2003, 23: 1
    26/03/2003, 24, 1
    26/03/2003, 25, 1
    ..
    27/03/2003, 22, 1 <-different date here
    ..
    ..

    Table TYPES
    ID_type
    ..
    ..
    20
    21
    22
    23
    24
    25
    ..
    ..


    Physical model
    STAT >-TYPES


    AM.
    F1 (only Digital STAT table column (agg. County))
    D1 (STAT_DATE of the STAT table column only)
    D2 (source TYPES)

    D1 - inner join - < F1
    D2 - left outer join - < F1


    I would like to create simple report filtered by date with number of each type.
    I want to get this result
    ID_type County
    ..     ..
    ..     ..
    20 1
    21 1
    22 null
    23 1
    24 1
    25 1
    ..     ..
    ..     ..


    But I get this
    ID_type County
    ..     ..
    ..     ..
    20 1
    21 1
    23 1
    24 1
    25 1
    ..     ..
    ..     ..

    ID_type 22 is missing


    !!!

    I NORMALLY GET RESULT ONLY IF I DELETE RECORD ' 27/03/2003 22' OF MY FACT TABLE.

    !!!


    I have the filter on the date column D1
    STAT_DATE = 26/03/2003 or STAT_DATE is null


    BI Server running this SQL query


    Select distinct D1.c1 as c1,
    D1. C2 C2
    Of
    (select count (T17840. NUM) in c1.
    T17867.ID_TYPE C2
    Of
    Left outer join of TYPES T17867
    STAT T17840 on T17840.ID_TYPE = T17867.ID_TYPE
    where (T17840. STAT_DATE in (TO_DATE ('2003-03-26', 'YYYY-MM-DD')) or T17840. STAT_DATE is null)
    T17867.ID_TYPE group
    ) D1


    Can you give me some advice?

    Thank you

    Hi cardel,

    I think that you can achieve your goal if you build a dimension of the array STAT form, you can create a table Alias in the physical layer and then to join the table of facts (external to the left). In this way, I think that you can solve your problem.

    Let me know.

    Kind regards
    Gianluca

  • not displaying recordset is not the expected results

    Hello

    I try to get the recordset to display only users with an access level of 1 and the person that is connected only to assign the task to.

    $paramUser_rsTaskUsers = "-1";
    If (isset($_SESSION['kt_login_id'])) {}
    $paramUser_rsTaskUsers = (get_magic_quotes_gpc())? $_SESSION ['kt_login_id']: addslashes($_SESSION['kt_login_id']);
    }
    @mysql_select_db ($database_cbank, $cbank);
    $query_rsTaskUsers = sprintf ("" SELECT * FROM users WHERE AccessLevel = 1 AND UserID = %s ", GetSQLValueString ($paramUser_rsTaskUsers,"int")");
    $rsTaskUsers = mysql_query ($query_rsTaskUsers, $cbank) or die (mysql_error ());
    $row_rsTaskUsers = mysql_fetch_assoc ($rsTaskUsers);
    $totalRows_rsTaskUsers = mysql_num_rows ($rsTaskUsers);

    y at - it something wrong with my request as it is only showing to the user who is logged in the drop-down list to the bottom of the list and not the accesslevel = 1 users too.

    Thank you very much

    Your application uses AND, which means that both conditions must be met: 1 user access level and specific ID. As a result, you will get a single result.

    If you want all the people with the 1 and the specific user access level (regardless of the level of access), to modify AND where.

  • REGEXP_LIKE return is not the expected results

    My first attempt at REGEXP_LIKE and I am obviously missing something. I tried several suggestions I found on the forum but can not get the correct results. I need the following query to return only rows with only alphabetic characters (no numbers). What I get are lines containing letters and numbers.

    Any help will be greatly appreciated!

    Randy

    SELECT order_number
    Of order_table
    where REGEXP_LIKE (order_number, "[a - z A - Z]")
    select order_number
    from order_table
    where regexp_like(order_number,'^[[:alpha:]]+$')
    

    Published by: michaels2 on 10 Sep 2009 15:51

    No need to 'i '.

  • Invoke VMScript not return expected results

    Hello

    I use VMScript-Invoke to call a script, then return to the State of the output of the script. Since it is Linux I'm back the $? variable.

    To simplify the problem, I wrote a little script on my linux system which is as follows:

    #! / bin/bash
    Output 1

    I have this saved in / tmp and called it exit1.sh. If I run this command line, I get this back:

    (root@au-lab) / tmp$. / exit1.sh; ECHO $?

    1

    If I run VM script I get:

    Invoke-VMScript - VM AU-GSCLAB-7 - ScriptText "/ tmp/exit1.sh;» echo "" $? "- GuestPassword root password - GuestUser |" Select ScriptOutput - ExpandProperty

    0

    PowerCLI Version

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

    VMware vSphere PowerCLI 5.0.1 build 581491

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

    Versions of the snap

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

    VMware AutoDeploy PowerCLI component 5.0 build 544967

    VMware ImageBuilder PowerCLI component 5.0 build 544967

    License of VMware PowerCLI component 5.0 build 544881

    VMware vSphere PowerCLI component 5.0 build 581435

    Hello

    It looks like we have some problems with the redirection of output and the "echo". I log a bug for this. I don't know if this will help, but you can get the exit code of the script of the VMScriptResult returned by Invoke-VMScript:

    Invoke-VMScript - VM AU-GSCLAB-7 - ScriptText "/ tmp/exit1.sh ' GuestPassword - root password - GuestUser | Select ExitCode - ExpandProperty

    1

  • Expect a result of zero when subtracting, but is 138.778E - 18

    I get unexpected values in a subtraction routine. I'm using LabView 2013.

    In my example code VI, I have several condition blocks sequentially decremented 7 banks of values. I get an unexpected result when executing my code under the following conditions:

    Bank 1 = 1.0

    2 the Bank to Bank 7 = 100

    BankTTL = 601,00

    Maneuvers of rate = 1, which makes the Rate(%FP/s) = 0.10

    I run the code 10 times expected decremented by 1 Bank of 0.10 each time.

    When I run the code the 11th time, 1 Bank should remain at zero and Bank 2 should begin decrement.

    However, this is not the case...  1 Bank becomes-. 01. This should not happen.

    By tracing the code, put a probe on the entrance to the indicator of Bank 1, the value returned after 10 executions in the "probe Watch Window' is 138.778E - 18. This is unexpected. The value displayed in the front panel is 0.00.

    When I start my logic with the following values:

    Bank 1 = 0.1

    2 the Bank to Bank 7 = 100

    BankTTL = 600.10

    Maneuvers of rate = 1, which makes the Rate(%FP/s) = 0.10

    I get the expected result of zero in the 'spy Probe window' as the façade for Bank 1 indicator.

    Your help to solve the unexpected result would be greatly appreciated.

    Thank you.

    Lixuan

    SGL/DBL types store numbers in binary format. Powers of 2 can be represented accurately (..., 0.125, 0.25, 0.5, 1, 2, 4, 8,...), but most of the other numbers may not.

    100, 0.1 and 601 are not powers of 2, so these values can be stored precisely and produce any rounding errors. See: ""which causes any floating point rounding errors?".

    Note that 138.778E - 18 is 0.000000000000000138778, which is very close to zero as your starting value is of ~ 600.

  • Ask help - please help me get the expected defined in a query result

    Dear all,

    Help with your suggestions and advice. Please see the bottom of the screenshots for the planned result sets.

    create table shift_dt 
    (name varchar2(20),
    shift_start date,
    shift_end date);
    
    insert into shift_dt values ('Brian',to_date('01-01-2015 09:10:00','dd-mm-yyyy hh24:mi:ss'), to_date('01-01-2015 22:10:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('02-01-2015 09:10:00','dd-mm-yyyy hh24:mi:ss'), to_date('04-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('04-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('05-01-2015 15:20:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('06-01-2015 10:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('06-01-2015 23:20:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('07-01-2015 11:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('09-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'));
    insert into shift_dt values ('Brian',to_date('09-01-2015 00:00:00','dd-mm-yyyy hh24:mi:ss'), to_date('10-01-2015 22:00:00','dd-mm-yyyy hh24:mi:ss'));
    
    select * from shift_dt;
    
    
    

    Select * from shift_dt;

    1.jpg

    Expected result set: -.

    1.jpg

    I compare date of shift_end with the next date of shift_start of the day. If the dates made 12 am (IE 00:00:00), then I ignore and display the next shift end date available as displayed in the screen game result. Please see the screen set outcome turned for more details.

    Please help get the results you want in the SQL query

    Kind regards

    Souls

    Hello

    Here's one way:

    WITH got_new_grp AS

    (

    SELECT name, shift_start, shift_end

    CASE

    WHEN shift_start = TRUNC (shift_start)

    AND shift_start = LAG (shift_end) OVER (ORDER BY shift_start)

    THEN 0

    1. OTHER

    END AS new_grp

    OF shift_dt

    )

    got_grp AS

    (

    SELECT name, shift_start, shift_end

    SUM (new_grp) OVER (ORDER BY shift_start) AS grp

    OF got_new_grp

    )

    SELECT MIN (name) DUNGEON (DENSE_RANK FIRST ORDER BY shift_start)

    As a name

    MIN (shift_start) AS shift_start

    MAX (shift_end) AS shift_end

    OF got_grp

    GROUP BY grp

    ORDER BY shift_start

    ;

    Output (from the full sample data):

    NAME SHIFT_START SHIFT_END

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

    01/01/2015 Brian 09:10 01/01/2015 22:10

    Brian 02/01/2015 09:10 01/05/2015 15:20

    Brian 06/01/2015 10:00 01/06/2015 23:20

    Brian 07/01/2015 11:00 10/01/2015 22:00

    Brian 01/02/2015 15:00 02/02/2015 00:00

    Brian 02/02/2015 11:00 02/02/2015 17:00

    Brian 03/02/2015 00:00 03/02/2015 08:00

    Brian 02/05/2015 15:30 06/02/2015 07:30

    Brian 07/02/2015 23:30 10/02/2015 00:30

    I guess that shift_start is unique.

    It's finally a GROUP BY problem: we want to show the first shift_start and the last shfit_end of a group of 1 or more lines.  The tricky part is to identify the groups.  If I understand the problem, line X is grouped with the previous line X-1 if shift_start on the X line is midnight and is equal to shift_end on line X-1.  The above query uses the LAG analytic to see if each line begins a new group or not and the analytic function SUM to see how many groups have already begun (and therefore, which group each line entry belongs.)

    I still don't understand why you 'Corrected name of Anne in Brian' and not vice versa.  I guess the name to display in each group is the name of the first row in the Group (i.e. the line with the shift_start earlier).

Maybe you are looking for