Tektronix DPO2024 function average

Dear Sir/Madam:

I would like to use the average function in Tektronix DPO2024 to digitize the signal through Labview.

The error appeared when I used the average function. Please see the attachment.

Anyone got the same problem before?

Willy0120 wrote:

Hi, Ben:

I have difficulty outside. Thanks for your information.

You then mark the post helped you in the accepted solution. You should also put the updated the vi that works, it might help others with a similar problem to find a solution.

Ben64

Tags: NI Software

Similar Questions

  • Function average in HFM return error

    Hello

    I wrote the following script in HFM calculate ordinary for the calculation of averages. But it gives me an error.
    Someone has used this function and may report the error in this please?


    VOID SUBSaVG

    GSA EXP ' a = #AverageSales "& medium ('a #Sales', '3')".

    END SUB

    As far as I know (always on HFM 4.X!), HFM is not a predefined function of average. You will need to define a new function in your rules as shown below. I received this support earlier. The settings are a bit different than what you have in your example, so you may need to change. Is the '3' in your example the number of the period?

    Function Average (strPOV, strFreq)

    DIM nPERIOD
    DIM strCUM
    I have SUN

    If strFreq = "PERIODICAL" Then
    If HS. PERIOD. ISFIRST = TRUE Then
    nPERIOD = 1
    On the other
    nPERIOD = 2
    End If
    Else if strFreq = "CDA" Then
    HS = nPERIOD. PERIOD. NUMBER()

    On the other
    EXIT FUNCTION 'nothing to see -
    End If

    For i = 0 To nPERIOD-1
    If I = 0 Then
    "strCUM = strPOV &". W #PERIODIC ".
    On the other
    "strCUM = strCUM & '+' & strPOV & '. W #PERIODIC. P #CUR-'& I '.
    End If
    Next

    Average = "(("& strCUM &") /" & nPERIOD & ")".

    End Function

  • VI data on average compared to the data from the Excel file on average .lvm

    I am trying to build a .VI to measure voltages on a channel of a transducer of pressure for a period of 3 minutes.  I would like the .VI to write all the samples of blood to a file .lvm with another .lvm file that comes from the average voltage over the period of 3 minutes.  I built a .VI making everything above so I think that... The problem I'm running into is when I opened the file .lvm of all samples of blood in MS Excel and take the average of them using the built-in Excel function (= AVERAGE(B23:B5022) for example) averaged and compare it to the .lvm file, which has just 3 minute average .VI voltage, they do not correspond to the top.

    This makes me wonder if I use VI with an average of function correctly or if maybe VI averages data different voltage than what is written in the .lvm file.

    Does anyone know why the two averages are different and how I can match.

    I have attached a picture of my functional schema with the file .VI for clarity.

    The Type of dynamic data of LabVIEW you use is a special data type that can take many forms.  It therefore requires the use "Of DDT" and "DDT" for the conbert to and from other data types.  These special conversion functions can be configured by double-clicking them and specifying the format you are converting from.  You can find the functions on the pallet handling Express-Signal.

    I've attached a screenshot of the modification of the code using the "DDT" and the average is very good.

    Please mark this as accepted such solution and/or give Kudos if it works for you.  We appreciate the sides for our answers.

    Thank you

    Dan

  • How to call the function cascade BlackBerry

    I begineer in blackberry c ++.

    I do two class is testobject and second in test .i call the onther text function average () and nexttext();

    so please how to call this function.

    // Default empty project template
    #include "TestObect.hpp"
    
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    TestObect::TestObect(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        // set created root object as a scene
        app->setScene(root);
    }
    
    void TestObect::test(){
    
        qDebug()<< "****************Naveen";
    }
    

    I insert also declared in the header file.

    Q_INVOKABLE Sub test();

    then I create another test class.

    /*
     * test.cpp
     *
     *  Created on: Apr 2, 2013
     *      Author: nksharma
     */
    
    #include "test.h"
    
    test::test() {
        // TODO Auto-generated constructor stub
    
    }
    
    void test:: nexttest(){
        qDebug()<<"***********Next test*********"
    
    }
    test::~test() {
        // TODO Auto-generated destructor stub
    }
    

    error in the file namespace,

    here in file herder

    the namespace error

    /*
     * test.h
     *
     *  Created on: Apr 2, 2013
     *      Author: nksharma
     */
    
    #ifndef TEST_H_
    #define TEST_H_
    
    class test {
    public:
        test();
        virtual ~test();
         Q_INVOKABLE void nexttest();
    };
    
    #endif /* TEST_H_ */
    

    You have a space between the colon and the n in:

    void test:: nexttest()
    

    Another thiing, if you are using Q_INVOKABLE, you must declare Q_OBJECT in your front header file public:

     


    If you're still having problems, try to clean up the project with Project > clean...

  • Average calcs

    I am trying to put in place some Calc for averages and can't seem to do things. I searched the forums and found this thread: Re: average function in HFM return error , but I have a few questions.

    When you configure these functions? Is that just as with the rest of my Calc scripts? What I have to put in place an average variable or any of the others?

    Can someone please give me some info in such a way that a novice administrator can understand this.

    The syntax I get, but I need help with where to find things and where to put them. I've read that the average was a rule system in HFM, but I don't know where to go to see these rules.

    Any help is greatly appreciated!
    Kristen

    There is a file call PDF HFM library functions for your version, it shows the script function, which you must copy and paste at the end of your rules.

    Here is the sample Script:
    Example Script
    ' Written in the routine of the sample statement
    Void calculate)
    Hs.Exp ' an AVG_SALES # = "& average ("#Sales "," 12").
    End Sub
    "the AVERAGE function programming
    FUNCTION Average (strPOV, strPERIOD)
    DIM nPERIOD
    DIM strCUM
    I have SUN
    strPOV = UCASE (strPOV)
    strPERIOD = UCASE (strPERIOD)
    IF strPERIOD = "PERIODICAL" THEN
    IF HS. PERIOD. ISFIRST = TRUE THEN
    nPERIOD = 1
    ON THE OTHER
    nPERIOD = 2
    END IF
    ELSE IF strPERIOD = "CDA" THEN
    HS = nPERIOD. PERIOD. NUMBER()
    ELSE IF CINT (strPERIOD) > 0 THEN
    nPERIOD = CINT (strPERIOD)
    ON THE OTHER
    EXIT FUNCTION
    END IF
    FOR i = 0 TO nPERIOD-1
    IF i = 0 THEN
    "strCUM = strPOV &". W #PERIODIC ".
    ON THE OTHER
    "strCUM = strCUM & '+' & strPOV & '. W #PERIODIC. P #CUR-'& I '.
    END IF
    NEXT
    "(Average =" (("& strCUM &") / "& nPERIOD &") ")".
    END FUNCTION

  • [8i] how to calculate a moving average?

    I am trying to calculate a moving average over a specific period of time, but I can't quite figure out how to do this. For this particular problem, I am also stuck on a 8i database.

    Some examples of data for the problem:
    CREATE TABLE     my_data
    (     order_no     CHAR(10)
    ,     seq_nbr          CHAR(4)
    ,     area_id          CHAR(4)
    ,     start_date     DATE
    ,     unit_time     NUMBER(7,2)
    );
    
    INSERT INTO my_data VALUES ('0000567890','0010','A001',TO_DATE('05/01/2000','mm/dd/yyyy'),0.34);
    INSERT INTO my_data VALUES ('0000567890','0020','A001',TO_DATE('05/02/2000','mm/dd/yyyy'),0.78);
    INSERT INTO my_data VALUES ('0000567890','0030','A002',TO_DATE('05/03/2000','mm/dd/yyyy'),0.91);
    INSERT INTO my_data VALUES ('0000567890','0040','A003',TO_DATE('05/03/2000','mm/dd/yyyy'),0.27);
    INSERT INTO my_data VALUES ('0000123456','0010','A001',TO_DATE('04/01/2001','mm/dd/yyyy'),0.39);
    INSERT INTO my_data VALUES ('0000123456','0020','A001',TO_DATE('04/02/2001','mm/dd/yyyy'),0.98);
    INSERT INTO my_data VALUES ('0000123456','0030','A002',TO_DATE('04/03/2001','mm/dd/yyyy'),0.77);
    INSERT INTO my_data VALUES ('0000123456','0040','A003',TO_DATE('04/03/2001','mm/dd/yyyy'),0.28);
    INSERT INTO my_data VALUES ('0000123123','0010','A001',TO_DATE('12/01/2001','mm/dd/yyyy'),0.31);
    INSERT INTO my_data VALUES ('0000123123','0020','A001',TO_DATE('12/02/2001','mm/dd/yyyy'),0.86);
    INSERT INTO my_data VALUES ('0000123123','0030','A002',TO_DATE('12/03/2001','mm/dd/yyyy'),0.82);
    INSERT INTO my_data VALUES ('0000123123','0040','A003',TO_DATE('12/03/2001','mm/dd/yyyy'),0.23);
    INSERT INTO my_data VALUES ('0000111111','0010','A001',TO_DATE('06/01/2002','mm/dd/yyyy'),0.29);
    INSERT INTO my_data VALUES ('0000111111','0020','A001',TO_DATE('06/02/2002','mm/dd/yyyy'),0.84);
    INSERT INTO my_data VALUES ('0000111111','0030','A002',TO_DATE('06/03/2002','mm/dd/yyyy'),0.78);
    INSERT INTO my_data VALUES ('0000111111','0040','A003',TO_DATE('06/03/2002','mm/dd/yyyy'),0.26);
    INSERT INTO my_data VALUES ('0000654321','0010','A001',TO_DATE('05/01/2003','mm/dd/yyyy'),0.28);
    INSERT INTO my_data VALUES ('0000654321','0020','A001',TO_DATE('05/02/2003','mm/dd/yyyy'),0.88);
    INSERT INTO my_data VALUES ('0000654321','0030','A002',TO_DATE('05/03/2003','mm/dd/yyyy'),0.75);
    INSERT INTO my_data VALUES ('0000654321','0040','A003',TO_DATE('05/03/2003','mm/dd/yyyy'),0.25);
    It is a sample of the actual data, which includes the lines around 50K, and is the result of a query, not a table. In addition, the actual data also have a reference number attached to each order, and the end result will be be partitioned by party id number and the region. This sample represents basically something, you might see a unique part number. In addition, these records at the time spacing is not predictable. You might have a single year that has 20 ordered, and another year (or years) that does not.

    Here is where I am now in the problem. For example, suppose I want to calculate a moving average over 2 years (average for the 2 years preceding the date of the current row). For my actual data, I probably want to be able to change the period of time (at different times in several queries) on which the moving average is calculated.

    I thought that using the analytical function AVERAGE with a window clause might be the way to go, but I don't know exactly how to use the window clause. I can even be completely wrong interpret what is its use, but if all goes well, it should still show what I'm after.
    SELECT     area_id
    ,     AVG(tot_area_unit_hrs)     
         OVER     (
              PARTITION BY     area_id
              ORDER BY     min_start
              ROWS          BETWEEN     --2 years prior to min_start of current row
                        AND     CURRENT ROW
              )
    ,     --something to indicate the time period the average is over     AS time_period
    FROM     (
         SELECT     order_no
         ,     area_id
         ,     MIN(start_date)     AS min_start
         ,     SUM(unit_time)     AS tot_area_unit_hrs
         FROM     my_data
         GROUP BY     order_no
         ,          area_id
         )
    ORDER BY     area_id
    ,          time_period
    As you can see from the above query, I want to calculate the sum of the unit_time for each order/area_id combo, then roll the way to this total time. (I'm the average total time that a product passes through each area_id per order).

    I want to see results like something along those lines... I really don't like how the time period is identified, as long as I can pay by him in chronological order, and he tells me what period of time it covers. The way I show with period_start and period_end in the results of the sample below is just a way that I thought to do this.
    area_id   period_start period_end   avg_unit_time   
    ----------------------------------------------------
    A001      4/30/1998    5/1/2000     1.120           
    A001      3/31/1999    4/1/2001     1.245           
    A001      11/30/1999   12/1/2001    1.220           
    A001      5/31/2000    6/1/2002     1.223           
    A001      4/30/2001    5/1/2003     1.153           
    A002      5/2/1998     5/3/2000     0.910            
    A002      4/2/1999     4/3/2001     0.840            
    A002      12/2/1999    12/3/2001    0.833            
    A002      6/2/2000     6/3/2002     0.790            
    A002      5/2/2001     5/3/2003     0.783            
    A003      5/2/1998     5/3/2000     0.270            
    A003      4/2/1999     4/3/2001     0.275            
    A003      12/2/1999    12/3/2001    0.260            
    A003      6/2/2000     6/3/2002     0.257            
    A003      5/2/2001     5/3/2003     0.247            
    Any suggestions?

    Hello

    You're close enough. You want a window based on the BEACH, no LINES.
    LINES BETWEEN... means that you know exactly how many lines will be in the window, and you don't care what range of values that represents.
    RANGE BETWEEN... means that you know the exact scope of the ORDER BY value to include in the window, which could mean any number of lines.

    When you say "RANGE BETWEEN x BEFORE...". "where the words ORDER BY id of a DATE, x is considered as the number of days. (Which is consistent with the arithmetic DATE Oracle).

    Try this:

    SELECT     area_id
    ,     min_start - 730          AS period_start
    ,     min_start             AS period_end
    ,     AVG(tot_area_unit_hrs)
         OVER     (
              PARTITION BY     area_id
              ORDER BY     min_start
              RANGE BETWEEN     365 * 2     PRECEDING
                    AND     CURRENT ROW
              )               AS avg_unit_time
    FROM     (
         SELECT     order_no
         ,     area_id
         ,     MIN(start_date)     AS min_start
         ,     SUM(unit_time)     AS tot_area_unit_hrs
         FROM     my_data
         GROUP BY     order_no
         ,          area_id
         )
    ORDER BY     area_id
    ,          period_end
    ;
    

    Output of your sample data:

    AREA PERIOD_STA PERIOD_END AVG_UNIT_TIME
    ---- ---------- ---------- -------------
    A001 5/2/1998   5/1/2000           1.120
    A001 4/2/1999   4/1/2001           1.245
    A001 12/2/1999  12/1/2001          1.220
    A001 6/1/2000   6/1/2002           1.223
    A001 5/1/2001   5/1/2003           1.153
    A002 5/4/1998   5/3/2000            .910
    A002 4/4/1999   4/3/2001            .840
    A002 12/4/1999  12/3/2001           .833
    A002 6/3/2000   6/3/2002            .790
    A002 5/3/2001   5/3/2003            .783
    A003 5/4/1998   5/3/2000            .270
    A003 4/4/1999   4/3/2001            .275
    A003 12/4/1999  12/3/2001           .260
    A003 6/3/2000   6/3/2002            .257
    A003 5/3/2001   5/3/2003            .247
    

    The period_starts are not quite what you posted, but, if I understand you correctly, you don't mind that.
    There should be no problem of partitioning an additional column.

  • the basis of my time scrolls not (in my blood pressure measurements)

    I have a DC 5v pot connected to my USB DAQ 6008. In labVIEW when I run it I get my voltage output as expected but the time base does not scroll it remains fixed. When I change the axis scales the output voltage varies even in the first second only. Does anyone know what is the problem?

    I don't think you can ignore the timestamp which is part of the dynamic data. I never use dynamic data and I hope that I am never placed in a situation where I have to.

    Eventually, a difficulty for the elevator VI is in the attachment. Since you have wired some scalar indicators data, TI EÉ seems not you care about 1000 samples so I used a function average to get a scalar value at least a certain meaninig. Then I converted to a real scalar.

    If you want to paste the dynamic data, you cannot use the function bundle in VI of the gear. The correct function would be the merge of the signals feature.

  • AVGHeadcount Calc

    Hi guys

    I have a requirement of funding to create some accounts average calc for lines of numbers that can be very simple, if all goes well...

    We have 1 parent: 999100 - Total of staff and 3 child accounts 999101 - Perm, 999102 - Temp, 999103 - Comms.

    The rules that I have tested are as follows:

    Void calculate)

    "Average actual accounts

    GSA EXP ' a = #AVGHCTOT "& medium ("a #999100","CDA")". "
    GSA EXP ' a = #AVGHCPERM "& medium ("a #999101","CDA")". "
    GSA EXP ' a = #AVGHCTEMP "& medium ("a #999102","CDA")". "
    GSA EXP ' a = #AVGHCCOMM "& medium ("a #999103","CDA")". "

    End Sub


    "the AVERAGE function programming

    FUNCTION Average (strPOV, strPERIOD)
    DIM nPERIOD
    DIM strCUM
    I have SUN
    strPOV = UCASE (strPOV)
    strPERIOD = UCASE (strPERIOD)
    IF strPERIOD = "PERIODICAL" THEN
    IF HS. PERIOD. ISFIRST = TRUE THEN
    nPERIOD = 1
    ON THE OTHER
    nPERIOD = 2
    END IF
    ELSE IF strPERIOD = "CDA" THEN
    HS = nPERIOD. PERIOD. NUMBER()
    ELSE IF CINT (strPERIOD) > 0 THEN
    nPERIOD = CINT (strPERIOD)
    ON THE OTHER
    EXIT FUNCTION
    END IF
    FOR i = 0 TO nPERIOD-1
    IF i = 0 THEN
    "strCUM = strPOV &". W #PERIODIC ".
    ON THE OTHER
    "strCUM = strCUM & '+' & strPOV & '. W #PERIODIC. P #CUR-"& I
    END IF
    NEXT
    "(Average =" (("& strCUM &") / "& nPERIOD &") ")".
    END FUNCTION

    My question is - should be in the routine of Sub Calc or dynamic void routine?

    The type of account of all of the above accounts is currently 'balance '.

    Another measure of this kind of type and they are balance or dynamic?

    Thanks in advance

    Juan

    Hi Juan,

    It is a common request and is usually managed by a Sub function calculate as you described (perhaps with another script of ways).

    If you are in version 11.1.2.3.5, you can also use the average rule (POV, periods). For more information, see page 336 of the hfm_admin.pdf.

    See you soon,.

    Thanos

    My answer has helped you? Please mark my answer as helpful/correct.

  • course of action

    Hello

    I did following steps

    step 1

    CREATE OR REPLACE TYPE  address_type as object
    (
      ad1      varchar2(50),
      ad2      varchar2(50),
      ad3      varchar2(50),
      city      varchar2(20),
      pin      varchar2(10)
    );
    

    step 2

    CREATE OR REPLACE TYPE  H_address is table of address_type;
    

    step 3

     create or replace function address_details
     (
     brcode in NUMBER,
     prd in varchar2)
     return sys_refcursor
     is
     x_cursor   sys_refcursor;
     vquery varchar2(4000);
     begin
     vquery:='SELECT ADDR1,ADDR2,addr3,citycd,pincd from d010054 where lbrcode='||brcode||' and prdacctid='||prd ||' and addrtype=1';
     open x_cursor for
     vquery;
     return x_cursor;
     IF (x_cursor%NOTFOUND) THEN
           vquery:='select add1,add2,add3,citycd,pincode from d009011 where custno='||t_cust(brcode,prd);
        open x_cursor for vquery;
     END IF;
     return x_cursor;
     end address_details;
    

    function is created without any errors

    step 4

    create or replace function address_pipe_function (i_cursor sys_refcursor)
       return h_address pipelined is
       vapxrec address_type:=address_type(null,null,null,null,null);
     begin
        loop
        fetch i_cursor into
        vapxrec.ad1,
        vapxrec.ad2,
        vapxrec.ad3,
        vapxrec.city,
        vapxrec.pin;
        exit when i_cursor%notfound;
        pipe row (vapxrec);
        end loop;
     close i_cursor;
     return;
     end;
    

    feature created without error

    then I tried the following

    SQL > select * from

    Table 2 (address_pipe_function (address_details (2, 'SB 000000000003055300000000')));

    Table (address_pipe_function (address_details (2, 'SB 000000000003055300000000')))

    *

    ERROR on line 2:

    ORA-00933: SQL not correctly completed command.

    ORA-06512: at "RECORD. ADDRESS_DETAILS', line 11

    I'm working on 11g

    Please guide

    HEMU wrote:

    Mr President

    It's for learning

    In fact, I wrote a function average monthly report giving fromdate, parameters to date, once again, it returns a single delimited string

    the problem is that I have to put the title of the column for the month are back through (fromdate, to date)

    That's why I'm creating a type based on inputdata dynamically, then the pupulate values for dérirez

    There may be a number of months from different years

    so the heads of column will be 'JAN_2013', feb_2013 and so on

    This forum will certainly helps me learn rather than copy the codes

    Thank you

    This is a misconception.

    When you start to dynamically create queries with dynamic column names, you start to need to dynamic code to process the results of the query, because you can not write static code you know not the names of columns... resulting in any of your code more dynamic... that is impassable, unperformant, and may contain bugs which will be not detectable at compile time not to mention the possibility of introducing questions sql injection.

    The only time you need to have column names from the data, is purposes, not for purposes of data processing.  Therefore, you must leave such column name up to reporting tools, which are specifically designed to query the data first, then layout of these data report and dynamically generate headings etc. as required.  Do not try and do it in SQL.

    Read this: 101 PL/SQL: cursors and Projection of SQL

  • Field containing average function works only when the data are engaged on the same page. Does not work for fields on other pages.

    I'm having a problem with a field defined to calculate the average of eleven points fields (points 1 to 8 on page 1-9-11 on page 2). My original question was that it could exclude fields of points when they do not have information entered and adjust the average calculation (number of "divided by") accordingly.

    I had someone write JavaScript code for him, but I just found a small problem I don't know if it's something in the code or what the person who originally wrote the script cannot understand it either and suggested that I have post here.

    The middle area (located on the 2nd page of the pdf page two) seems to work exclusively with precision if at least one of the points of the fields on the 2nd page, 9, 10 (and 11) are engaged with the data. No values entered on the first page and only the first page, are for some reason any dividing by a more than expected. For example, if I fill the boxes 1, 2 and 3, it divides the total by four. If I filled just box 7, it halves. If I fill all 8 boxes on the 1st page, it divides by nine. It is corrected as soon as I get the points in one or more of the three boxes on the 2nd page points, suddenly the overall average is accurate. But if boxes 9, 10 and 11 contain no points, then the average is still inaccurate because the number of ' divide by "he uses is one more than what it should. I can't understand how to attach the form to this post, so I downloaded on Dropbox: Dropbox - used Evaluation.pdf.

    Under the direction of State: javascript came work to exclude the empty boxes when the points are entered in one of the three points of fields on the 2nd page (and more), but the average function is not accurate because it adds 1 to the number of ' divide by "in the calculation of the average If the points are only entered into the fields on the 1st page.

    Here's the code I entered in the 'Custom calculation Script' box in the 'Calculate' tab of the Properties menu of Test field:

    Initialize variables

    var num = 0;

    var sum = 0;

    Browse the input fields

    for (var i = 1; i < 12; i ++) {}

    var f = getField ("points." + i);

    If {(f.valueAsString)

    increment the counter to non-empty field

    NUM ++;

    Add the value of the running total field

    sum += + f.value;

    }

    }

    Calculate the average

    If {(num)

    Event.Value = sum / num;

    } else {}

    All fields are empty, then the empty value

    Event.Value = "";

    }

    I do not see that. Add the code of script debugging will display the results that each field is completed:

    Initialize variables
    var num = 0;
    var sum = 0;

    Browse the input fields
    for (var i = 1; i)< 12;="" i++)="">
    var f = getField ("points." + i);
    If {(f.valueAsString)
    increment the counter to non-empty field
    NUM ++;
    Add the value of the running total field
    sum += + f.value;
    }
    }
    Debug - display results as the form is filled;
    Console.Show
    Console.println (sum + "/" + num + "=" + sum/num);
    end of debugging;
    Calculate the average
    If {(num)
    Event.Value = sum / num;
    } else {}
    All fields are empty, then the empty value
    Event.Value = "";
    }

  • Need for a function defined by the user in order to obtain a weighted average

    Hello

    We have a table where we want to device the weighted average for a column of prices below using formula,

    sum (quantity * price) / sum (qty)

    We have a few lines where part or all of the columns that is price or quantity can be NULL.

    We have tried to write the function as follows however, it fills even after 30 minutes, where as we have the addition of this feature request could was completed in 25 seconds.

    Please note that we are dealing with big data i.e. the table could have 50 million records. It has appropriate indexing and other components to improve performance required.

    We know that we did something wrong in the creation of feature below, but we are unable to resolve

    CREATE OR REPLACE FUNCTION "WEIGHTEDAVGPRICE" (PCOLNAME NUMBER( ) RETURN NUMBER

    IS

    TEMP NUMBER (26,13);

    BEGIN

    SELECT SUM (QUANTITY * PCOLNAME) / SUM (QUANTITY) IN TEMP DE FEES;

    RETURN TEMP;

    END WEIGHTEDAVGPRICE;


    Here, we send the parameter THAT PCOLNAME represents the name of the price column we want to do a weighted average.


    We know we could do this without adding a feature, but we need instructions BOX, and then in our SELECT clause. We use toplink to query the database, in this case, it will be difficult to covert.

    Also, we want this function to be used in other places as well.


    Thank you

    @Bhagyesh KNW



    The reason for the decrease in performance when you use the function, you call the function from a query and which is originally a context switch between SQL and PL/SQL engines.  That is known to slow down performance.  If you can only do the task in SQL, you must do so, in order to avoid context switching.

    It would be useful that you provided a few sample data and expected the output, as indicating the version of your database, so that people can understand and help you better.

    Please read:

    Re: 2. How can I ask a question in the forums?

  • Average Score function

    Hello.

    I have two things I have to do, but I don't know how. These problems happen in my EVALUATION_RESULTS table. The first thing I want to do is create a formula for the primary key EVALUATION_ID I need to do to make the EMPLOYEE_NUMBER followed by EMPLOYER_NUMBER followed by EVALUATION_ID. For example, if the employee being evaluated the number 10000, the employer has the number 1000, and the ID of the evaluation is 100, the number of assessment should be automatically 100001000100. How can I have this be created automatically after the user fills out a form?

    The second question is: I need to create a function in the EVALUATION_RESULTS table that takes an average of four partitions that are entered into the form. So it will (SCORE2 and SCORE3, SCORE1 + SCORE4) / 4. How can I implement this so that the user can enter the four notes, send the form, and the AVERAGE_SCORE is added to the table.

    Thanks in advance for the help.

    Published by: DanDan Sc on January 13, 2013 15:40

    Hi Dan,.

    Not the end-user database design leads a breath ;-)

    If you insist on doing things the hard way, here are several methods that you can use to do this, but they fall into two categories, to the application level IE Apex and at the database level. Usually, you will need to do both, to ensure the integrity of data as much as possible.

    At the level of the (Apex) application, you can create a page of calculation that is triggered on "Send" to complete/upgrade to update the mean field, or you could do dynamic action the mean field update every time that the partition fields are updated.

    At the database level, you can create a constraint that checks that the average field equals the average of the fields score, and you can create a trigger that updates the average field for inserts and updates.

    Overall, you will need so that you cover all the situations where the data can be inserted or updated to ensure that the average field is calculated.

    Another alternative is to use a virtual column, which is a column calculated, identified at the database level, but the value is not actually stored in the database, but it is calculated on the fly by the database. These were introduced in v11.2 (I think). I saw some posts in the forums of Apex on them and they apparently don't always behave in the Apex, but they merit to be studied.

    Hope this helps, even if only for you convince stored derivable values is a bad idea.

    Concerning
    André

  • 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.

  • Function numbers for dynamically on average over the last 30 cells

    I am a trader and I have several months of data. I currently have a percentage of the sum of all the victories and defeats by currency pair. I want to create a function that retrieves the last 30 cells of data and creates a percentage I can compare it to the percentage of total victory.

    The cells are empty, unless I have add data in either to the upper or lower row. 1 win and - 1 are losses. 0 means not configured.

    Here's a full month with 20 data cells (cells max per month are 22) of trading days:

    This is the current month:

    I have 16 months of data with percentages of victory for all my data. As you see, I also have winning monthly winning percentages easily in the examples above (with a small division). I really, really want to compile data from the last 30 cells with data to create a winning percentage. It would be necessary to sometimes include 3 different lines of different months of data to create 30 cells with a number inside.

    A friend used the COUNTIF command but I do not have it works for me.

    If there is a different website to request this detail of the question please share that too.

    Thanks in advance,

    B

    Hi Braddon,

    It would be a pretty easy task if the data to be summed up in two columns from a single table and had no gaps, but that doesn't seem to be the case.

    Screenshots of two isolated sets of cells containing two rows (railway of) the data to be summarized, but give no indication where these data will be found in the document does not provide sufficient information to start to find a solution.

    Where are the data stored? You say "data for each month." "Every month" is recorded on another table?... on a pair of rows of the same table different?

    In the image (very vague) I, the factors of complications will gather data from a subset of continually changing several tables on multiple sheets and which specific cell contains the 30 most recent reference and is the one to start the harvest.

    While a few details and clarifications.

    Kind regards

    Barry

  • What does '... argument ' average in the arguments of a function

    So can someone explain this?

    So far, I have seen no document on this subject. I don't know how to use it, but I would like to know what it means and.

    Things like these makes the flash/flex/as learning reylly hard when there is no documentation.

    If you define a function, you can add... .args as argument, which means that the function can receive an array of multiple arguments. This is useful if you don't know in advance of the arguments how your function will receive.

    An example:

    public void sum(...args):Number

    {

    var s:Number = 0;

    for each (var n: Number in args)

    {

    s += n;

    }

    return s;

    }

    See also: http://www.adobe.com/livedocs/flex/2/langref/statements.html#..._%28rest%29_parameter

    Dany

Maybe you are looking for