Row wise Date Difference

Hi
I have one column which contains Date field. and I want date difference between two rows like (1st row- 2nd row),(2st row- 3nd row) 3-4,4-5 like that.
How I can get this
Thanks
Siddhartha P

As for the minutes calculation it doesn't take Einstein to know that the number of minutes in a day = 24 (hours) * 60 (minutes)
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 1 as id, sysdate-10 as dt from dual union all
  2             select 2, sysdate-7.4 from dual union all
  3             select 3, sysdate-6.45 from dual union all
  4             select 4, sysdate-2.82 from dual union all
  5             select 5, sysdate from dual)
  6  -- END OF TEST DATA
  7  select id
  8        ,dt
  9        ,dt-lag(dt) over (order by id) as dt_diff_days
10        ,(dt-lag(dt) over (order by id))*(24*60) as dt_diff_minutes
11* from t
SQL> /
        ID DT                  DT_DIFF_DAYS DT_DIFF_MINUTES
         1 30/11/2007 13:07:37
         2 03/12/2007 03:31:37          2.6            3744
         3 04/12/2007 02:19:37          .95            1368
         4 07/12/2007 17:26:49         3.63          5227.2
         5 10/12/2007 13:07:37         2.82          4060.8
SQL>

Similar Messages

  • Row wise data insertion

    Hi,
    I have a query like this
    select
    wwv_flow_item.display_saveas(1,TXT,50,500) "Date"
    FROM
    WITH all_months AS
    SELECT ADD_MONTHS ( TRUNC ( TO_DATE ('1-JAN-09','dd-MON-YY')
    , 'MM'
    , LEVEL - 1
    )      AS dt
    , LEVEL      AS rn
    FROM dual
    CONNECT BY LEVEL <= MONTHS_BETWEEN ( TO_DATE ('1-APR-09', 'dd-Mon-YY')
    , TO_DATE ('1-JAN-09', 'dd-Mon-YY')
    ) + 1
    SELECT TRANSLATE (SYS_CONNECT_BY_PATH ( TO_CHAR (dt, 'Mon-YY')
    ) AS txt
    FROM     all_months
    WHERE     CONNECT_BY_ISLEAF = 1
    START WITH     rn = 1
    CONNECT BY     rn = PRIOR rn + 1
    The output generated by this query is like this
    Jan-09 Feb-09 Mar-09 Apr-09
    There is table create resource_plan
    which is having a structure like this ID Dates Commnets
    data is getting stored like this Jan-09 Feb-09 Mar-09 Apr-09
    I need to insert the data in this fashion Jan-09
    Feb-09
    Mar-09
    Apr-09
    How to split the data and save please suggest
    This is the insert query i am writing
    insert into resource_plan
    ( id,dates,comments)
    values
    (1,wwv_flow.g_f01,'');
    Please suggest me how to split the row data and insert in column wise.
    Thanks
    Sudhir.

    Sudhir_N wrote:
    My requirement was not with query i need to display the data in the same fashion how is getting populated only reqirement of mine was when getting stored into the table it must store in this order in the table
    01-JAN-09
    01-FEB-09
    01-MAR-09
    01-APR-09
    Thanks
    Sudhir.And the following didn't help you in that?
    Message From OP's previous thread:
    Hope the following code helps:
    SQL> WITH test_tab AS
    2       (SELECT '01-Jan-2008' start_date, '01-Dec-2009' end_date
    3          FROM DUAL)
    4  SELECT     ADD_MONTHS (TO_DATE (start_date, 'DD-Mon-YYYY'), LEVEL - 1) date
    _1
    5        FROM test_tab
    6  CONNECT BY LEVEL <=
    7                  MONTHS_BETWEEN (TRUNC (TO_DATE (end_date, 'DD-Mon-YYYY')),
    8                                  TRUNC (TO_DATE (start_date, 'DD-Mon-YYYY'))
    9                                 )
    10                + 1
    11  /
    DATE_1
    01-JAN-08
    01-FEB-08
    01-MAR-08
    01-APR-08
    01-MAY-08
    01-JUN-08
    01-JUL-08
    01-AUG-08
    01-SEP-08
    01-OCT-08
    01-NOV-08
    DATE_1
    01-DEC-08
    01-JAN-09
    01-FEB-09
    01-MAR-09
    01-APR-09
    01-MAY-09
    01-JUN-09
    01-JUL-09
    01-AUG-09
    01-SEP-09
    01-OCT-09
    DATE_1
    01-NOV-09
    01-DEC-09
    24 rows selected.
    SQL>
    Please explain what you didn't understand.
    Regards,
    Jo

  • Transpose Columnwise data to row wise date in 10g

    Hi,
    How can I transpose the below type of data to
    ID     MOTNH      YEAR     Pram1     Param2 Parm2
    10000     11     2012 200     300     500
    10001     11     2012     700     800 100
    to
    ID     MONTH     YEAR PARAMETER TARGET     
    10000     11     2013     Pram1          200          
    10000     11     2013     Pram2          300          
    10000     11     2013 Pram3          500          
    10001     11     2013 Pram1     700          
    10001     11     2013     Pram2     800          
    10001     11     2013     Pram3     100
    Regards,
    Tarun

    Basic think in converting column to row is you need to know the number of columns up front. In your case its 3. Now you have to create a dummy table that will have three rows and cross join this with your original table. Then you need to manipulate your data with a DECODE or CASE statement.
    below is an example.
    with my_table
    as
    select 10000 id, 11 mth, 2012 yr, 200 prm1, 300 prm2, 500 prm3 from dual union all
    select 10001 id, 11 mth, 2012 yr, 700 prm1, 800 prm2, 100 prm3 from dual
    ), cross_join_table
    as
    select level no
      from dual
    connect by level <= 3 -- This will change based on number of param columns in my_table
    select id, mth, yr, decode(no, 1, prm1, 2, prm2, 3, prm3) prm
      from my_table
      cross
      join cross_join_table
    order by id, mth, yr, no

  • Row wise date calculation

    Hello all the seniors, i am using Oracle 10g & Form 6i;
    create table empl
    (code varchar2(4), dob date);
    insert into empl values ('1095',to_date('12/02/1960','dd/mm/yyyy');
    insert into empl values ('1098',to_date('02/09/1952','dd/mm/yyyy');
    insert into empl values ('1099',to_date('28/04/1956','dd/mm/yyyy');
    insert into empl values ('1104',to_date('16/02/1965','dd/mm/yyyy');
    insert into empl values ('1115',to_date('02/02/1966','dd/mm/yyyy');
    insert into empl values ('1116',to_date('23/02/1956','dd/mm/yyyy');
    insert into empl values ('1786',to_date('07/05/1974','dd/mm/yyyy');
    insert into empl values ('1721',to_date('14/01/1983','dd/mm/yyyy');
    I want the query result to be like this;
    CODE     DOB        AGE YMD      Round Y/M MX  Y/M     MNTHS
    1095   12/02/1960  49/10/11        49/10       60   10/2    122
    1098   02/09/1952  57/03/21        57/4       60     2/8      32
    1099   28/04/1956  53/07/25        53/8       60     6/4      76
    1104   16/02/1965  44/10/07        44/10       60    15/2    182
    1115   02/02/1966  43/10/21        43/11       60    16/1    193
    1116   23/02/1956  53/10/00        53/10       60     6/2      74
    1786   07/05/1974  35/07/16        35/8       60    24/4    292
    1721   14/01/1983  26/11/09    26/11       60    33/1    397AGE YMD should be calculated upto sysdate.
    Y/M = MX - Round YM
    MNTHS = Y/M * 12
    please help.
    TY & regards.

    Merry Christmas!
    If you like Ravikumar's solution, but you like Blushadow's formatting better, then compare how Ravikumar and Blushadow use TO_CHAR differently, and do what Blushadow does.
    It helps if you format the code so that you can tell what the arguments to each function are.
    You'll notice that Blusadow starts the 2nd argument to TO_CHAR with 'fm', but Ravikumar does not. Normally, TO_CHAR leaves room for a sign in its output; 'fm' tells it not to do that, so you can modify Ravikumar's solution like this:
    ...to_char ( TRUNC ( months_between (sysdate,d ob)
                 / 12
           , 'FM00'     -- FM added
    || '/' 
    || to_char ( mod ( TRUNC ( months_between (sysdate,dob)
               , 12
            , 'FM00'     -- FM added
    || '/' 
    || to_char ( ROUND ( sysdate
                 - add_months ( dob
                        , floor (months_between (sysdate, dob))     -- Don't use TO_CHAR here
            , 'FM00'     -- FM added
         )      AS "AGE YMD",WITH clauses are very useful, and a great programming practice. If your version of Forms doesn't allow them, then you can write a view using a WITH clause in the database, and simply wuery the view within forms.
    If you really have to avoid the WITH clause, you can usually re-write it using in-line views.
    For example:
    select code, dob, age_ymd
          ,case when round_m = 13 then to_char(yr+1,'fm09')||'/00'
           else to_char(yr,'fm09')||'/'||to_char(round_m,'fm09')
           end as round_y_m
          ,mx
          ,to_char(mx-(yr+1),'fm09')||'/'||to_char(case when round_m = 13 then 0
                                                   else 12-round_m
                                                   end
                                                  ,'fm09') as y_m
          ,((mx-(yr+1))*12)+case when round_m = 13 then 0 else 12-round_m end as mnths
    from      (     -- Begin in-line view t3
            select code, dob
                      ,to_char(yr,'fm09')||'/'||to_char(mt,'fm09')||'/'||to_char(dy,'fm09') as age_ymd
                      ,case when mt in (1,3,5,7,8,10,12) then case when dy <= 15 then mt else mt+1 end
                       when mt in (4,6,9,11) then case when dy < 15 then mt else mt+1 end
                       else case when dy < 14 then mt else mt+1 end
                      end as round_m
                     ,60 as mx
                     , yr, mt, dy
                from      (     -- Begin in-line view t2
                              select code, dob, yr, mt
                                    ,case when dy < 0 then
                                       case when mt in (1,3,5,7,8,10,12) then 31+dy-1
                                            when mt in (4,6,9,11) then 30+dy-1
                                       else 28+dy-1
                                       end
                                     else dy end as dy
                              from     (     -- Begin in-line view t
                          select code, dob
                                             ,to_number(to_char(sysdate,'YYYY'))-to_number(to_char(dob,'YYYY')) as yr
                                             ,floor(mod(months_between(sysdate, dob),12)) as mt
                                             ,to_number(to_char(sysdate,'DD'))-to_number(to_char(dob,'DD')) as dy
                                      from empl
                        )     -- End in-line view t
                   )     -- End in-line view t2
         )     -- End in-line view t3
    ;Start with the main query.
    Where Blushadow said
    FROM  t3substitute:
    FROM    (
                SELECT  ...  -- Put the code of sub-query t3 here
            )but where sub-query t3 originally said
    FROM    t2you'll say
    FROM    (
                SELECT  ...  -- Put the code of sub-query t2 here
            )and so on.

  • How to display the data in row wise in smartform

    Hi,
        I have to make a modification a smartform of poprinting and i want to display the row wise . At present it is displaying the  
        column wise. Actually there is a text which i want to display the data row wise.
        It is possible to display the data in row wise of the text .
    Edited by: nav009 on Oct 8, 2009 10:39 AM

    Hello ,
    I  assume that your requiremen is related to smartform.the below is the solution i suggest.
    As per my understanding of your requirement ,It's clear that as of now there is some description field which is also getting displayed along with other PO fields.
    However you would like to display the description field in a new line since the length of this field is longer than other fields as a result the data is getting scattered .
    Therefore one better option could be: since the whole data from PO would be in a loop you can display all other fields in one line type of the table as per the intial requirement and you display the description line alone in a new line type wth the desired length so that data would not be scattered and no data loss would happen.
    I assume you are aware of creating of line types for table.
    Thanks
    M.Naveen.

  • Output data in row wise instead of column

    hi all,
    i need to get the output data in row wise which is getting now as column wise.
    for eg:
    below is my final internal table.
    HEADING      DATE   MATNR   BUKRS   DMBTR
    jan/08        200801    567       10       800
    feb/08       200802    567       10       900
    mar/08      200803    567       10       200
    apr/09       200804    567       10       400 
    the output should come as
    MATNR  BUKRS   Jan/08   Feb/08   Mar/08   Apr/08
    567      10       800    900       200      400.
    instead of column wise the output should display as row as above.
    please help how to get this.
    thanks in advance

    Hi Vignesh,
    Please use below program which I created for you reference. It will work for your requirement.
    DATA:BEGIN OF it_test OCCURS 1,
         date(6),
         matnr(5),
         bukrs(3),
         END OF it_test.
    it_test-date = 'jan/08'.
    it_test-matnr = '01234'.
    it_test-bukrs = 'AE1'.
    APPEND it_test.
    it_test-date = 'feb8'.
    it_test-matnr = '56789'.
    it_test-bukrs = 'AE1'.
    APPEND it_test.
    it_test-date = 'mar8'.
    it_test-matnr = '23478'.
    it_test-bukrs = 'AE1'.
    APPEND it_test.
    START-OF-SELECTION.
      LOOP AT it_test.
        WRITE :/ 'DATE', 'MATNR', 'BUKRS', it_test-date, it_test-matnr,  it_test-bukrs .
      ENDLOOP.
    Output Will be as follows :-
    DATE MATNR BUKRS jan/08 01234 AE1
    DATE MATNR BUKRS feb8   56789 AE2
    DATE MATNR BUKRS mar8   23478 AE3
    Please set to resolve if this satisfies your requirement.
    Regards
    Abhii..

  • Calculate date differences in consecutive rows and generate a sequence

    Hi Guys,
    I am trying to implement one scenario where in i need to compare the date differences for consecutive rows and generate a sequence against that.
    this is the table schema:
    create table temp
    id int identity(1,1),
    emp_id int,
    time datetime
    insert into temp 
    values
    (1, '2011-02-20 12:30:00.000'),
    (1, '2011-02-20 12:32:34.172'),
    (1, '2011-02-20 12:32:34.172'),
    (1, '2011-02-20 12:43:21.004'),
    (1, '2011-02-20 12:46:39.745'),
    (2, '2011-02-20 12:48:06.004'),
    (2, '2011-02-20 12:48:06.004'),
    (2, '2011-02-20 12:53:07.733'),
    (2, '2011-02-20 12:55:30.295');
    now, I want to compare the first date-time with the second and so on. now if the date-time difference is same for two consecutive rows then the sequence should  increment by 1 otherwise the sequence again will start from '00' for any unique date-time.
    This sequence number should start from '00' from each employee.
    I want the output to be like this
    ID emp_id
    time    
    sequence
    1 1 2011-02-20 12:30:00.000
    00
    2  1 2011-02-20 12:32:34.172
    00
    3  1 2011-02-20 12:32:34.172
    01
    4  1 2011-02-20 12:32:34.172
    02
    5  1 2011-02-20 12:46:39.745
    00
    6  2 
    2011-02-20 12:48:06.004 00
    7  2 
    2011-02-20 12:48:07.003 00
    8  2 
    2011-02-20 12:48:07.003 01
    9  2 
    2011-02-20 12:46:39.745 00
    Please revert as soon as possible as this is a bit urgent.
    Thank You in Advance. :)

    create table temp
    (id int identity(1,1),
     emp_id int,
     time datetime
    insert into temp values
    (1, '20110220 12:30:00.000'),
    (1, '20110220 12:32:34.172'),
    (1, '20110220 12:32:34.172'),
    (1, '20110220 12:43:21.004'),
    (1, '20110220 12:46:39.745'),
    (2, '20110220 12:48:06.004'),
    (2, '20110220 12:48:06.004'),
    (2, '20110220 12:53:07.733'),
    (2, '20110220 12:55:30.295');
    go
    SELECT id, emp_id, time,
           dateadd(mcs, (row_number() OVER(PARTITION BY emp_id, time ORDER BY
    id) - 1) * 10,
                   convert(datetime2(5), time)) AS [Sequence]
    FROM   temp
    ORDER  BY id
    go
    DROP TABLE temp
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Row wise total in editable ALV

    hello all,
                I am workin on editable alv, the user need to enter the values in the editable fields and in the last column(non-editable) i need to populate the total row wise,as soon as user enters a value and goes to next editable cell or on entering a vale and press enter.how to accomplish this task...
    with regards,
    sandeep akella.
    Edited by: sandeep akella on Aug 20, 2009 1:58 PM

    You need to Implement the OnCellAction event.follow these steps;
    1. Goto WDDOMODIFYVIEW and place the following code
    IF first_time IS INITIAL.
        DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
        lo_cmp_usage =   wd_this->wd_cpuse_usg_alv( ).
        IF lo_cmp_usage->has_active_component( ) IS INITIAL.
          lo_cmp_usage->create_component( ).
        ENDIF.
        DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
        lo_interfacecontroller =   wd_this->wd_cpifc_usg_alv( ).
        DATA lo_value TYPE REF TO cl_salv_wd_config_table.
        lo_value = lo_interfacecontroller->get_model(
        CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
         EXPORTING
            value = abap_true.
      ENDIF.
    2. Implement the onCellAction event as follows;
        Goto Methods tab, create a new method. Method Type- Event Handler , Event - ON_CELL_ACTION
    3. Now in this  method retrive the contents of the row and calculate the value as follows.
    DATA: l_element TYPE REF TO if_wd_context_element.
      DATA:ls_stru TYPE wd_this->element_cn_alv.
      DATA: l_node TYPE REF TO if_wd_context_node.
      l_node  = wd_context->get_child_node( 'CN_ALV' ).
      l_element = l_node->get_element(  r_param->index ).
      l_element->get_static_attributes( IMPORTING static_attributes = ls_stru ).
      ls_stru-last_col = ls_stru-col1+ls_stru-col2....+ ls_stru-col5. " add all the cells data
      l_element->set_static_attributes( exporting static_attributes = ls_stru ).

  • Regarding Logical level key and row wise initialization

    Hi Gurus,
    What is the purpose of row wise initialization in external table authentication and when we have to go for row wise initialization.
    Why we have to enable logical level key in hierarchy is this only for getting drill down to the next level if we make two columns as logical level key what will happens. If we want to enable a column as a logical level key what are the character sticks that column should satisfy.
    Thanks,

    1) Row Wise Initialization used to hold multiple values in a variable. Let says SQL gives 4 rows (A,B,C,D) as output. Now I want to hold 4 value in a variable to get this happen we need to go for RowwiseIniziation. If you do not do this at any point in time Variable holds only value A not others. Simply it works as Array.
    2) Level keys define the unique elements in each level and provide the context for drill down. You can make two logical columns as logical key but you need to make sure what to be displayed in your hierarchy by selecting DISPLAY. If you make to as separate logical keys and set Display for both you get two columns in the hierarchy
    http://gerardnico.com/wiki/dat/obiee/hierarchy_level_based

  • How 2 Change of column wise o/p  to row wise output in ABAP?

    Hi all,
    I am getting the output in column wise as normally but how can I get the ouput in row wise.in ABAP.
    its urgent. can any one help me how to change the output layout?
    thanks in advance,
    Sakthi.C

    if it is normal report  .then
    go through the write  statents  . one of that is below 
    Loop at itab .
    write  : itab  .
    endloop.
    if it is  ALV  then you have to  define an internal table which are the fieldds  you  want palce in the  Row .
    so  that  
    data  c type  i value    '1'.
    loop at  itab .
    fieldcatalog-fieldname   = itab-field.
    fieldcatalog-col_pos     = c.
    append fieldcatalog to fieldcatalog.
    clear  fieldcatalog
    c = c + 1.
    endloop.
    so that  the Col_pos  will be increased  and the  Column data will be moved into Row .
    reward  points if it is usefull...
    Girish

  • Date Difference in same column

    select to_char(CREATEDON,'DD-MM-YYYY HH24:MM:SS'),LABSTATUS,REMARKS from history_paperlesstran
    where hnum='797551D' order by to_char(CREATEDON,'DD-MM-YYYY HH24:MM:SS');
    Rownum TO_CHAR(CREATEDON,' LABSTATUS REMARKS
    1 20-10-2010 08:10:08 1 Barcode number generated and printed
    2 20-10-2010 08:10:08 1 Barcode number generated and printed
    3 20-10-2010 08:10:08 1 Barcode number generated and printed
    4 20-10-2010 08:10:08 1 Barcode number generated and printed
    5 20-10-2010 08:10:08 1 Barcode number generated and printed
    6 20-10-2010 08:10:08 1 Barcode number generated and printed
    7 20-10-2010 09:10:55 3 Recieved in department
    8 20-10-2010 09:10:58 3 Recieved in department
    9 20-10-2010 09:10:58 3 Recieved in department
    10 20-10-2010 09:10:58 3 Recieved in department
    11 20-10-2010 09:10:58 3 Recieved in department
    12 20-10-2010 10:10:38 3 Recieved in department
    13 20-10-2010 11:10:34 1 Barcode number generated and printed
    14 20-10-2010 11:10:34 1 Barcode number generated and printed
    15 20-10-2010 11:10:35 3 Recieved in department
    16 20-10-2010 12:10:08 3 Recieved in department
    17 20-10-2010 14:10:03 1 Barcode number generated and printed
    18 20-10-2010 14:10:44 3 Recieved in department
    18 rows selected.
    Dear Friends, Now i want to get the date difference on labstatus based,i.e rownum1 - rownum7, rownum2 - rownum8, and rownum17 - rownum18
    Thing is Barcode number generated and printed - Recieved in department for each & every samples.
    Advance thanks for your solution...
    Edited by: bharathit on Oct 21, 2010 2:18 AM

    You mean something like this?
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1 as rn, to_date('20-10-2010 08:10:08', 'DD-MM-YYYY HH24:MI:SS') as dt, 1 as labstatus, 'Barcode number generated and printed' as comments from dual union all
      2             select 2, to_date('20-10-2010 08:10:08','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
      3             select 3, to_date('20-10-2010 08:10:08','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
      4             select 4, to_date('20-10-2010 08:10:08','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
      5             select 5, to_date('20-10-2010 08:10:08','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
      6             select 6, to_date('20-10-2010 08:10:08','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
      7             select 7, to_date('20-10-2010 09:10:55','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
      8             select 8, to_date('20-10-2010 09:10:58','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
      9             select 9, to_date('20-10-2010 09:10:58','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
    10             select 10, to_date('20-10-2010 09:10:58','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
    11             select 11, to_date('20-10-2010 09:10:58','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
    12             select 12, to_date('20-10-2010 10:10:38','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
    13             select 13, to_date('20-10-2010 11:10:34','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
    14             select 14, to_date('20-10-2010 11:10:34','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
    15             select 15, to_date('20-10-2010 11:10:35','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
    16             select 16, to_date('20-10-2010 12:10:08','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual union all
    17             select 17, to_date('20-10-2010 14:10:03','DD-MM-YYYY HH24:MI:SS'), 1, 'Barcode number generated and printed' from dual union all
    18             select 18, to_date('20-10-2010 14:10:44','DD-MM-YYYY HH24:MI:SS'), 3, 'Recieved in department' from dual)
    19  --
    20  -- END OF TEST DATA
    21  --
    22     ,x as (select rn, dt, labstatus, comments, row_number() over (partition by labstatus order by rn) as labrn from t)
    23  --
    24  select y.rn as rn1, y.dt as dt1, z.rn as rn2, z.dt as dt2, round((z.dt - y.dt)*24*60) as mins_diff
    25  from x y join x z on (y.labrn = z.labrn)
    26  where y.labstatus = 1
    27* and   z.labstatus = 3
    SQL> /
           RN1 DT1                        RN2 DT2                  MINS_DIFF
             1 20/10/2010 08:10:08          7 20/10/2010 09:10:55         61
             2 20/10/2010 08:10:08          8 20/10/2010 09:10:58         61
             3 20/10/2010 08:10:08          9 20/10/2010 09:10:58         61
             4 20/10/2010 08:10:08         10 20/10/2010 09:10:58         61
             5 20/10/2010 08:10:08         11 20/10/2010 09:10:58         61
             6 20/10/2010 08:10:08         12 20/10/2010 10:10:38        121
            13 20/10/2010 11:10:34         15 20/10/2010 11:10:35          0
            14 20/10/2010 11:10:34         16 20/10/2010 12:10:08         60
            17 20/10/2010 14:10:03         18 20/10/2010 14:10:44          1
    9 rows selected.
    SQL>

  • Year Wise Data in SQL Express

    Hi...
    Can any one help for How to maintain year wise data in sql server. 
    In my project i manage year wise data i.e 1st April to 31 march.
    At the end of the year the current year closing balances need to update as opening balance for the next year and previous data wont be changed.
    And i dont know how to  create year wise folders in one database....
    Please show me some suggestion...

    Hi
    According to your description, we got that you want to manage year wise data in one database. You can try to create a partitioned table with a Year column to store all the data. The partitioning feature is supported in SQL Server 2005 and later versions of
    SQL Server. There are four major steps for implementing partitioning.
    1. Create a filegroup or filegroups and corresponding files that will hold the partitions specified by the partition scheme.
    2. Create a partition function that maps the rows of a table into partitions based on the values of a specified column.
    3. Create a partition scheme that maps the partitions of a partitioned table to the new filegroups.
    4. Create or modify a table and specify the partition scheme as the storage location.
    For how to create a partitioned table, please review the following links:
    Create Partitioned Tables and Indexes:http://msdn.microsoft.com/en-us/library/ms188730.aspx
    Creating a table with horizontal partitioning in SQL Server:
    http://www.mssqltips.com/sqlservertip/1796/creating-a-table-with-horizontal-partitioning-in-sql-server/
    Thanks
    Lydia Zhang

  • How to display 7 values of  single field in row wise.

    hi,
    how to display 7 values of  single field in row wise.
    thankx in advance.

    hi ,
    do it like this :
    1 Place ur UI element in tranparent container with Layout as Row Data and Layout Data as Row Head Data
    2 Ur first  UI , which contains the first value as Row Head Data ,
    3 Others as Row Data
    u can do it with Matrix Data as well
    if u want to give space , u can use HORIZONTAL GUTTER and set its width to medium / large / Xlarge
    also there is a UI element "INVISIBLE ELEMENT" ,
    1 u can use this UI element to provide space between ur other UI elements in the view
    2 u can insert a text element as well , and in the Text property of the element press ALT + 0160.
    u can give the space bw UIs as desired.
    regards,
    amit

  • Abt Row - Wise initialization

    Hi Gurus,
    What is the use of row wise initialization when we have go for this can i have one scenario for better under standing.
    Thanks,

    Check these
    http://gerardnico.com/wiki/dat/obiee/row-wise
    http://docs.oracle.com/cd/E12103_01/books/admintool/admintool_Variables6.html
    http://obiee10grevisited.blogspot.com/2012/03/row-wise-initialization.html

  • Row-Wise Session Variable Initialization Block (Max Rows)

    Hi, we have a problem with Row-Wise Session Variable.
    We'll try to implemented the security with a External Query and a Row-Wise Initialization Block. But when we'll try to open the Web Obiee and the rows of result of the query is more than 3000 rows, the browser is broken. The access is very slowly.
    When the result of Query to Row-Wise Variable is more than 3000 rows and we'll try to open the Web Obiee, we have to close NQServer.EXE process of Obiee Server.
    Is there a best practise or a limit rows in the Row-Wise Initialization Block?.
    Thanks.

    You're Right, the people can't be in 3000 groups.
    Is possible I don't explain my problem correctly.
    We use this Row-Wise Variable for implement Data Level Security. .
    For Example :
    I have a fact table with Offices and Office's Sales.
    And each Obiee User can see many Offices according to their level of security.
    I want filter the fact table using a external SQL table implemented in a Session Row-Wise Variable and a User can have X Offices (In the worst case, 3000 Offices).

Maybe you are looking for

  • Animated gif on multiple rollover buttons ?

    I want to use animated gifs as MouseOver in rollover buttons. Somehow when I put this together the animation only works for the first time I do the MouseOver. - the anim gifs are not looping I want them to restart every time I have a MouseOut and Mou

  • How do I move all my settings from my old computer with Vista to a New one with Windows 7 ? I'm using V. 14.0.1 on both Systems

    Hello All, How do I move all my Settings & Bookmarks from my 5 year old Computer running Vista and Firefox V. 14.0.1 , to my New Computer with Windows 7 and also Firefox 14.0.1 ? Thank you very much.

  • Lost indesign file please help

    Hi guys, last night I was working on some coursework, I had just done saves throughout the night multiple times to the same name as ''Design.indd'' on my desktop. I then plugged in my HDD. I then right click ''save as'' and then went over my design.i

  • Re: exchange partition on weekly partition

    We have divided month in 4 week partitions Week 1 start from date 2 to 8, Week2 start from 9 to 15, Week3 start from 16 to 22 and Week4 start from 23 to 1st of coming month. Tables has huge data (some tables size in TB). Can exchange partition will w

  • How long do I have to wait for service?

    Waited over an hour yesterday trying to get through on the phone to itunes store which is so screwed up it keeps telling me that I have authorized this computer plus one other computer to play songs I bought but it won't let me play them because this