Creation of function to calculate average

Hello

The following query has been successfully returned an average value. He returns 1 row.

---
SELECT AVG (Volume)
SECURITY
WHERE
Type = 'Future' AND
Note = "AAA" AND
Code = 1 AND
(Day = "14-mar-09' OR)
Day = 16-mar-09' OR
Day = ");
---

I tried to use this function on my function created below.

--------
FUNCTION to CREATE or REPLACE fn_Vol_Average

(DATE IN v_DayLast_1_Week,
v_DayLast_2_Week IN DATE,
v_DayLast_3_Week IN DATE)

RETURN NUMBER IS
v_Vol_Average NUMBER;

BEGIN

SELECT AVG (Volume) IN the v_Vol_Average
SECURITY
WHERE
Type = 'Future' AND
Note = "AAA" AND
Code = 1 AND
(Day = v_DayLast_1_Week OR)
Day = v_DayLast_2_Week OR
Day = v_DayLast_3_Week;)

RETURN NVL (v_Vol_Average, NULL);

END;
---------

I called this function with the following query. It was work, but it return the whole lines. It seems the function to perform the calculation of the average of each lines on the table.

Can someone help me what happens with logic?
--
Select fn_Vol_average('14-mar-09','16-mar-09','')
Security
--
select fn_Vol_average('14-mar-09','16-mar-09','')
from security

What you trying to accomplish?

Maybe you wanted to say:
Select fn_Vol_average('14-mar-09','16-mar-09','')
from DUAL;

It's kind of a weird way to write and call a function well.

Tags: Database

