calculate the time in seconds, the day of the year and year

I have a data file where they record three columns, the seconds elapsed since midnight, day of the year and the year.  I am creating a timestamp of LabVIEW from these three numbers.  Of seconds elapsed since midnight, I can create seconds, minutes and hours.  If I feed in a cluster of time with the day of the year and the year, the timestamp of output is 0.  Does not work.  Although an input of the day of the year element, the Date and time with seconds function apparently requires day for months and months to work.

The only solution I can imagine at this stage is to calculate the month and the day of the day of the year, which would imply a choice of the month table and a check of the leap year.

Smart solutions, I'm missing?

DaveT

Dave,

I found a Julian Georgian so far.

Tags: NI Software

Similar Questions

  • How to calculate the year last month in obiee 11g?

    Hello

    I want to calculate the year last month in obiee 11g. I tried DB.

    -SELECT TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYYMMDD') FROM DUAL;

    Using the above query, year last month is -"08-01-2015"

    But I want to get the same result using timestampadd() in obiee 11g.

    Please help me,

    Thanks in advance,

    A.Kavya

    Hello

    TIMESTAMPADD (SQL_TSI_YEAR-1, CURRENT_DATE)

  • query to calculate the value and produce new lines

    QUARTER CUSTOMER PRODUCT RETAIL_SALES_AMT WHOLESALE_AMT

    01/01/2006 ABC VACUUM CLEANER 454234,00 65633456.00
    01/04/2006 ABC VACUUM CLEANER 324562,00 45333234.00
    01/07/2006 ABC VACUUM CLEANER 67845423.00 NULL
    01/10/2006 ABC VACUUM CLEANER 67453453.00 NULL
    01/01/2007 ABC VACUUM CLEANER 56754633.00 NULL
    01/04/2007 ABC VACUUM CLEANER 45423434.00 NULL


    Hi guys,.

    It's a situation where I have to produce a few new lines with projections based on Q4 RETAIL_SALES_AMT
    RETAIL_SALES_AMOUNT and fourth ' rs following WHOLESALE_AMT. As you can see from the sample data for a specific customer,
    product I have populated only until 01/04/2006 retail_sales_amt but WHOLE_SALE amt for the same product and customer
    are there up to 01/04/2007.

    I have to produce a PROJECTED RETAIL_SALES_AMT and it must be inserted in a new line with an indicator to identify
    a proposed line. Here, in this case I have to produce a new line of projection from 07/01/2006,10/01/2006 and 01/01/2007
    the RETAIL_SALES_AMT. The method of calculation is provided for in:

    retail_sales_amt scheduled for 07/01/2006=.345+ ((01/07/2006 whole_sales-01/04/2006 whole_sales) / (01/04/2006 whole_sale)))
    * 01/04/2006 RETAIL_SALES_AMT and move forward to subsequent quarters.

    Is it possible that I can use a query to produce these new lines by calculating the RETAIL_SALES_AMT on the fly, or any other
    How to procedure.

    Please help as it seems a little complicated.

    Concerning

    Published by: user626688 on October 27, 2009 11:26

    Published by: user626688 on October 27, 2009 11:26

    Published by: user626688 on October 27, 2009 11:27

    Published by: user626688 on October 27, 2009 11:28

    Published by: user626688 on October 27, 2009 11:31

    Published by: user626688 on October 27, 2009 11:32

    Hello

    As far as I can tell, that's what you asked for:

    WITH     got_prev         AS
    (
         SELECT     table_x.*
         ,     LAG (wholesale_amt) OVER ( PARTITION BY  customer
                                        ,                product
                                ORDER BY      quarter
                               )     AS prev_wholesale_amt
         FROM     table_x
    --     WHERE     ...     -- Any filtering goes here
    )
    ,     tree     AS
    (
         SELECT     got_prev.*
         ,     SYS_CONNECT_BY_PATH ( CASE
                               WHEN  LEVEL = 1
                               THEN  retail_sales_amt
                               ELSE  ( .345
                                              + wholesale_amt
                                              - prev_wholesale_amt
                                  ) / prev_wholesale_amt
                              END
                            , '*'
                            )                    AS path
         FROM     got_prev
         START WITH     retail_sales_amt     IS NOT NULL
         CONNECT BY     retail_sales_amt     IS NULL
              AND     quarter               = ADD_MONTHS (PRIOR quarter, 3)
              AND     customer          = PRIOR customer
              AND     product               = PRIOR product
    )
    SELECT       quarter
    ,       customer
    ,       product
    ,       COALESCE ( retail_sales_amt
                 , eval_number ( LTRIM ( path
                                           , '*'
                               )       )
                 )      AS retail_sales_amt
    ,       wholesale_amt
    ,       NVL2 ( retail_sales_amt
                , 'F'
                , 'T'
                )          AS projected_flag
    FROM       tree
    ORDER BY  customer
    ,            product
    ,       quarter
    ;
    

    I posted earlier the eval_number function.

    In this query, a group of consecutive quarters, where the first group a retail_sales_num and the rest of the members of the group are not, is treated as a hierarchy. The retail_sales_amt of all members (except the first) will be based on the previous, as well as the wholesale_amts past and present.
    Say that a tree is 5 points of time (as in your examples of data). We can calculate the 2nd point in several ways: using analytical functions, for example. But we cannot use the same formula to calculate the 3rd point, because the calculation of section 2 must be completed before we can calculate the 3rd. It goes the same for the 4th and 5th.
    This is CONNECT BY arrives. CONNECT BY is one thing in Oracle SQL that can be recursively; children may find themselves once their parents are found, in the same way we want to calculate the nth retail_sales_amt once the amount of the n-minus-1 has been calculated. To do this, we use SYS_CONNECT_BY_PATH, where the first element in the path is the retail_sales_amt given, and all others are the factor to multiply this number to get the next amount.
    SYS_CONNECT_BY_PATH produces a string like ' * 324562 *. 4965935 *-. 0057739', which should be interpreted as a number. TO_NUMBER won't: TO_NUMBER cannot convert only a single numeric literal. Instead, we have a function defined by the user who put this string dynamically in the SELECT clause of a query, where it is interpreted as a numeric expression.

  • With the mouse to draw the edges of a XY Chart to calculate the perimeter and area of him

    I have signals from a stabilometer... I traced X in terms of y in a XY Chart and I want to know how I can draw with the mouse a circle linking most of the points that is the graph of X on Y and calculate the area of her more perimeter. I joined my program labview with two files X and Y

    LV 2009 Version attached.

  • Calculate the start and end date in Connect By - during Hirerchy changes

    / * Formatted 05/20/2013 09:53 (PS5 v5.115.810.9015) * /.



    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    Hello, can you please help me or guide me in the calculation of the dates of beginning and end to the underside of logic

    I want to calculate the Hirerchy Manager to the Agent.
    Then under query works fine and its giving me the expected results
    But when there is a change in the Hirerchy Manager or manager gets promoted
    Then I need to calculate the start date and end date.
    CREATE TABLE PERSON_DTL
    (
      SID                 VARCHAR2(10 BYTE),
      EMP_MGRS_ID         VARCHAR2(10 BYTE),
      START_EFFECTIVE_DT  DATE,
      END_EFFECTIVE_DT    DATE
    );
    
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M100', 'M107', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M101', 'M102', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('A100', 'M100', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M100', 'M101', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M107', 'M102', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M102', 'M103', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M103', 'M104', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('A101', 'M105', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M105', 'M106', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
                 TRIM (
                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
                                     || ','
                                     || b.emp_mgrs_id
                 )
                    PATH,
                 START_EFFECTIVE_DT Start_dt,
                 END_EFFECTIVE_DT End_dt
          FROM   PERSON_DTL b
         WHERE   CONNECT_BY_ISLEAF = 1
    START WITH   sid IN ('A101', 'A100')
    CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
    This is the results that i am getting now.
    
    AGENT_SID    PATH                       START_DT    END_DT
    
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    12/31/9999
    A100    A100,M100,M107,M102,M103,M104    1/1/2010    12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999
    Results Required
    
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    5/18/2013
    A100    A100,M100,M107,M102,M103,M104    5/20/2013   12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999

    WITH the CLAUSE will make it readable

    SQL> with paths as
      2  (
      3        SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
      4                 TRIM (
      5                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
      6                                     || ','
      7                                     || b.emp_mgrs_id
      8                 )
      9                  PATH,
     10                 START_EFFECTIVE_DT Start_dt,
     11                 END_EFFECTIVE_DT End_dt,rownum rn
     12        FROM   PERSON_DTL b
     13        START WITH   sid IN ('A101', 'A100')
     14        CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
     15  ),
     16  flagged as
     17  (
     18      select agent_sid,
     19             path,
     20             start_dt,
     21             end_dt,rn,
     22             case when path like lag(path) over(order by rn)||'%' then 0 else 1 end flg
     23      from paths
     24  ),
     25  summed as
     26  (
     27      select agent_sid,path,start_dt,end_dt,
     28             sum(flg) over(order by rn) sm
     29      from flagged
     30  )
     31  select agent_sid,max(path) path,max(start_dt) start_dt,
     32         min(end_dt) end_dt
     33  from summed
     34  group by agent_sid,sm
     35  order by agent_sid;
    
    AGENT_SID  PATH                                     START_DT  END_DT
    ---------- ---------------------------------------- --------- ---------
    A100       A100,M100,M101,M102,M103,M104            01-JAN-10 18-MAY-13
    A100       A100,M100,M107,M102,M103,M104            20-MAY-13 31-DEC-99
    A101       A101,M105,M106                           01-JAN-10 31-DEC-99
    
  • Need help to calculate the start and end time and place the result in a term like text box

    I did a search on the forum for calculating start and end time and found the code depending on which I am using as a formcalc on the duration field.
    ==============================================================
    Form1. Page1.duration::calculate - (FormCalc, client)

    If (HasValue (StartTime) and HasValue (EndTime)) then
    industrial var = Time2Num (StartTime.formattedValue, "h: mm A")
    var = Time2Num out_ (EndTime.formattedValue, "h: mm A")
    If (IN2 > = out_) then
    xfa.host.messageBox ("start time cannot be greater than or equal to the end time.")
    $.rawValue = null
    on the other
    var out_ - IN2 = diff
    $.rawValue = diff/3600000
    endif
    on the other
    $.rawValue = null
    endif
    =============================================================

    Then, when I enter for example from 15:30, an hour of beginning and end of 04:00

    The duration field will say 0.5

    How can I get my form to say 30 minutes instead of placing a decimal?

    Secondly, how can I use field models LC where the employee can just type 330 or 03:30 and it automatically based on the computer's clock on time to start 15:30?

    Any help will be greatly appreciated.  Thank you.

    Attached is the form for display:

    https://Acrobat.com/#d=f1kxh5qjuow5ujyZduF8OQ

    To view the results in a regular time format, you can use:

    $.rawValue = Num2Time (diff/3600000, "HH: mm")

    For a flexible time entry check this example.

    http://thelivecycle.blogspot.com/2011/05/flexible-Eingabe-von-Daten-und-Zeiten.html

  • How to calculate the difference between two times by the NUMBERS

    I'm so bothered by the fact that I can't understand that.

    Cell B2 - 08:00

    Cell C2 - 10:50

    (How can cell D2 - I get this cell to calculate the difference and say 02:50?)

    I know it's probably one of the most basic operations, but for the life of me I can't understand it. The cells B2 and C2 are formatted for a 24-hour clock. But if I tell the system to just subtract the two, I get "0,118. Everything I find on the forum search goes beyond what I need. Can someone help me?

    Thank you

    Hi sapirs,

    Departure and arrival of the cells are in Date and time with Date format: no and time: 24-hour clock.

    Formula in D2 (fill down)

    = C2−B2

    The results become a duration format, but under automatic (numbers automatically worth this format)

    If you wish, you can change the cells of lasting results.

    What Data Format have your result cells?

    Kind regards

    Ian.

  • How to read the date of the day of the day of the year?

    I want to put 30 days for the test of endurance for the application of the components. the user will have the current value of 30 days with specify them the end of the day.

    I saw that the "seconds to Date/Time.vi" sure I checked the day of the year. If I can use this day of the year, I can add + 30 read 30 date.

    Barros,

    What I gave was the answer you were looking for originally because I believe.  You will not just be able to read the date in a coherent way and then add 30.  You can either use the function Get time in seconds or a few varaint it and then add the offset you want (you could use the get a Date/time string and enter the date directly, but this digital conversion which will be useful in the monitoring of the time elapsed will be much more difficult than what I provided only).  If you want to stop the test, simply to keep track of the amount of time the test is in pause and extension at the time where that amount.

    Cheers, Matt

  • Process of calculation to calculate the value after submit after all validations

    Hello

    Please help with a possible approach or suggestions for the calculation process.

    I have a calculation process after submit I want to calculate its value after that all validations are handled. Because this process of calculating trim is off of the first part of the input string of the user for the P3_USES element. Thus, for example consider; the user selects a value for P3_USES (point list manager) to be "TAC"... BCA... BCA... BCA... 0.CA BC... "CA IT BC. So my calculation process just stripes off the coast of the first portion of the string and computes the value will be "BCA"... BCA... BCA... 0.CA BC... "CA IT BC. It works fine when all postings on the page are placed without cooking.

    The problem occurs, then the validation fails on the form. Once the validation fails, the calculation process; already calculates the value and the P3_USES value form element is set to "BCA"... BCA... BCA... 0.CA BC... "CA IT BC. So, here the user solves the problem of validation and sends it again the form, but at this point the value is calculated again but this time that my string is "BCA"... BCA... BCA... 0.CA BC... CA IT BC"which is not correct, because my initial user string entry was"TAC"... BCA... BCA... BCA... 0.CA BC... "CA IT BC.

    So my question is how they treat the value of my calculation after all validations. While I can keep the original value of the P3_USES element. I'm using the version of Oracle APEX 4.0 and Oracle 10 g R2 database.

    Thank you

    Rambeau

    Hello

    Combine code of calculation and validation?

    Perform the calculations in the process?

    Use another element to contain the value 'real '?

    Kind regards

    Jari

  • I want you to help because the phone asking me to become a frequent and annoying enter a password to calculate the icloud

    Hello

    I want you to help because the phone ask me for becoming a frequent and annoying password to calculate the icloud, and I do not know because I bought a phone from someone else is not new Hama is on the phone (*) No. account. IMEI (*) Please help me soon thank you

    < post branched out by host >

    < personal information under the direction of the host >

    Robert Odamat says:

    Hello

    I want you to help because the phone ask me for becoming a frequent and annoying password to calculate the icloud, and I do not know because I bought a phone from someone else is not new Hama is on the phone (*) No. account. IMEI (*) Please help me soon thank you

    < post branched out by host >

    < personal information under the direction of the host >

    Find my iPhone Activation Lock - Apple Support

    There is nothing you can do to get around activation icloud blocking without recovering the former owners information.

    Communicate with the person that you bought the phone.

  • How to calculate the polynomial graphic adjustment of waveform

    Hi all

    I am new to lab - view so would need a little assistance in one of the problem I have right now.

    My problem is: how to calculate the polynomial graph of waveform data adjustment? I need to convert the waveform to XY graph data, and then use the polynomial vi made integrated to calculate the fitting?

    Detail: My problem is that I have waveform graph, I calculate the vertices and the Valley, but because of the noise, my peaks and Valley detection is sometimes not exact, so to smooth the chart that I must apply the polynomial fit.

    If anyone can help me in this, I'll be very grateful.

    Thanks in advance

    Hi Omar,.

    have you seen the suggestion of Lynn above?

    You already have the values of Y (your table). Now, you need build the table of X as indicated, only to replace the value of dt with your spacing from point to point. Somewhere in your code, you know that the value that you have an x-axis indicated in milliseconds...

  • JavaScript to calculate the average of a column

    I have my PDF file I'm trying to calculate the average in a column of fields.

    My problem is that there are 7 areas, but all 7 can be omitted, so I think I need some sort of statement 'if' that would only count the number of fields containing values.  Then, somehow working in the rest of my calculation...

    That's what I have so far...

    (function () {}

    Get all the field values, as numbers
    var v1 = + getField("column.0").value;
    var v2 = + getField("column.1").value;

    var v3 = + getField("column.2").value;

    var v4 = + getField("column.3").value;

    V5 var = + getField("column.4").value;

    var V6 = + getField("column.5").value;

    v7 var = + getField("column.6").value;

    var V8 = + getField("column.7").value;

    Calculate the result and the value of this field
    Event.Value = (v1 + v2 + v3 + v4 + v5 + v6 + v7) / the number of fields that have been filled;

    })();

    I'm pretty new to javascript. Any help would be greatly appreciated! Thank you

    First of all, I woul write this function withou field reference to make it more universal, and then I have a funcion of document level so it could be used more than once in a PDF document and easily put into another PDF file.

    function Avg() {}
    average computer of the last non-empty field names
    var sum = 0; sum of the fields
    var number = 0; meter for non-empty fields
    for (i = 0; i< arguments.length;="" i++)="">
    iField var = arguments [i]; get the element of arguments passed
    var fField = this.getField(arguments[i]).value;
    If (!) isNaN (fField)))) {}
    field is a number
    If (fField.ToString ()! = ") {}
    field is not null or empty
    sum += Number (fField); Add to the sum
    Count ++; County of increment
    } / / do not blank end
    } / / end of number
    } / / end of loop iterative arguments
    If (count! = 0) {}
    calculate the average if there is one or more items on average
    to return the sum / count; Returns the average
    } else {}
    return ";
    } / / no end no average calculated
    } / / end of function Avg

    Your custom calculation script would then become:

    Event.Value = Avg ("column. 0', 'column.1', 'column.2', 'column.3', 'column.4', 'column.5', 'column.6', 'column.7');

  • bug using the list and treeset

    I have a problem in the real world where I get a list of the retail store and get the distance of the starting places group and a location closest to you find the 10 for each starting locations. I'm back from getdata a list of stores loop in each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset that the original game is replaced with a duplicate of the second set. a very simple test for this case is:
    package treeset;
    
    import java.util.Comparator;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.TreeSet;
    
    import java.io.Serializable;
    
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class TreeSetExample
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    /**
     * The TreeSetExample demonstreates a odity in the sorting of list using a treeset
     *
     * @version 1.0, 04/06/2011
     * @author  Douglas Nelson
     * @author  copyright Oracle 2011
     * @author  Unauthorized use, duplication or modification is strictly prohibited.
     */
    public class TreeSetExample extends Object {
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start constructor
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    /**
     * Constructs a TreeSetExample object
     */
    public TreeSetExample() {
    
    } // end constructor
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start getData
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    /**
     * getDatea
     */
    public List<SimpleVO> getData() {
    
       List<SimpleVO> returnList = new LinkedList<SimpleVO>();
    
       SimpleVO simpleVO = null;
    
       for (int i = 0;i < 5;i++) {
    
          returnList.add(new SimpleVO());
    
       } // end for
    
       return(returnList);
    
    } // end getData
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start runTest
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    /**
     * runTest - Test the insert sorting of a tree set with a list of data
     * @param loopCount number of time to load data into the saveset
     */
    public void runTest(int loopCount) {
    
       List<SimpleVO>    simpleList   = getData();
       SimpleVO          simpleVO     = null;
       TreeSet<SimpleVO> saveSet      = new TreeSet<SimpleVO>(new simpleComparator());
       SimpleVO          tempSimpleVO = null;
    
       Iterator<SimpleVO> iterator      = null;
       Iterator<SimpleVO> printIterator = null;
    
       int id = 0;
    
       for (int i = 0; i < loopCount;i++) {
    
          iterator = simpleList.iterator();
    
       //--------------------------------------------------------------
       // for each of the user's zip codes find the distance to the RSL
       //--------------------------------------------------------------
       while (iterator.hasNext()) {
    
          simpleVO = iterator.next();
    
          id ++;
    
          simpleVO.setName("" + id);
    
          saveSet.add(simpleVO);
    
       } // end while
    
       //--------------------------------------
       // print saveset at the end of each load
       //--------------------------------------
       System.out.println("list count after loop [" + (i + 1) + "] number of elements = [" + saveSet.size() + "] contents:");
    
       printIterator = saveSet.iterator();
    
       while(printIterator.hasNext()) {
    
          tempSimpleVO = printIterator.next();
    
          System.out.println(" save simpleVO name = [" + tempSimpleVO.getName() + "]");
    
       } // end while
    
       } // end For
    
    } // end runTest
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start main
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    /**
     * IbotMailParser main thread
     * @param arg standard main input string array.
     */
    public static void main(String[] arg) {
    
       System.out.println("Main - Started");
    
       try {
    
          System.out.println("*************** starting test 1 *********************");
    
          TreeSetExample treeSetExample = new TreeSetExample();
    
          treeSetExample.runTest(1);
    
          System.out.println("\n");
          System.out.println("\n");
          System.out.println("*************** starting test 2 *********************");
    
          treeSetExample.runTest(2);
    
       } // end try
       catch (Exception any) {
    
          System.out.println("Exception [" + any.getMessage() + "]");
    
       } // end catch
    
       System.out.println("Main - we gone bye-bye...!");
    
    } // end main
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class SimpleVO
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    /**
     * The SimpleVO is a value object pattern used for this example
     *
     * @version 1.0, 04/06/2011
     * @author  Douglas Nelson
     * @author  copyright Oracle 2011
     * @author  Unauthorized use, duplication or modification is strictly prohibited.
     */
    public class SimpleVO extends Object {
       /**
        * Default user name for Oracle connection.
        */
       private String name = "";
    
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       /**
        * Returns the name value associated with this attribute
        *
        * @return String - the Name parameter
        */
       public String getName() {
    
          return(name);
    
       } // end getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start setName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       /**
        * Sets the name value for this attribute
        *
        * @param newName the Name to be set
        */
       public void setName(String newName) {
    
          if (newName != null) {
    
             name = newName.trim();
    
          } // end if
    
       } // end setName
    
    } // end SimpleVO
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class simpleComparator
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    /**
     * The SimpleComparator is a comparator object used for sorting simple value objects
     *
     * @version 1.0, 04/06/2011
     * @author  Douglas Nelson
     * @author  copyright Oracle 2011
     * @author  Unauthorized use, duplication or modification is strictly prohibited.
     */
    public class simpleComparator implements Comparator<SimpleVO>, Serializable {
    
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       /**
        * Returns the name value associated with this attribute
        *
        * @return String - the Name parameter
        */
       public int compare(SimpleVO simpleVO_1, SimpleVO simpleVO_2) {
    
          return(1);
    
       } // end compare
    
    } // end SimpleComparator
    
    } // end class TreeSetExample
    output:

    c:\treeset > java treeset. TreeSetExample
    Hand - started
    from test 1 *.
    County from the list after several loop [1] items = [5] content:
    you save simpleVO name = [1]
    you save simpleVO name = [2]
    you save simpleVO name = [3]
    you save simpleVO name = [4]
    you save simpleVO name = [5]

    from test 2 *.
    County from the list after several loop [1] items = [5] content:
    you save simpleVO name = [1]
    you save simpleVO name = [2]
    you save simpleVO name = [3]
    you save simpleVO name = [4]
    you save simpleVO name = [5]
    County from the list after several items loop [2] content = [10]:
    you save simpleVO name = [6]
    you save simpleVO name = [7]
    you save simpleVO name = [8]
    you save simpleVO name = [9]
    you save simpleVO name = [10]
    you save simpleVO name = [6]
    you save simpleVO name = [7]
    you save simpleVO name = [8]
    you save simpleVO name = [9]
    you save simpleVO name = [10]
    Hand - we go... Bye Bye!

    Published by: EJP 07/04/2011 10:44: Add code tags. Please use them.

    Here, I added a string comparison. TreeSet stil works.

    package scratch;
    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.LinkedHashSet;
    import java.util.List;
    import java.util.Set;
    import java.util.TreeSet;
    
    public class TreeSetWorks {
      public static void main (String[] args) throws Exception {
    
        List list = new ArrayList ();
        Set insertionOrderSet = new LinkedHashSet ();
        Set comparator1OrderedSet = new TreeSet (new SimpleVOComparator1 ());
        Set comparator2OrderedSet = new TreeSet (new SimpleVOComparator2 ());
    
        for (int i = 5; i <= 15; i++) {
          SimpleVO vo = new SimpleVO();
          vo.id = i;
          vo.name = "VO-" + i;
          list.add(vo);
        }
    
        System.out.println ("preshuffle list : " + list);
        Collections.shuffle (list);
        System.out.println ("postshuffle list : " + list);
    
        System.out.println ();
    
        for (SimpleVO vo : list) {
          insertionOrderSet.add (vo);
          System.out.println ("addded " + vo + " to insertionOrderSet : " + insertionOrderSet);
    
          comparator1OrderedSet.add (vo);
          System.out.println ("addded " + vo + " to comparator1OrderedSet : " + comparator1OrderedSet);
    
          comparator2OrderedSet.add (vo);
          System.out.println ("addded " + vo + " to comparator2OrderedSet : " + comparator2OrderedSet);
    
          System.out.println ();
        }
    
        System.out.println ("list                  : " + list);
        System.out.println ("insertionOrderSet     : " + insertionOrderSet);
        System.out.println ("comparator1OrderedSet : " + comparator1OrderedSet);
        System.out.println ("comparator2OrderedSet : " + comparator2OrderedSet);
      }
    }
    
    class SimpleVO {
      int id;
      String name;
    
      public String toString() {
        return name;
      }
    }
    
    class SimpleVOComparator1 implements Comparator {
      public int compare(SimpleVO vo1, SimpleVO vo2) {
        return
          vo1.id < vo2.id ? -1 :
          vo1.id > vo2.id ? 1 :
          0;
      }
    }
    
    class SimpleVOComparator2 implements Comparator {
      public int compare(SimpleVO vo1, SimpleVO vo2) {
        return vo1.name.compareTo (vo2.name);
      }
    }
    
    list                  : [VO-6, VO-5, VO-14, VO-7, VO-8, VO-11, VO-12, VO-15, VO-9, VO-10, VO-13]
    insertionOrderSet     : [VO-6, VO-5, VO-14, VO-7, VO-8, VO-11, VO-12, VO-15, VO-9, VO-10, VO-13]
    comparator1OrderedSet : [VO-5, VO-6, VO-7, VO-8, VO-9, VO-10, VO-11, VO-12, VO-13, VO-14, VO-15]
    comparator2OrderedSet : [VO-10, VO-11, VO-12, VO-13, VO-14, VO-15, VO-5, VO-6, VO-7, VO-8, VO-9]
    
  • Get the length and width of a rectangle

    I use sdo_sam.tiiled_bins in rectangles of bursting into different sections. I need to divide the rectangle along the x axis depending on if there is longer or wider. I checked the documentation and I couldn't find a way to get the length and width of a rectangle encompassing minimum. Is there any built-in feature to get the length and width of a rectangle or do I have to create my own? Database is 11 GR 2.

    Thank you
    Rob

    Rob,

    You can use SDO_GEOM. SDO_MIN_MBR_ORDINATE and SDO_GEOM. SDO_MAX_MBR_ORDINATE to calculate the length and width of a mbr.

    References:

    [SDO_GEOM. SDO_MIN_MBR_ORDINATE | http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11830/sdo_objgeom.htm#i866250]

    [SDO_GEOM. SDO_MAX_MBR_ORDINATE | http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11830/sdo_objgeom.htm#i866249]

    Kind regards
    Noel

  • How can I change this request, so I can display the name and partitions in a r

    How can I change this request, so I can add the ID of the table SPRIDEN
    from now on gives me what I want:
     
    1,543     A05     24     A01     24     BAC     24     BAE     24     A02     20     BAM     20
    in a single line, but I would like to add the id and the name that is stored in the SPRIDEN table

     
    SELECT sortest_pidm,
           max(decode(rn,1,sortest_tesc_code)) tesc_code1,
           max(decode(rn,1,score)) score1,
           max(decode(rn,2,sortest_tesc_code)) tesc_code2,
           max(decode(rn,2,score)) score2,
           max(decode(rn,3,sortest_tesc_code)) tesc_code3,
           max(decode(rn,3,score))  score3,
           max(decode(rn,4,sortest_tesc_code)) tesc_code4,
           max(decode(rn,4,score))  score4,
           max(decode(rn,5,sortest_tesc_code)) tesc_code5,
           max(decode(rn,5,score))  score5,
           max(decode(rn,6,sortest_tesc_code)) tesc_code6,
           max(decode(rn,6,score))  score6         
      FROM (select sortest_pidm,
                   sortest_tesc_code,
                   score, 
                  row_number() over (partition by sortest_pidm order by score desc) rn
              FROM (select sortest_pidm,
                           sortest_tesc_code,
                           max(sortest_test_score) score
                      from sortest,SPRIDEN
                      where 
                      SPRIDEN_pidm =SORTEST_PIDM
                    AND   sortest_tesc_code in ('A01','BAE','A02','BAM','A05','BAC')
                     and  sortest_pidm is not null  
                    GROUP BY sortest_pidm, sortest_tesc_code))
                    GROUP BY sortest_pidm;
                    

    Hello

    That depends on whether spriden_pidm is unique, and you want to get the results.

    Whenever you have a problem, post a small example of data (CREATE TABLE and INSERT, relevamnt columns only instructions) for all the tables and the results desired from these data.
    If you can illustrate your problem using tables commonly available (such as in the diagrams of scott or HR) so you need not display the sample data; right after the results you want.
    Whatever it is, explain how you get these results from these data.
    Always tell what version of Oracle you are using.

    Looks like you are doing something similar to the following.
    Using the tables emp and dept of the scott schema, producing a line of production by Department showing the highest salary for each job, for a set given jobs:

    DEPTNO DNAME          LOC           JOB_1   SAL_1 JOB_2   SAL_2 JOB_3   SAL_3
    ------ -------------- ------------- ------- ----- ------- ----- ------- -----
        20 RESEARCH       DALLAS        ANALYST  3000 MANAGER  2975 CLERK    1100
        10 ACCOUNTING     NEW YORK      MANAGER  2450 CLERK    1300
        30 SALES          CHICAGO       MANAGER  2850 CLERK     950
    

    On each line, jobs are listed in order by the highest salary.
    This seems to be similar to what you are doing. The roles played by the sortest_pidm, sortest_tesc_code and sortest_test_score in your table sortest are played by deptno, job and sal in the emp table. The roles played by the spriden_pidm, id and the name of your table spriden are played by deptno, dname and loc in the dept table.

    Looks like you already have something like the query below, which produces a correct output, except that it does not include the dname and loc of the dept table columns.

    SELECT    deptno
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
               SELECT    deptno
               ,          job
               ,          max_sal
               ,          ROW_NUMBER () OVER ( PARTITION BY  deptno
                                              ORDER BY          max_sal     DESC
                                )         AS rn
               FROM     (
                             SELECT    e.deptno
                       ,           e.job
                       ,           MAX (e.sal)     AS max_sal
                       FROM      scott.emp        e
                       ,           scott.dept   d
                       WHERE     e.deptno        = d.deptno
                       AND           e.job        IN ('ANALYST', 'CLERK', 'MANAGER')
                       GROUP BY  e.deptno
                       ,           e.job
                         )
           )
    GROUP BY  deptno
    ;
    

    Dept.DeptNo is unique, it won't be a dname and a loc for each deptno, so we can modify the query by replacing "deptno" with "deptno, dname, loc" throughout the query (except in the join condition, of course):

    SELECT    deptno, dname, loc                    -- Changed
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
               SELECT    deptno, dname, loc          -- Changed
               ,          job
               ,          max_sal
               ,          ROW_NUMBER () OVER ( PARTITION BY  deptno      -- , dname, loc     -- Changed
                                              ORDER BY          max_sal      DESC
                                )         AS rn
               FROM     (
                             SELECT    e.deptno, d.dname, d.loc                    -- Changed
                       ,           e.job
                       ,           MAX (e.sal)     AS max_sal
                       FROM      scott.emp        e
                       ,           scott.dept   d
                       WHERE     e.deptno        = d.deptno
                       AND           e.job        IN ('ANALYST', 'CLERK', 'MANAGER')
                       GROUP BY  e.deptno, d.dname, d.loc                    -- Changed
                       ,           e.job
                         )
           )
    GROUP BY  deptno, dname, loc                    -- Changed
    ;
    

    In fact, you can continue to use just deptno in the analytical PARTITION BY clause. It may be slightly more efficient to just use deptno, as I did above, but it won't change the results if you use all 3, if there is only 1 danme and 1 loc by deptno.

    Moreover, you don't need so many subqueries. You use the internal subquery to calculate the MAX and the outer subquery to calculate rn. Analytical functions are calculated after global fucntions so you can do both in the same auxiliary request like this:

    SELECT    deptno, dname, loc
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
                   SELECT    e.deptno, d.dname, d.loc
              ,       e.job
              ,       MAX (e.sal)     AS max_sal
              ,       ROW_NUMBER () OVER ( PARTITION BY  e.deptno
                                           ORDER BY       MAX (sal)     DESC
                                          )       AS rn
              FROM      scott.emp    e
              ,       scott.dept   d
              WHERE     e.deptno        = d.deptno
              AND       e.job                IN ('ANALYST', 'CLERK', 'MANAGER')
                  GROUP BY  e.deptno, d.dname, d.loc
              ,       e.job
           )
    GROUP BY  deptno, dname, loc
    ;
    

    It will work in Oracle 8.1 or more. In Oracle 11, however, it is better to use the SELECT... Function PIVOT.

Maybe you are looking for

  • Calendar not in SYNC'ed after iOS MacOS update

    My calendar don't Sync today, one day after the iOs and Mac OS has been updated. I added 4 events on iPhone but only appear on my iMac. I added 1 event on iMac, but does not appear on the iPhone. I deleted an event repeated on iPad but it still appea

  • find the version of the document of the last week

    I converted a file of pages to a doc.x I never downloaded from MS word. I'm new to mac. I used Finder and downloaded data recovery software that says I need to open in the application folder. I did not have the opportunity to browse any version or re

  • EX6100 thin antenna and positioning

    Can someone tell me if the two antennas on the EX6100 are for specific purposes, such as 2.4 GHz vs 5 GHz, or router communication vs. communication device? It would help to position the antennas as well as the device itself.

  • HELP: Report by generic e-mail or filter?

    I know I created this before somewhere in Eloqua in case of filter or reports, but I'll try to find out all the @Domains in our contacts.So, for example, it would be lists:Percentage of the number of name fields@Gmail 100 30%@Yahoo 20 5%Anyone know w

  • upgrading to creative cloud

    I bought the Adobe Creative Suite Design Premium a few years ago and I was wondering if it is possible to upgrade to creative cloud?