How to get the difference of two dates in months

Dear friends,

I have 4 items on my page.

2 entered message text (value of loan, monthly deduction)

2 are message style fields (start date, end date)

I need to get the difference from above 2 dates in no.. of months. (for example say N)

So with N, loanvalue should be divided and populated as monthly deduction.

I tried this way, but not able to get the difference of dates

{if ("populateMonthlyDeduction". Equals (PageContext.GetParameter (EVENT_PARAM)))}

System.out.println ("enter populateMonthlyDeduction loop1");

String xxDeductionStartDate = vo.getCurrentRow ().getAttribute("DeducStartDt").toString ();

System.out.println ("xxDeductionStartDate is:" + xxDeductionStartDate);

TXN OADBTransaction = am.getOADBTransaction ();

java.sql.Date DeductionSDate = null;

java.sql.Date DeductionEDate = null;

if(xxDeductionStartDate!=null)

{

java.sql.Date startDate = txn.getOANLSServices () .stringToDate (xxDeductionStartDate);

DeductionSDate = startDate;

System.out.println ("DeductionSDate is:" + DeductionSDate);

}

String xxDeductionEndDate = vo.getCurrentRow ().getAttribute("DedEndDt").toString ();

if(xxDeductionEndDate!=null)

{

java.sql.Date endDate = txn.getOANLSServices () .stringToDate (xxDeductionEndDate);

DeductionEDate = endDate;

System.out.println ("DeductionEDate is:" + DeductionEDate);

}

int difInDays = xxDeductionEndDate-xxDeductionStartDate; -Please correct me

How reach it .plz help.

Thank you

Aravinda

I used a custom like this method and calls this method daysBetween PFR.

I got it. Thanks to you all.

public int daysBetween(As Date, Date etDate)

{

return (int) ((etDate.getTime () - stDate.getTime (()) / (1000 * 60 * 60 * 24));

}

If ("populateMonthlyDeduction". Equals (PageContext.GetParameter (EVENT_PARAM)))

{

System.out.println ("enter populateMonthlyDeduction loop1");

String dedStDt = vo.getCurrentRow ().getAttribute("DeducStartDt").toString ();

String dedEndDt = vo.getCurrentRow ().getAttribute("DedEndDt").toString ();

If (! dedStDt.Equals (null) &! dedEndDt.equals (null))

{

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

Date sdate = new Date();

Date edate = new Date();

String sdate1 = null;

String edate1 = null;

try {}

sdate = dateFormat.parse (dedStDt);

EDATE = dateFormat.parse (dedEndDt);

SimpleDateFormat dateFormat1 = new SimpleDateFormat("dd-MMM-yyyy");

sdate1 = dateFormat1.format (sdate);

edate1 = dateFormat1.format (edate);

int days = daysBetween(sdate, edate);

int diffInMonths = days/30;

System.out.println ("days is:" + days);

System.out.println ("diffInMonths is:" + diffInMonths);

String sTotValueTuitionFees = vom.getCurrentRow ().getAttribute("TotValueTuitionFees").toString ();//pageContext.getParameter("LoanValue").toString();

int iTotValueTuitionFees = Integer.parseInt (sTotValueTuitionFees);

int iMonthlyDeduction = iTotValueTuitionFees/diffInMonths;

String sMonthlyDeduction = String.valueOf (iMonthlyDeduction);

System.out.println ("iMonthlyDeduction is:" + sMonthlyDeduction);

OAMessageStyledTextBean bMonthlyDeduction = (OAMessageStyledTextBean) webBean.findChildRecursive ("MonthlyDeduction");

bMonthlyDeduction.setValue (pageContext, sMonthlyDeduction);

}

catch (ParseException exception) e

{

}

}

}

Tags: Oracle Applications