Similar Questions

  • Function to calculate the days of work

    Hi all

    I accidentally develop an application in which I had to follow the thread below and it works perfectly for the weekend (Saturday and Sunday)

    PL/SQL function to calculate the non-working days

    Now, my specific question is: how to implement the same function , but weekends (Fri & sat).

    I tried to recognize the logic behind the calendar to change the days of the weekend, but I suspect.

    I need your recommendation around this function specifically.

    !-[CodeBlockStart:3cad70b5 - 81 a 0-4f6b-909 a-cacb29e25953]--> BOX WHEN IN l_case (-"Mon6", "Tue5", "Wed4", "Thu3", "Fri2" - exclude Saturday & Sunday, workday begins from Monday 'Sun6', 'Mon5', 'Tue4', 'Wed3', 'Thu2' - remove begins day 2 business days (Fri & sat) on Sunday and maintaining the order of the sequences,-"Sat1", "Sun1", "Sun2', 'Sun3', 'Sun4' - Include weekend can be for the rest of the week) , "Sat1", "Sat2", 'Fri1', "Sat3", "Sat4" - includes my week ends replace (with FRI Sat) & (Sun to SAT) & law enforcement-sequence, "Sun5', 'Sun6',"Sat5","Sat6"- replace (Sun with Sam).                                                                   ) 1 THEN WHEN IN l_case (-'Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5" - Old (Saturday and Sunday) end over the next week - I guess - sequence of days - since the week days sequence Changed (number 1 or 1 step backward) when numbers also changed accordingly "Tue5", "Wed4", "Wed5", "Thu3", "Thu4" - ok-, 'Thu6', 'Fri3', "Fri4", "Fri5", "Fri6", "Thu5", "Sun1", "Sun2", 'Sun3', 'Sun4' - contiue to Thu sequence number & then replace my current (Friday) holiday with start of work dat (Sun) "Fri1") (, 'Fri2', 'Fri3', 'Fri4', "Fri5") THEN 2 0 OTHERWISE END;

    Thanks in advance.

    Amatu Allah

    with

    calendar as

    (select dat_val,

    cases where to_char(dat_val,'mm-dd') in (12-25', 12-26', ' 01-01')-in fact select the host table to_char(holiday_date,'mm-dd')

    then "vacation."

    When to_char (dat_val, 'Dy') in ('Friday', 'Saturday')

    then 'weekend '.

    else 'work '.

    end dat_type

    sum (case when to_char(dat_val,'mm-dd') in (12-25', 12-26', ' 01-01'))

    then 0

    When to_char (dat_val, 'Dy') in ('Friday', 'Saturday')

    then 0

    1 other

    end

    ) on working_count (dat_val control)

    from (select date "' 2015-12-01 + level - 1 dat_val)

    of the double

    connect by level<=>

    )

    )

    Select dat_val,

    dat_type,

    working_count

    calendar

    where dat_val between to_date(:lo_date,'yyyymmdd') and to_date(:hi_date,'yyyymmdd')

    and dat_type! = work «»

    DAT_VAL DAT_TYPE WORKING_COUNT
    11/12/2015 end of week 8
    12/12/2015 end of week 8
    18/12/2015 end of week 13
    19/12/2015 end of week 13
    25/12/2015 holiday 18
    26/12/2015 holiday 18
    01/01/2016 holiday 23
    02/01/2016 end of week 23
    08/01/2016 end of week 28
    09/01/2016 end of week 28

    Select to_date(:lo_date,'yyyymmdd') lo_date,

    to_date(:hi_date,'yyyymmdd') hi_date,

    dat_val,

    dat_type,

    working_count,

    Lead (working_count) more (order of dat_val) - working_count + 1 working_days,

    to_date(:hi_date,'yyyymmdd') - to_date(:lo_date,'yyyymmdd') - lead (working_count) (order dat_val) + working_count non_working_days

    calendar

    where dat_val in (to_date (:hi_date,'yyyymmdd'),to_date(:lo_date,'yyyymmdd'))

    LO_DATE HI_DATE DAT_VAL DAT_TYPE WORKING_COUNT WORKING_DAYS NON_WORKING_DAYS
    10/12/2015 10/01/2016 10/12/2015 work 8 22 10
    10/12/2015 10/01/2016 10/01/2016 work 29 - -

    Concerning

    Etbin

  • PL/SQL function to calculate the non-working days

    Hello

    I have the following pl/sql function which generates a number of days between two selected dates (i.e. excluding weekends). However, I also need to exclude specific holidays - day of Christmas etc. These holiday dates are stored in a table in our database (11 GR 2) called "HOLIDAY".

    How can I integrate the holidays which is held in the table of holidays in the following query to exclude these dates as well? I know how to write a separate funtion pl/sql for a number of days between two dates using SELECT... BUT I can't work out how to bring together them in a single query.

    Could someone show me how with the pl/sql / dates below please?

    Example of HOLIDAY table below.

    Thank you!

    TP

    create or replace
    function WORKING_DAYS (pi_start_date in date, pi_end_date in date) return integer
    
    is
    
    v_start_date date :=pi_start_date;
    v_end_date date:=pi_end_date;
    v_count integer:=0;
    
    begin
    
    while v_start_date <= v_end_date
          loop
                            if to_char(v_start_date,'D') not in ('6','7')                    
                            then
                            v_count := v_count+1;                       
                            end if;
                           
                    v_start_date:=v_start_date+1;
                   
          end loop;
         
    return v_count;
    
    end;
    
    

    (select '10-Apr-2013' as NWD from dual union all
    select '06-May-2013' from dual union all
    select '27-May-2013' from dual union all
    select '26-Aug-2013' from dual union all
    select '26-Dec-2013' from dual union all
    select '25-Dec-2013' from dual union all
    select '01-Jan-2014' from dual union all
    select '18-Apr-2014' from dual union all
    select '21-Apr-2014' from dual union all
    select '05-May-2014' from dual union all
    select '26-May-2014' from dual union all
    select '25-Aug-2014' from dual union all
    select '25-Dec-2014' from dual union all
    select '26-Dec-2014' from dual) HOLIDAYS
    

    Hello

    the link is on MOSC, not OTN... Here's a copy:

    This function calculates the number of days between two dates, ignoring weekends and holidays (if requested and if the holidays are stored in a table)

    I give an example of table 'public_holiday' with sample data, but users must ensure that their table contains the relevant data (all holidays within the maximum range of use of the service)

    CREATE TABLE public_holiday (calendar_day, DATE, text VARCHAR2 (30));

    FUNCTION to CREATE or REPLACE nb_days (p_date_from IN DATE

    p_date_to DATE by DEFAULT TRUNC (sysdate)

    , p_public_holidays in CHAR DEFAULT 'Y '.

    ) RETURN NUMBER

    DEFINE AUTHID

    AS

    /*********************************************************************/

    / * Author: Bruno Vroman * /.

    / * Created: 23-AUG-2012 * /.

    / * Last updated: 23-AUG-2012 * /.

    / * Object: to calculate the number of days between 2 dates, to the exclusion of * /.

    / * Saturday and Sunday, but also "holidays" If the * /.

    / * argument 'p_public_holidays' = 'Y ' * /.

    / * Support: p_date_from<= p_date_to                             ="">

    / * component ' hour min dry "ignored (just counting days) * /.

    /* First step:                                                       */

    / * the calendar days between 2 days * /.

    / Remove 2 days for each "week" and 0 or 1 extra day * /.

    / * function to a condition "complex" mix day of first week * /.

    / * and the number of days when full remaining weeks are removed * /.

    / * (set up once for all, for example if there is 3 days and the * /)

    (/ * first day is a Thursday, there is 1 "Sat/Sun" to subtract) * /.

    / * Second step: If 'p_public_holidays' = 'Y': other * /.

    / * days, do not count holidays.                         */

    / Holiday everyday are defined in a table "public_holiday" * /.

    / * Note: there may be holidays defined on Saturday/Sunday.       */

    /*********************************************************************/

    l_result NUMBER;

    l_from DATE;

    l_to DATE;

    l_case tank (4);

    BEGIN

    l_from: = TRUNC (p_date_from);

    l_to: = TRUNC (p_date_to);

    l_case: = TO_CHAR (l_from, 'Dy', 'NLS_DATE_LANGUAGE = English').

    To_char (MOD (l_to - l_from + 1, 7));

    l_result: = l_to - l_from + 1

    -TRUNC ((l_to-l_from + 1) / 7) * 2

    -CASE

    WHEN l_case IN ('Mon6', 'Tue5', 'Wed4', 'Thu3', 'Fri2'

    , "Sat1", "Sun1", "Sun2', 'Sun3", "Sun4".

    , "Sun5', 'Sun6.

    )

    THEN 1

    WHEN l_case IN ('Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5"

    , 'Thu6', 'Fri3', 'Fri4', 'Fri5', 'Fri6 '.

    , "Sat2", "Sat3', 'Sat4', 'Sat5", "Sat6.

    )

    THEN 2

    0 OTHERWISE

    END

    ;

    IF SUPERIOR (p_public_holidays) = "Y".

    THEN

    SELECT l_result - COUNT (*)

    IN l_result

    OF public_holiday p

    WHERE p.calendar_day > = l_from

    AND p.calendar_day<=>

    AND SUBSTR (TO_CHAR (p.calendar_day

    , "Dy".

    'NLS_DATE_LANGUAGE = English'

    )

    , 1, 1 ) != 'S'

    ;

    END IF;

    RETURN l_result;

    EXCEPTION

    WHILE OTHERS

    THEN

    DBMS_OUTPUT. Put_line (' CTF nb_days (' |))

    To_char (p_date_from, "MON-DD-YYYY"). ', ' ||

    To_char (p_date_to, "MON-DD-YYYY"). ', ' ||

    p_public_holidays | ' ) : ' || SQLERRM

    );

    LIFT;

    END nb_days;

    /

    REM

    REM example:

    REM A) fill out the 'public_holidays '.

    REM

    TRUNCATE TABLE public_holiday;

    INSERT INTO public_holiday VALUES (DATE ' 2012-01-01', ' new year (a Sunday)');

    INSERT INTO public_holiday VALUES (DATE '' 2012-01-03, "for example");

    REM (insert other days...)

    COMMIT;

    Call the function for some pairs of dates of REM B)

    REM nb1: remove only Sat/Sun

    REM nb2: also remove holidays

    REM

    ALTER SESSION SET nls_date_format ='Dy DD-MON-YY';

    WITH some_dates AS

    (SELECT DATE ' 2011-12-29'd dual FROM

    UNION ALL SELECT DATE ' 2012-01-08' FROM dual

    UNION ALL SELECT DATE ' 2012-01-10' FROM dual

    )

    SELECT d1.d 'FROM '.

    , d2.d ' to THE '.

    , nb_days (d1.d, d2.d, ' don't) nb1

    , nb_days (d1.d, d2.d, 'Y') nb2

    OF some_dates d1

    some_dates d2

    WHERE d1.d<=>

    ORDER BY nb1, nb2, d1.d

    ;

    GO TO NB1 NB2

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

    Monday, January 8, 12 Monday, January 8, 12 0 0

    Friday, December 29, 11 Friday, December 29, 11 1 1

    Wednesday, January 10, 12 Wednesday, January 10, 12 1 1

    Monday, January 8, 12 Wednesday, January 10, 12 2 2

    Friday, December 29, 11 Monday, January 8, 12 7 6

    Friday, December 29, 11 Wednesday, January 10, 12 9 8

    Hope that this could be useful, but note that this code has not been completely tested, so check and test before you trust it (in the case of any questions, please post a comment)

    Bruno Vroman.

    Best regards

    Bruno

  • How to calculate average daily time of the Start_Time and End_Time fields

    I am using ORACLE 11 G on Red Hat Linux, I have calculated the average daily time of multiple transactions for each day. The followign is the querry that shows the difference between the fields end_time start_ time and time.

    Select TRIP_LOAD_STARTED AS START_TIME, TRIP_LOAD_ENDED'RE END_TIME.

    ceil ((TRIP_LOAD_EDDT-TRIP_LOAD_STDT) * 1440) "time difference Bw Start and End.
    of GATE2GATE_ACTIVITY_VW
    Where TRIP_LOAD_STARTED > = February 1, 14 '
    AND TRIP_LOAD_ENDED < 3 February 14 '
    ORDER BY TRIP_LOAD_STARTED;

    The querry above gives me the result as follows:

    Start_Time End_Time time Diff bw begins and ends

    1 FEBRUARY 14 FEBRUARY 1, 14 18

    1 FEBRUARY 14 FEBRUARY 1, 14 18

    1 FEBRUARY 14 FEBRUARY 1, 14 18

    1 FEBRUARY 14 FEBRUARY 1, 14 18

    1 FEBRUARY 14 FEBRUARY 1, 14 18

    1 FEBRUARY 14 FEBRUARY 1, 14 18

    1 FEBRUARY 14 FEBRUARY 1, 14 12

    FEBRUARY 2, 14 2 FEBRUARY 14 29

    FEBRUARY 2, 14 2 FEBRUARY 14 29

    FEBRUARY 2, 14 2 FEBRUARY 14 29

    FEBRUARY 2, 14 2 FEBRUARY 14 29

    FEBRUARY 2 FEBRUARY 2, 14 14 19

    FEBRUARY 2 FEBRUARY 2, 14 14 19

    FEBRUARY 2 FEBRUARY 2, 14 14 19


    It shows two dates for which I want to get the average duration in minutes for each group to date by the start time.


    I use the following querry that probably gives me the average two days mentioned in where clause


    Select the floor (avg ((TRIP_LOAD_STARTED-TRIP_LOAD_ENDED) * 1440)) 'average of Minutes of time.

    of gate2gate_activity_vw

    Where TRIP_LOAD_STDT > = February 1, 14 '

    AND TRIP_LOAD_STDT < 3 February 14 ';

    Average duration in Minutes

    29

    Can someone help me to a daily average time calculated between start and end.

    Kind regards

    mhamidch

    Is that what you want:

    SELECT trunc (TRIP_LOAD_STARTED), trunc (TRIP_LOAD_ENDED).

    floor (avg (ceil ((TRIP_LOAD_ENDED-TRIP_LOAD_STARTED) * 1440))) Diff

    OF GATE2GATE_ACTIVITY_VW

    WHERE TRIP_LOAD_STARTED > = to_date('01/FEB/2014','dd/MON-YYYY')

    AND TRIP_LOAD_ENDED<>

    Trunc GROUP (TRIP_LOAD_STARTED), trunc (TRIP_LOAD_ENDED)

    Always the example of create table and insert statements to verify the results and use the to_date with date format function.

    Post edited by: Elya

  • Function to calculate the Minutes of business between two Dates

    Hello

    I use the version of database Oracle 11.2.1. I would like to calculate the number of minutes of work between the two dates where working hours are Monday - Thursday from 08:45 to 17:00 and Friday from 08:45 to 16:30

    I found the following function useful in a similar position but wanted help picking up the days and the hours above into account

    CREATE OR REPLACE
      FUNCTION get_bus_minutes_between(
                                       p_start_date DATE,
                                       p_end_date DATE
                                      )
        RETURN NUMBER
        IS
            v_return NUMBER;
        BEGIN
            with t as (
                       select  case level
                                 when 1 then greatest(p_start_date,trunc(p_start_date) + 9 / 24)
                                 else trunc(p_start_date) + level - 15 / 24
                               end start_dt,
                               case connect_by_isleaf
                                 when 1 then least(p_end_date,trunc(p_end_date) + 18 / 24)
                                 else trunc(p_start_date) + level - 8 / 24
                               end end_dt
                         from  dual
                         connect by level <= trunc(p_end_date) - trunc(p_start_date) + 1
                      )
            select  sum(greatest(end_dt - start_dt,0)) * 24 * 60 work_minutes
              into  v_return
              from  t
              where trunc(start_dt) - trunc(start_dt,'iw') < 5; -- exclude weekends
            RETURN v_return;
    END;
    /

    Can anyone help?

    Hello

    Think about what you do.

    sliderrules wrote:

    SELECT TO_CHAR (DATE ' 1-1-1' + business_end_time, 'HH24:MI:SS')-TO_CHAR (DATE ' 1-1-1' + business_start_time, 'HH24:MI:SS') * 24 * 60

    of time_dim

    where full_date = July 1, 2013.

    AND working_day = 'Y ';

    The following error is returned:

    ORA-01722: invalid number

    The time is converted to character reslting with this error. Is there a better way to subrtacting types of data INTERVAL DAY (1) SECOND (2) (business_end_time - business_start_time)

    To_char, as its name implies, returns a string of characters.  You say that

    TO_CHAR (...) - TO_CHAR (...) * 24 * 60

    If you ask for the string returned by the 2nd TO_CHAR be multiplied by 24.  Does make any sense to you?

    Maybe you wanted to do the subtraction first, which would be

    (TO_CHAR (...) - TO_CHAR (...)) * 24 * 60

    but still would be a mistake, because you can't subtract a string to another string (or anything else).

    .

    Last Friday, I proposed this:

    SELECT SUM (LESS (end_dt, v_end_dt)

    -Most GREAT (start_dt, v_start_dt)

    ) * 24 * 60...

    where start_dt and end_dt were the DATE in the table columns, as the value returned by TO_DATE (08 11 July 2013:45 ', "DD-Mon-YYYY HH24").

    If I understand correctly, you would store stores rather 3 columns: full_date (a DATE, where the time part is 00:00:00) as well as business_start_time and business_end_time (the two INTERVAL DAY TO SECOND).  In this case, you can modify the code above to say:

    SELECT SUM (LESS (full_date + business_end_time, v_end_dt)

    -GREATEST (full_date + business_start_time, v_start_dt)

    ) * 24 * 60...

    You can add a DATE at an INTERVAL;  the result will be a DATE.  There is no need to convert anything to a data type to the other.

  • Need to calculate average start time

    Hello

    Someone at - it an example of how to calculate the start time medium for a range of dates? I essentially have to evaluate a column date (including time) and to determine, on a specific time period, the average start for a process time given each day.

    Any help is greatly appreciated.

    Thank you
    Christine

    Hello.

    Here is a way.

    WITH data AS
    (
         SELECT TO_DATE('2012-01-01 10:30:10','YYYY-MM-DD HH24:MI:SS') start_datetime FROM DUAL UNION
         SELECT TO_DATE('2012-01-02 10:28:20','YYYY-MM-DD HH24:MI:SS') start_datetime FROM DUAL UNION
         SELECT TO_DATE('2012-01-03 10:40:30','YYYY-MM-DD HH24:MI:SS') start_datetime FROM DUAL UNION
         SELECT TO_DATE('2012-01-04 10:17:20','YYYY-MM-DD HH24:MI:SS') start_datetime FROM DUAL UNION
         SELECT TO_DATE('2012-01-05 10:32:50','YYYY-MM-DD HH24:MI:SS') start_datetime FROM DUAL
    )
    SELECT TO_CHAR(TO_DATE('2012-01-01','YYYY-MM-DD')+AVG(start_datetime-TRUNC(start_datetime)),'HH24:MI:SS') avg_start_time
    FROM data;
    
    AVG_START_TIME
    --------------
    10:29:50
    

    I hope this helps.

    Kind regards.

  • Requried helps the creation of function

    Hi all

    I need assistance to create feature my input parameters for this function will be 1 or 1,2 1,2,3

    my output should be

    If I pass 1 as an input parameter, it should return 1
    If I spend 1, 2 as input parameter it should return 1.2 in different lines
    Even if I switch 1,2,3 as an input parameter it should return 1,2,3 in different lines.

    Can someone help me please in the creation of this function.

    Thanks in advance.

    Published by: p78 on January 16, 2012 03:31

    Published by: p78 on January 16, 2012 03:31

    Hello

    It will be something like that. You must first type to return lines (use another number, for example data type if you must):

    CREATE OR REPLACE TYPE t_list AS TABLE OF VARCHAR2 (4000);
    /
    

    Then, the function will be a pipeline function:

    CREATE OR REPLACE FUNCTION in_list (p_list  IN  VARCHAR2)
      RETURN t_list PIPELINED
    AS
      l_text  VARCHAR2(32767) := p_list || ',';
      l_idx   NUMBER;
    BEGIN
      LOOP
        l_idx := INSTR(l_text, ',');
        EXIT WHEN NVL(l_idx, 0) = 0;
        PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
        l_text := SUBSTR(l_text, l_idx + 1);
      END LOOP;
    
      RETURN;
    END;
    /
    

    now, you can query (or whatever the needs):

    select * from table(in_list('aa','bb'));
    

    Herald tiomela
    http://htendam.WordPress.com

  • How can I use the SUM function to calculate the number of employees in the comp. &amp; deptnt?

    I have two tables: employees and their departments. I'm figuring the total employees by the Department and the total employees of the entire society. I know I have to use the SUM function, but I can only calculate total employees by Department and company separately. I need to get this result:

    DEPT_NAME     DEPT_TOTAL_SALARY         COMPANY_TOTAL_SALARY
    RESEARCH                  10875                        29025
    SALES                      9400                        29025    
    ACCOUNTING                 8750                        29025      
    
    
    This is my code:
    
    SELECT department_name, SUM(salary) as total_salary
    FROM employee, department
    WHERE employee.department_id = department.department_id
    GROUP BY department_name;
    
    SELECT SUM(salary)
    FROM employee;
    
    
    
    
    
    
    Can somebody help please?
    Thank you in advance.
    Published by: user13675672 on January 30, 2011 14:29

    Published by: user13675672 on January 30, 2011 14:31

    Hello

    Something like:

    SELECT dname,
           dept_tot_sal,
           SUM (dept_tot_sal) OVER () comp_tot_sal
    FROM   (SELECT   dname,
                     SUM (sal) dept_tot_sal
            FROM     dept, emp
            WHERE    dept.deptno = emp.deptno
            GROUP BY dname);
    

    There might be a smarter way, with no re - select.

    Concerning
    Peter

    Analytical functions:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm

  • How to create a function to calculate the calendar

    Oracle Forms 6i

    Hai

    I'm generating a daily presence that is stored in the database with the fields

    Empcode, attend_date, intimate, outtime, extratime, deptcode, unitid and some other things

    I need to create a function by taking these fields of the table unitid, empcode, intimate, outtime, attend_date, deptcode and return total hours he worked, and more than 8 means it will add in extra time.

    If it is possible to give the run of the date value to which to this day, you must calculate.

    Thanks in advance

    Srikkanth.Ml

    Srikkanth,
    Depending on how you stated your RESPONDENT and OUTTIME, columns this should quite simply be a calculation. For example, if you have declared these columns as DATE columns, the following calculation should work:

    SELECT NVL(OUTTIME,SYSDATE) - INTIME AS hours_worked
    FROM DAILY_ATTENDANCE
    WHERE EMPCODE = "Emp Code of the employee you are evaluating";
    

    Once you have the HOURS_WORKED, you can check if the amount is greater than 8 (or whatever is the approved duration of working hours of the employee's) to determine if he or she worked longer than their approved shift back the extra time, and the user has worked or NULL or zero if they have not exceeded their shift.

    If you have set up the columns of time as something other than the DATE or DATETIME, you will need to convert the values in input/OUTPUT at a DATE so that you can use the functionality of calculation date default Oracle or you need to build your own process of calculation of the WORK_HOURS based on how you store the RESPONDENT and OUTTIME values.

    I hope this helps.
    Craig...

  • help in the creation of function.

    Hi guys I am a newbie in pl/sql...
    I want to create a function that bed alll the lines of a table containing hundreds of lines...
    Break all the lines separated by space in several blocks or columns and check certain conditions on each block/columns...
    For example:
    I have a table that is to have a GBA and hundreds these lines...

    12345 1234 12345 12345 12345 12345 12345 12345
    .
    .
    .
    .
    Now, I want to create a function or a procedure that reads all the lines and check certain conditions on every word of each line...

    for example: 1st condition:
    1st, 2nd, 3rd, 4th and 5th Word is 12345 or not...
    2nd, 3rd, 4th, 5th, 6th Word is 1234 or not
    3rd word has a length = 5 or not, and various other conditions... but one thing is sure, I must check all the words in the line with respect to each condition...


    thnx in advance...

    Or...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with testdata as (select '12345 12345 12345 12345 12345 12346 12347 12348' as txt from dual union all
      2                    select '54321 1234 1234 1234 1234 1234 32785' from dual union all
      3                    select '10101 10101 10101 10101 10101 10101 10101' from dual union all
      4                    select '123 123 123 123 123 123 123' from dual)
      5  --
      6  -- end of test data, use query below
      7  --
      8  select txt
      9        ,case when wrd1 = '12345' and wrd2 = '12345' and wrd3 = '12345' and wrd4 = '12345' and wrd5 = '12345' then
     10                'True'
     11         else 'False' end as cond1
     12        ,case when wrd2 = '1234' and wrd3 = '1234' and wrd4 = '1234' and wrd5 = '1234' and wrd6 = '1234' then
     13                'True'
     14         else 'False' end as cond2
     15        ,case when length(wrd3) = 5 then
     16                'True'
     17         else 'False' end as cond3
     18  from (
     19        select txt
     20              ,regexp_substr(txt,'[^ ]+',1,1) as wrd1
     21              ,regexp_substr(txt,'[^ ]+',1,2) as wrd2
     22              ,regexp_substr(txt,'[^ ]+',1,3) as wrd3
     23              ,regexp_substr(txt,'[^ ]+',1,4) as wrd4
     24              ,regexp_substr(txt,'[^ ]+',1,5) as wrd5
     25              ,regexp_substr(txt,'[^ ]+',1,6) as wrd6
     26        from testdata
     27*      )
    SQL> /
    
    TXT                                             COND1 COND2 COND3
    ----------------------------------------------- ----- ----- -----
    12345 12345 12345 12345 12345 12346 12347 12348 True  False True
    54321 1234 1234 1234 1234 1234 32785            False True  False
    10101 10101 10101 10101 10101 10101 10101       False False True
    123 123 123 123 123 123 123                     False False False
    
  • creation of function in a loop

    Hello-

    My problem is that I have created a bunch of buttons dynamically in a loop and to include a "onRollOver", different for each button function. However, variables that I put in the functions are all being replaced by the value of the last pass through the loop. How can I generate another body of the function for each button that I'm generation?

    my code:

    var dataIndex = 0;
    [while loop]
    {
    var name = "instbut_" + dataindex;
    var button = container.createEmptyMovieClip (Anom, 100 + dataindex);
    [...]
    container [name] .onRollOver = function() {trace ("my button name is" + name) ;}
    dataIndex ++;
    }

    When it works, it generates correctly four buttons - but when I roll over each, 'Anom' is always equal to "instbut_3". How can I force it to generate four separate functions, instead of a single referenced by all the buttons together?

    Thanks for the tips!

    -miranda

    var dataIndex = 0;
    [while loop]
    {
    var name = "instbut_" + dataindex;
    var button = container.createEmptyMovieClip (Anom, 100 + dataindex);
    button.myName = name;
    [...]
    container [name] .onRollOver = function() {trace ("I name the button" + this.myName) ;}}
    dataIndex ++;
    }

    By the way, you could use this instead, but for other variables ._name, give the value you need before writing the handler and then target values with this.

  • average fluctuating value

    Hi, I'm real real-time signal acquisition. I calculated THAT SNR of the received signal problem is Traoré signal SNR is fluctuating between 9 and 15. I like this way.

    I need a block or a function that calculates average values of 50 or 60 last so that reduce the fluctuation of SNR. OR any other method to resolve this isue

    (NRS data type is DBL)

    Thank you

    Hello

    Try the example below, see attached vi.

    Hope this works for you.

  • Calculate the average per slot?

    Hi Chaps,

    I am a beginner on numbers (almost everything on Mac I would say) and I need help to calculate average values.

    These are calculated values (column 2) taken on a specific time of the day (column 1).
    I managed to create a third using a built-in function to get the time slot (column 3).

    14:58:42

    235

    14

    14:59:42

    274

    14

    15:00:50

    7937

    15

    15:01:55

    5157

    15

    16:02:57

    1822

    16

    16:03:57

    207

    16

    Can please somebody see me step by step how to calculate the average by time slot as below?

    14

    254,5

    15

    6547

    16

    1014,5

    Kind regards

    Stone

    This can help you

    Assuming you data in a table named 'Data' and the information is summarised in another table (right) named "Summary".

    Select cell B1 in the summary table and then type (or copy and paste from here):

    = SUMIF(Data::C,a1,Data::B) ÷COUNTIF (Data::C, a1)

    shortcut for this is:

    B1 = SUMIF(Data::C,a1,Data::B) ÷COUNTIF (Data::C, a1)

    Select cell B1, copy

    Select column B, paste

  • How to calculate the average of the 1 d array?

    Could someone please help me, how can I calculate average of the 1 d array? For example, if the table 1 d - is [2, 3], I would get average = 2.5. Thank you very much!

    Use the average function. You can use the search or the quick menu to look for where you don't know where to find.

    Norbert

  • Display the progress bar when you use the Calculate function

    Hello

    For my project, I need to convert the raw values of a signal in physical quantities.

    To do this, I use the function "calculate".

    Because I have a lot of data, it takes time, and the user does not know if it works or not.

    The first thing I did, is to Add Dialog.BeginWaitCursor and Dialog.EndWaitCursor which works well, but is not enough.

    To view activity, I want to display a progress created bar before calling 'Calculate' and stopped after that.

    The progress bar does not need to show real progress, but displayed only a movement of progress even if it again to zeor until the end of the calculation.

    I have read some information on the progress made on this forum, but he did on selfmade function and tiara not call functions.

    This is why it is not useful to me.

    I don't know how to do this using vbs.

    Is it possible to create something like this?

    The best solution would be to get the status of the function of 'Calculate' to see where he is, but the function is not created to do this.

    Thanks for all the ideas,

    Best regards

    CFOE

    Hey CFOE,

    I asked R & D at the same time, because I thought I remembered seeing a progress bar continued in tiara before, but I didn't know if it was something we might call with a VBScript command.  I just heard back that you can, and it's here...

    Call AutoLoopInit
    MsgBox "ready to stop the progress bar?
    Call LoopDeInit

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

Maybe you are looking for

  • Why Norton Toolbar will not work with Firefox 23.0.1?

    Norton Toolbar 2013.4.1.2 is disabled and there is no option to turn it on. I've updated my Norton 360 with all latest updates. Norton site says that it has updated its software to be compatible with Firefox 23. Thank you in advance,Larrey

  • How to reset the password for BIOS on Satellite A15-S127

    What is the best way to reset the password for boot/BIOS/CMOS on a Satellite A15-S127? I saw notes on the creation of a parallel loop, but I can't find the technical notes on how to make one. Even if I can make one, it will work on this model? I don'

  • HP laserJet MFP M277dw Pro: cannot download the drivers for MFP M277dw for Mac OSX 10.7.5

    I bought the printer M277 today. Im trying to download the drivers for my Mac. I downloaded the HP Easystart program. It goes to the point where its driver (v4.0.0.32, 148 mb) download. Then, he begins the dwnload but he cancels with the error "Pleas

  • shoot-syringe - KD scientific Legato 210

    Hello I have problems using my computer to connect and communicate with the 210 KDS Syringe Pump legato. I found this link of national instruments: http://sine.NI.com/apps/UTF8/niid_web_display.model_page?p_model_id=16884 but I failed to do the commu

  • M251NW: windows 10

    How much of time is an application or a driver going to be available for Windows 10 for my laserprinter M251NW? My just desktop PC has been improved and it does not find the printer. It's connected network so HP assistant cannot find either.