Similar Questions

  • How to tell the difference between two dates

    Hello:

    I have a question on how to get the difference in quantities for two dates in the replies and dashboard.

    This is the scenario. I have two guests date and three columns. The first column must be the sum of the amounts for the first quick date. The second column should be the sum of the amounts for the second fast date. And the third column is the difference between the first two columns.

    Basically, I'm trying to do something similar to a function of sum of two lines but trying to get the difference between the two rows. Any help to solve this problem would be appreciated.

    Use the COLUMN FILTERS level...

    the first column with the first variable of date quick presentation of the filter

    Similarly, the second column in the second variable of quick overview of date filter

    Kind regards
    Rambeau

  • Dynamic action - Get the difference between two dates + times

    I have problems a little dynamic to work action. I'm trying to get the time between two dates with the time difference.

    Here is what I got (this is apex 4.0):

    Two date pickers + two numbers fields (date/start/end times)

    I created a dynamic action on the page who fires on the point lose focus (above points).

    The real action for the DA is the body of the PL/SQL function:
    declare
      end_date DATE;
      start_date DATE;
    Begin
      start_date := to_char(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MON-YYYY HH:MIAM');
      end_date := to_char(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MON-YYYY HH:MIAM');
      :P1_HOURS := end_date-start_date;
    End;
    When I change the values on the page, I get the following error:

    AJAX call back Server error ORA-06502: PL/SQL: digital or value error: character number conversion error to set the value.

    I'm guessing that there is a problem with the date formatting, but I can't make it work. Thanks in advance!

    Hi djston,

    because you chose the dynamic action of 'Set value' with the "Body of the PL/SQL function" type you need to return the value. Try the following code

    declare
      end_date DATE;
      start_date DATE;
    Begin
      start_date := to_date(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MM-YYYY HH:MIAM');
      end_date := to_date(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MM-YYYY HH:MIAM');
      RETURN (end_date-start_date)*24;
    End;
    

    and P1_REQUESTED_HOURS like 'item affected. "

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

    Published by: Patrick Wolf on January 17, 2011 10:54

  • How to find the difference between two dates in the presentation layer

    Hi gurus,

    Hello to everyone. Today, I came with the new requirement.


    I need to know the difference between a date and the current date in the formula column application presentation layer.by.



    Thank you and best regards,
    Prates

    Hi Navin,

    TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".

    If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...

    hope you understand...

    Award points and to close the debate, if your question is answered.

    See you soon,.
    Aravind

  • How to find the difference between two dates in time except Sunday

    Hi all

    I have a table, as shown below.
    SQL> select * from test;
    
    TR_ID                                              CREATE_TIME                                                                       CODE
    -------------------------------------------------- --------------------------------------------------------------------------- ----------
    S12341                                             05-JUN-12 12.20.52.403000 AM                                                      1003
    S12342                                             11-JUN-12 11.15.33.182000 AM                                                      1003
    S12342                                             07-JUN-12 12.00.36.573000 PM                                                      1002
    S12343                                             20-JUN-12 12.34.37.102000 AM                                                      1003
    S12343                                             15-JUN-12 11.34.27.141000 PM                                                      1002
    S12344                                             01-JUL-12 10.01.06.657000 PM                                                      1002
    S12344                                             06-JUL-12 12.01.04.188000 AM                                                      1003
    S12341                                             31-MAY-12 11.20.38.529000 PM                                                      1002
    I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.

    For example:

    TR_ID: S12344
    1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
    1003_Create_time: 12.01.04.188000 AM 6 July 12

    1002 create time is 22:00 Sunday.

    If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.

    I tried the sub query after doing a search on this forum but I am not getting the desired output.
    SELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and 
    ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) 
    from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d 
    WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
    Need help to get the desired o/p

    Hello

    If I unederstand the problem correctly, that's what you want:

    WITH       got_extrema     AS
    (
         SELECT       tr_id
         ,       CAST (MIN (create_time) AS DATE)     AS start_date
         ,       CAST (MAX (create_time) AS DATE)     AS end_date
         FROM       test
         GROUP BY  tr_id
    )
    SELECT       tr_id
    ,       start_date, end_date          -- If wanted
    ,       24 * ( ( ( TRUNC (end_date,   'IW')          -- Count -1 day for every full week
                        - TRUNC (start_date, 'IW')
                 )
               / -7
                  )
                + LEAST ( end_date               -- If end_date is a Sunday
                            , TRUNC (end_date, 'IW') + 6     -- consider it 00:00:00 on Sunday
                     )
                - CASE
                          WHEN  start_date >= TRUNC (start_date, 'IW') + 6     -- If start_date is a Sunday
                   THEN  TRUNC (start_date, 'IW') + 6               -- consider it 00:00:00 Sunday
                   ELSE  start_date
                      END
                )     AS total_hours
    FROM      got_extrema
    ;
    

    I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.

    Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
    (a) 1 day is deducted for each week between start_date and end_date
    (b) if End_date is a Sunday, none of the end_date himself hours are counted
    (c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.

    TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.

    Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • Find the difference between two date and time

    Hi friends,

    I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."

    select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed  
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate) 
    order by sql_step_num;

    You try to get the feel between two char strings.
    And more difference between two dates gives a NUMBER of days.
    Try this:

    select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed
    from eval.EVAL_RUNTIME_DETAILS
    where trunc(start_date) = trunc(sysdate)
    order by sql_step_num;
    
  • How to get the difference in dates in days

    Hi friends,

    How to get the date difference between two dates exactly

    date2-date1 days exactly... shouyld rounded to the nearest value of...

    and one entire display i mean positive integer
    Select round ((sysdate) - to_date (date_start)), date_start days of per_periods_of_service

    This gives negative also result

    Hello

    776317 wrote:
    Hi friends,

    How to get the date difference between two dates exactly

    date2-date1 days exactly... shouyld rounded to the nearest value of...

    Date1 - date2 is the exact number of days is after date2 date1. (It is as accurate as possible, given that the DATEs do not have fractions of a second).

    and one entire display i mean positive integer
    Select round ((sysdate) - to_date (date_start)), date_start days of per_periods_of_service

    You want to probably get the exact number of days first, then ROUND this number:

    SELECT  ROUND (SYSDATE - TO_DATE (date_start, ...))   AS days
    FROM    per_periods_of_service; 
    

    Always pass arguments at least 2 to TO_DATE:
    (1) the string to be converted, and
    (2) a saying string how (1) is formatted

    This gives negative also result

    Right; If date1 is before date2 then date1 - date2 returns a negative number.
    If you want to never get a negative value, use ABS (date2 - date1). If it returns 4, then you know that one of the DATEs was 4 days before the other, but you won't know who was earlier.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • The most elegant way to get the difference between two tables - not least!

    Hello


    Simplified example of what I'm trying to achieve - I have two tables ORIGINAL and REVISED.


    My aim is to compare the two, such as; -


    When there is data in the two tables I get the difference between the Budget column, and if there is no difference, so I don't want no lines.

    When data exists in the ORIGINAL, but not in review, I want to the inverse of the current value of the Budget column.

    Where the data exist in REVISED I want the REVISED value.

    I can see how I can do this, see below, but is there a more elegant solution?




    Data for the ORIGINAL table
    select '801040' entity, '2186' expense_type, 234000 budget
    from dual
    union all
    select '801040' entity, '3001' expense_type, 1000 budget
    from dual
    union all
    select '801040' entity, 'P132' expense_type, 34000 budget
    from dual
    union all
    select '801040' entity, 'P135' expense_type, 43000 budget
    from dual
    Data for the REVISED table
    select '801040' entity, '2186' expense_type, 235000 budget
    from dual
    union all
    select '801040' entity, 'P132' expense_type, 34000 budget
    from dual
    union all
    select '801040' entity, 'P139' expense_type, 56000 budget
    from dual
    Desired output



    ENTITY EXPENSE_TYPE DIFFERENCE
    ------ ------------ ----------
    801040 2186 1000
    801040 3001-1000
    801040 P135-43000
    801040 P139 56000

    5 selected lines.



    Code current to achieve this, is there a better way?
    select original.entity
    ,      original.expense_type
    ,       (nvl(revised.budget,0) - original.budget) as difference
    from   original
    ,      revised
    where  original.entity = revised.entity(+)
    and    original.expense_type = revised.expense_type(+)
    and   (nvl(revised.budget,0) - original.budget) != 0
    union all
    select  revised.entity
    ,       revised.expense_type
    ,       revised.budget as difference
    from   revised
    where  not exists
    (select 'x'
    from   original
    where  original.entity = revised.entity
    and    original.expense_type = revised.expense_type)
    and    revised.budget != 0
    Thanks a lot for your comments,.


    Robert.

    Published by: Robert Angel on January 17, 2012 03:31 to change is not equal to! = - Thanks for the heads up
    SQL> with original
      2  as
      3  (
      4    select '801040' entity, '2186' expense_type, 234000 budget
      5    from dual
      6    union all
      7    select '801040' entity, '3001' expense_type, 1000 budget
      8    from dual
      9    union all
     10    select '801040' entity, 'P132' expense_type, 34000 budget
     11    from dual
     12    union all
     13    select '801040' entity, 'P135' expense_type, 43000 budget
     14    from dual
     15  )
     16  , revised
     17  as
     18  (
     19    select '801040' entity, '2186' expense_type, 235000 budget
     20    from dual
     21    union all
     22    select '801040' entity, 'P132' expense_type, 34000 budget
     23    from dual
     24    union all
     25    select '801040' entity, 'P139' expense_type, 56000 budget
     26    from dual
     27  )
     28  select *
     29    from (
     30          select nvl(o.entity, r.entity) entity,
     31                 nvl(o.expense_type, r.expense_type) expense_type,
     32                 nvl(r.budget,0) - nvl(o.budget,0) budget
     33            from original o
     34            full join revised r
     35              on o.entity = r.entity
     36             and o.expense_type = r.expense_type
     37         )
     38   where budget <> 0
     39  /
    
    ENTITY EXPE     BUDGET
    ------ ---- ----------
    801040 2186       1000
    801040 P135     -43000
    801040 3001      -1000
    801040 P139      56000
    
    SQL>
    
  • How to get the multiple layers of data

    Hello

    I imported two jpg files into a single composition. Please follow this procedure...

    1 created a composition, say his name testCompo

    2 imported a file1.jpg in the file-> Import-> file draft

    3 imported a file2.jpg in the file-> Import-> file draft

    4. drag the two files, file1.jpg and file2.jpg, in the testCompo

    Now, I have two layers (it is file1.jpg and nested are file2.jpg) in my testCompo. How can I get the information in pixels or pixel data of the

    the two images (IE, I mean layers).

    I knew that params [0]-> u.ld is the first data layer in

    () EntryPointFunc
    PF_Cmd cmd,
    PF_InData * in_data,
    PF_OutData * out_data,.
    PF_ParamDef * params [],.
    PF_LayerDef * output,
    void * extra)

    So what about other data layer? Then, finally how can we get the multiple images/layers data in AE?

    Thanks in advance!

    It's the thing.

    You must have a param layer (let's say it's param number 3).

    Use this param to select any layer of the model.

    Now you checkout param 3.

    what you get is a paramDef structure containing the pixels of the layer 3 Advanced param to.

    you will find this information at:

    paramDef-> u.ld.data (or something close to that. I do not have in front of me)

    This way the jpg1 affect can get jpg2 pixels and jpg3. any layer in the comp.

  • How to calculate the difference between a Date column and the Date yesterday in the analysis (in the formula in the column)

    . For example, I need to calculate the difference between a date column, 'Table_Name '. "' Column_Name ' and (Current_Date-1). I tried different ways to do this. But nothing seems to work.

    Try the below formula.

    Replace "Time". "" Date "with your column.

    TIMESTAMPDIFF (SQL_TSI_DAY, "Time". "Date", TIMESTAMPADD (SQL_TSI_DAY-1, CURRENT_DATE))

    Thank you!

  • How to get the difference in Date in years, months and days

    Select Sysdate-Birth_date from Employees;
    the query returns the number of days between two dates
    I want to convert this number in years, months and days
    Can someone help me please

    Hoek wrote:
    Try:

    SQL> with t as (
    2  select to_date('01-01-1980', 'dd-mm-yyyy') birthdate
    3  ,      to_date('05-05-2010', 'dd-mm-yyyy') today
    4  from   dual
    5  )
    6  --
    7  --
    8  --
    9  select extract(year from today)-extract(year from birthdate) years
    10  ,      extract(month from today)-extract(month from birthdate) months
    11  ,      extract(day from today)-extract(day from birthdate) days
    12  from   t;
    
    YEARS     MONTHS       DAYS
    ---------- ---------- ----------
    30          4          4
    
    1 row selected.
    

    (May need some adjustments, possibly using the LARGEST, but currently not as long)

    Indeed, a few adjustments...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (
      2    select to_date('31-01-2009', 'dd-mm-yyyy') birthdate
      3    ,      to_date('28-02-2010', 'dd-mm-yyyy') today
      4    from   dual
      5    )
      6  --
      7  --
      8  --
      9  select extract(year from today)-extract(year from birthdate) years
     10  ,      extract(month from today)-extract(month from birthdate) months
     11  ,      extract(day from today)-extract(day from birthdate) days
     12* from   t
    SQL> /
    
         YEARS     MONTHS       DAYS
    ---------- ---------- ----------
             1          1         -3
    
    SQL>
    

    Maybe something like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('31-jan-2009','dd-mon-yyyy'), to_date('28-feb-2010','dd-mon-yyyy') from dual union all
      4             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      5             )
      6  -- end of test data
      7  select c_start_date, c_end_date
      8        ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
      9        ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
     10        ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
     11* from t
    SQL> /
    
    C_START_DATE        C_END_DATE                 YRS      MNTHS        DYS
    ------------------- ------------------- ---------- ---------- ----------
    17/11/2006 00:00:00 21/01/2008 00:00:00          1          2          4
    21/11/2006 00:00:00 17/02/2008 00:00:00          1          2         27
    31/01/2009 00:00:00 28/02/2010 00:00:00          1          1          0
    21/06/2006 00:00:00 17/07/2008 00:00:00          2          0         26
    
  • 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 get the required connection pool data source?

    Hi we have created two pools of connections with two different userid to restrict access to the database. now I have 2 pools. so if I want to get the connection to a specific pool how to do this?

    Use the JNDI string. When you created your pools you created the jndi names. So when connecting to the data source, you specify jndi. That's how.

    Your postal code if you have a problem.

  • How to calculate the difference between 2 dates, but with interruptions and stops between

    Hello

    How can I calculate the difference in minutes between 2 dates but taking into account the existence of a table in the Appendix, so if between start_date and end_date arguments, there is no 'work time' then this part of the time will not be included in the total difference.

    Records of the time table example:

    Time_configuration start_hour end_day end_hour
    219:00307:00
    319:00407:00

    so for example first record said that on Monday you start at 19:00 and leave the next day at 7:00 and then save the same sort of thing.

    There is an event that I want to track how many minutes lasted. for example, this event began the day 2 at 19:00 and ended the day 3 at 21:00

    Theoretically, this event really lasted: 840 minutes. This 840 minutes are within the limits of the annex.

    Thanks in advance.

    The storage of the dates not as data type DATE in most cases is bad design. In addition, how do you know what day of the date is 2 at 19:00? East - Monday 2 November 2015 or Monday, March 7, 2016? It is the same for the event. In any case, assuming that both calendar and events don't extend over several weeks:

    According to schedule)
    Select time_configuration 2, 19:00 ' start_hour, end_day 3,' 07:00 ' end_hour of all the double union
    Select 3, 19:00 ', 4,' 07:00 ' double
    ),
    event like)
    Select event_id 1, time_configuration 2, 19:00 ' start_hour, end_day 3: 21:00 ' end_hour of the double
    )
    Select e.event_id,
    Sum)
    less (e.end_day + to_date (e.end_hour, 'HH24'), s.end_day + to_date (s.end_hour, 'hh24:mi')).
    greater (e.start_day + to_date (e.start_hour, 'HH24'), s.start_day + to_date (s.start_hour,'hh24:mi'))))
    ) * 24 * 60 minutes
    Appendix s,
    e event
    where e.start_day + to_date(e.start_hour,'hh24:mi')< s.end_day="" +="">
    and e.end_day + to_date(e.end_hour,'hh24:mi') > s.start_day + to_date(s.start_hour,'hh24:mi')
    E.event_id group
    /

    EVENT_ID MINUTES
    ---------- ----------
    1 840

    SQL >

    SY.

  • How to get the difference of current and previous line for a column of the same table?

    Hello

    I have a table where there are 3 rows and say 2 columns only, as below

    Col1               | Col2
    --------------------- |----------------------------------------

    first_flag |  100

    second_flag |  104

    third_flag |  110

    Now, using sql, which accepts a parameter col1, how do I get the bottom o/p

    say that the entry is second_flag,

    output must be

    second_flag, 104, 4 (4 being the difference between 104 and 100)

    If I give the entry like third_flag, the output should be

    third_flag, 110, 6 (6 is the difference between 110 and 104)

    Any help?

    Hello

    Another way is to use the analytic LAG function:

    WITH got_diff AS

    (

    SELECT col1, col2

    , col2 - LAG (col2) over (ORDER BY col1) AS diff

    OF mydata

    )

    SELECT *.

    OF got_diff

    WHERE col1 =: flag_wanted

    ;

    This assumes that the lines are in alphabetical order by col1.  If the order is something else, then use it in the ORDER BY clause analytical.

Maybe you are looking for

  • For v.15 auto update on TUE and now I get hangs (freeze XP SP3 completely) every few hours. Help!

    Question says it all. I think I should get off until bugs in v.15 are developed. How do I do that?

  • Recovery utility Toshiba NB200 and HARD drive

    Hello worldI recently bought this netbook from toshiba and after installation of windows for the first time and restarting the machine it says that the password is incorrect, so I can't enter the system... It may be due to a particular keyboard layou

  • API ActiveX vs engine API

    Hello I want to develop an Interface with c# operator, but I don't know if I have to use the TestStand or motor TestStand API ActiveX API. In my opinion, the API ActiveX TestStand is more a sampler than the API of the engine, but the engine API is mo

  • Control of all the folders on my PC.

    I need full control over all the files in my PC.  I want to uninstall I-Tunes.  SPE "Apple Mobile Device Service.exe.

  • Autonomous AP 2600 security options

    Hello I can't seem to find a good document for SAP (standalone AP) security options to authenticate a coupling to layer2 and/or Layer 3 device. Can someone point me to one or give me a quick rundown on the best practice / this that the highest level