Date & time  difference in a single column but multiple rows in a table

hi folks,
am using Oracle db 10g by chance is there any other way to do my requirement.
as I stated in my subject.

You probably need LAG:
SQL> -- generating sample data (how hard can it be...)
SQL> with testdata as (
  2  select 200 bno, 32 temperature, to_date('28.05.2012 09:00:00', 'dd.mm.yyyy hh24:mi:ss') dt from
dual union
  3  select 200, 36,to_date('28.05.2012 15:00:00', 'dd.mm.yyyy hh24:mi:ss') from dual
  4  )
  5  --
  6  -- actual query:
  7  --
  8  select bno
  9  ,      temperature
10  ,      dt
11  ,      numtodsinterval(dt-lag(dt) over (partition by bno order by dt), 'day') difference_int
12  ,      substr((numtodsinterval(dt-lag(dt) over (partition by bno order by dt), 'day')), 12, 8)
difference_dt
13  from   testdata;
       BNO TEMPERATURE DT                  DIFFERENCE_INT                 DIFFEREN
       200          32 28-05-2012 09:00:00
       200          36 28-05-2012 15:00:00 +000000000 06:00:00.000000000  06:00:00
2 rows selected.But, as Paulie already said: still insufficient input. We know nothing about your datatypes. I assumed you're using a DATE.

Similar Messages

  • Select single column but multiple rows in JTable

    Hi
    I have a jTable and want to be able to select multiple rows but only in a single column.
    I've set these properties which makes selection almost the way I would like it.
    table1.setCellSelectionEnabled(true);
    table1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);the only problem now is that the user can select multiple columns.
    Is there a simple way to restrict selection to single column?
    regards
    abq

    table.setCellSelectionEnabled(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    DefaultListSelectionModel model =
         (DefaultListSelectionModel)table.getColumnModel().getSelectionModel();
    model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  • Calculate Date/Time Difference in a Calculated Column Omitting Weekends, Holidays and Non-Working Hours

    I am looking for a formula to use in a calculated column that calculates the difference between two date/time fields while excluding weekends, holidays and non-working hours
    6/1/2010 9:43 AM - 6/7/2010 1:45 PM
    Here is the closest that I have gotten; however, this formula gives me a result of 96:
    =IF(AND((WEEKDAY([Resolved Date],2))<(WEEKDAY(Created,2)),((WEEKDAY(Created,2))-(WEEKDAY([Resolved Date],2)))>1),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved Date],"D")+1)/7,1))-3),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved
    Date],"D")+1)/7,1)*2))*24)
    Any and all assistance is greatly appreciated!

    I don't know how to exclude holidays but i exclude weekends(Sat&Sun)-
    IF(ISERROR(DATEDIF([Start Date],[End Date],”d”)),””,(DATEDIF([Start Date],[End Date],”d”))+1-INT(DATEDIF([Start Date],[End Date],”d”)/7)*2-IF((WEEKDAY([End Date])-WEEKDAY([Start
    Date]))<0,2,0)-IF(OR(AND(WEEKDAY([End Date])=7,WEEKDAY([Start Date])=7),AND(WEEKDAY([End Date])=1,WEEKDAY([Start Date])=1)),1,0)-IF(AND(WEEKDAY([Start Date])=1,(WEEKDAY([End Date])-WEEKDAY([Start Date]))>0),1,0)-IF(AND(NOT(WEEKDAY([Start Date])=7),WEEKDAY([End
    Date])=7),1,0))
    -Thanks
    Swapnil

  • How to display time difference in a single cell separately.

    Hi All,
    I have an issue where you have to calculate the Start time and End Time , Start Date and End Date for a particular Work item number
    For eg ;
    WI_ID            WI_CD                WI_CT
    000001312610        02/09/2009      09:48:4     02/09/2009      09:48:9 
    000001312610        02/09/2009      09:54:4   02/09/2009        09:54:9
    000001312610        02/09/2009      09:54:5     02/09/2009      09:54:9
    000001312610        02/09/2009      10:07:0  02/09/2009         10:07:9
    000001312610        02/09/2009      10:07:0     02/09/2009      10:07:9
    000001312610        02/09/2009       10:16:5     02/09/2009       10:16:9
    000001312610        02/09/2009     10:16:7       02/09/2009     10:16:9
    Similarly I get the Endtime and ENd dayfrom other table for same work item.so my output should have the result as ,So my requirement here is
    in the it should show the display in a single cell .as, 5secs, 5 secs,4 secs,9secs,4 secs,2 secs
    for each work item.
    Can any body help me on this issue.
    Any pionters for this are much helpful forme.
    Thanks
    Rohini

    Hi Kewin,
    Its not the question of concatenation, that can be handled later.
    But my issue is how to calculate time difference for each single step

  • Performance of update query for single column vs multiple column

    Hi All,
    I could not find any answer for this, does it ever matter in terms of performance updating single column versus multiple column in a single update query.
    For eg. table consisting of 15 columns, what would be the difference in performance when one column is update in the single query against another update query where 15 columns are updated.
    Please do keep in mind my table columns in actually could be around 150+.
    Thanks for any information provided.

    If updated columns aren´t on where clause , then the only impact of 15 columns will be a increase on redo generation, and a possible chainning row.
    So since the redo is one of the things that have a large impact, the answer is yes.
    The performance will be slower.
    Regards
    Helio Dias.
    http://heliodias.com
    OCE SQL, OCP 9i

  • Difference between select single & select upto 1 row

    Hi,
    what is the Difference between select single & select upto 1 row?
    Whose performance is better?
    Regards,
    Mayank

    Hi
    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

  • 2.1.0.62: Bug editing text columns in multiple rows using editor-window

    Hello Forum,
    I hope this is not a double post, but I did not come up with the right keywords to search for.
    So here is the bug/strange annoying behavior:
    When I edit multiple rows of a table using the extra edit-window, it shows the text of the previous row I edited and not the text of the actual row.
    Well, sounds quit complicated so I'll give an example:
    Suppose you have a table with two columns and two rows. One column is of type varchar2. Say it contains the values "one" and "two".
    Now I click into the row containing "one", open the extra-edit-window and change the value to "one-1".
    Then I click into the second row and also open the extra-edit-window. The window shows "one-1" instead of "two" as it should.
    This is very annoying because I don't have autocommit activated and when I edit a couple of clob fields, the editor just shows the text of the previous field. I have to say commit for every row in order not to scramble the contents of multiple fields. I have to use the edit-window because the inplace editor is not very useful when editing large texts.
    I observed this bug with varchar2 and clob fields but it may not be restricted to those.
    I run Windows XP and conect to Oracle 10.2.0.4
    Regards,
    dhalek

    Hello -K-,
    setting "Post edits on row change" indeed does prevent this bug, but leads to another problem:
    When I click the rollback-button, the table data is not reverted to its original state. In fact the changes are not commited, but rolling back, does not give the old data back. I can enter "rollback;" into the worksheet and then refresh the table data to show the old values but internally SQL Developer still thinks it has uncommitted changes in the table.
    I, for now, uncheck "Post edits on row change" and use the inplace editor wherever possible. That has some strange cursor bugs (sometimes puts the cursor to the end making it impossible to enter text in the middle of the field) but that does not affect other rows.
    Regards,
    dhalek
    Edited by: dhalek on 30.10.2009 15:08

  • How do I change the background of a single cell or a row in a table?

    How do I change the background of a single cell or a row in a
    table? I doesn't seem to be letting me do that.

    Are you using the latest DW? If so, then it isn't letting you
    because
    bgcolor is deprecated and shouldn't be used.
    The correct way is to use css to define the background of a
    cell
    CSS:
    .blackcell {background-color: black;}
    HTML:
    <td class="blackcell">whatever in the cell</td>
    Nadia
    Adobe® Community Expert : Dreamweaver
    CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    ~ Template Customization ~
    http://www.csstemplates.com.au
    Spry Widget Examples
    http://www.dreamweaverresources.com/spry-widgets/
    "dm25" <[email protected]> wrote in message
    news:f4jr5h$luu$[email protected]..
    > for some reason that doesn't always work. When I click
    inside a cell, it
    > doesn't give me an option to change the background
    color.

  • Function Module for Date/ Time difference in Working Days

    Hi all,
    Are there any function modules which will calculate the difference between a date AND time, but in working days?
    I can use the FIMA_DAYS_BETWEEN_TWO_DATES_2 FM for the dates, but I need to include times in this as well.
    This is for situations where the 'starting date' is a non-working day, and the 'end date' is a working day.  In this situation I need to take all the hours and minutes into account, which happened on the working day.  To give an example -
    Start date:  04.07.2010 (Sunday - Non working day)
    Start time:  21:12:36
    End date:  05.07.2010 (Monday - Working day)
    End time:  04:47:24
    I realise there is a Time option in this function module, but when I test it, it doesn't seem to be returning the desired results (returns 0 for days and time).  I am using '5' as the I_STGMETH and 'GB' as the I_SKALID. 
    I need a calcuation which will return the time, post midnight on the working day - in this example, 4 hours, 47 minutes (seconds are optional!).
    Can anyone help? - can I still use FIMA_DAYS_BETWEEN_TWO_DATES_2 but with different parameters?
    Thanks
    Mischa
    Edited by: Mischa Gulseven on Jul 20, 2010 10:40 AM

    Hi,
    Thanks but this FM does not seem to account for working days.
    For example, if I use:
    DATE1                           04.07.2010  (non working day)
    TIME1                           04:00:00
    DATE2                           05.07.2010   (working day)
    TIME2                           21:00:00
    It will give the following results -
    DATEDIFF                                                      1
    TIMEDIFF                                                     17
    EARLIEST                        1
    I don't want to account for the non-working day so the result I actually want would be to calculate from midnight on 05.07 to 21:00 on 05.07 which should be 21 hours.
    I suspect I probably need to include the STGMETH and the factory calendar somewhere in the FM?
    Does such a FM exist, or could anyone help me with some ABAP for this?
    thanks
    Mischa

  • Date/Time difference based on working days

    Hi Guru's,
           I am having a problem getting the difference between two timestamps. A normal difference between 2 timestamps is possible however i would like to calculate the hour difference between 2 timestamps excluding public holidays, weekends and also after office hours. Is there a series of FM or a logic to extract this kind of info. Hope you guys can shed some light into the matter.
    Thanks in advance.
    Anand

    Hi,
    Use FM DATE_COMPUTE_DAY. DATE in MM/DD/YYYY format.
    This FM returns the date in form of weekday number ie the date which you give is tuesday then it will return 2.
    Give call log date and call handled date.
    eg A call is logded on tuesday 3.00 pm and handled on Thursday 10.a.m.
    First check the days difference from the return of this FM.
    IF the call handled date return - call loged date return is positive means no sat sun , if negative means sat and sun.
    then from call logged date time start counting the office hours till call handled time.
    Office hours can be easily calculated using 24 hours clock.
    For public holidays have to check whether between the twodates any public holiday if is there then subtract that much office hours.
    Hope this helps.
    Thanks,
    Niketa

  • Difference between select single * & select upto 1 rows

    difference between select single * & select upto 1 rows

    Hi,
       According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Mainly: to check if entries exist.
    Select Single
    You need to mention all the key fields of the table.
    No END SELECT required.
    More performance compared to upto 1 row.
    Where as UP to 1 row.
    YOu can use if you do not have all the primiary key fields available.
    END SELECT requeired.
    Since all keys are not passing, possiblities of have other rows which satisfies the condition.
    Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.
    Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.
    The most important thing to remember about the SELECT SINGLE is
    There are several things to remember:
    1) It retrieves only one row
    2) It does not need an ENDSELECT statement
    3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN
    THE WHERE CLAUSE OF THE SELECT STATEMENT
    Regards

  • Select column, but group rows inside that column first

    Hi,
    I have a scenario where I want to show data from a column, but the column has multiple entries of the 'same' entry.
    id company
    1 burger_king
    2 mcdonalds
    3 mcdonalds_east
    4 diary_queen
    5 mcdonalds_west
    I want to be able to show all companies but group the mcdonalds companies.
    Any suggestions on how to do that?
    Thanks.

    Here's a funky way (if I haven't misread the requirement):
    SQL> -- generating sample data:
    SQL> with t as (
      2  select 1 id, 'burger_king' company from dual union
      3  select 2, 'mcdonalds' from dual union
      4  select 3, 'mcdonalds_east' from dual union
      5  select 4, 'diary_queen' from dual union
      6  select 5, 'mcdonalds_west' from dual
      7  )
      8  --
      9  -- actual query:
    10  --
    11  select id
    12  ,     company
    13  from  ( select id
    14          ,      company
    15          ,      row_number() over (partition by soundex(company) order by id) rn
    16          from   t
    17        )
    18  where rn = 1;
            ID COMPANY
             1 burger_king
             4 diary_queen
             2 mcdonalds
    3 rows selected.

  • Need query to convert Single Row Multiple Columns To Multiple rows

    Hi,
    I have a table with single row like below
    Column0 | Column1 | Column2 | Column3 | Column4|
    Value0    | Value1    | Value2    | Value3    |  Value4  |
    Am looking for a query to convert above table data to multiple rows having column name and its value in each row as shown below
    Column0 | Value0
    Column1 | Value1
    Column2 | Value2
    Column3 | Value3
    Column4 | Value4
    Thanks in advance.
    Mohan

    Hi ykMohan,
    Dynamic UNPIVOT can be applied in this case as well.
    CREATE TABLE dbo.T(ID INT,Column0 VARCHAR(99),Column1 VARCHAR(99),Column2 VARCHAR(99),Column3 VARCHAR(99),Column4 VARCHAR(99))
    INSERT INTO T VALUES
    (1,'Value0','Value1','Value2','Value3','Value4'),
    (2,'Value0','Value1','Value2','Value3','Value4');
    DECLARE @columns VARCHAR(MAX)
    SELECT @columns=
    STUFF(
    SELECT ','+ COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='T' AND TABLE_SCHEMA='dbo' AND Column_name NOT IN('ID') FOR XML PATH('')
    ),1,1,'')
    DECLARE @Sql NVARCHAR(MAX)
    SET @Sql =
    'SELECT ID, UPT.col,UPT.val FROM T
    UNPIVOT
    (val FOR col IN('+@columns+')) AS UPT'
    EXEC sp_executeSQL @Sql
    DROP TABLE T
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • Time difference between one Ext Trig and multiple secondary triggers ?

    An external device generates a 100 Hz square wave (primary). During
    each 10 msec period, another device (secondary) generates multiple
    pulses at random times. I want to determine the time, with respect to
    each primary waveform's leading edge, when each and every of the
    secondary pulses occurs. Not just the first secondary pulse.
    Count Buffered Edges.vi example records times when multiple secondary
    pulses occur, but there does not seems to be a way to set the counter
    value to zero by the primary pulse (especially on STC cards).
    The TIO example Two Edge Separation.vi only measures time between the
    primary pulse and the first secondary pulse, not all secondary pulses.
    The TIO Measure Position.vi fo
    r encoder use mentions using the Z-index
    on the gate pin to initialize the count value. Is there a way to
    combine this with ability to record multiple buffreed time differences
    I envision each 100 Hz leading edge resetting a counter (which is
    counting a high frequency time base) to zero. Then each secondary
    pulse latches that counter's value into memory.
    For each count latched by the secondary pulses, it is not necessary to
    know within which specific primary period it belonged to.
    An alternative is to use two of the Count Buffered Edges.vi and record
    the times of both primary and secondary pulses and take their time
    difference in software.

    Answered on another thread...
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HFORCEKWTID=75037:5&HOID=5065000000080000009EA20000&HExpertOnly=&UCATEGORY_0=_32_%24_12_&UCATEGORY_S=0
    Ron

  • Split single column to multiple

    Hello dears.
    please i have the following along column as below and i want to make it multiple column.
    07700000295
    07700000519
    07700000937
    07700000987
    07700001113
    07700001846
    07700002397
    07700002427
    Output>> 07700000295 07700000937 07700001113 07700002397
    07700000519 07700000987 07700001846 07700002427
    appreciate your efforts..
    Ali//

    Hi, Ali,
    user13721099 wrote:
    ... please i have the following along column as below and i want to make it multiple column...The links above show how to do String Aggregation , where you combine one column from several rows into one column on one row. That one big column can be formatted to look like multiple columns.
    If you really need multiple columns, then you need to Pivot , which is covered in the links on this page:
    SQL and PL/SQL FAQ
    String Aggregation can be much simpler, especially if the number of columns you want depends on the data in the table.
    If you'd like help, post your requirements. Why do you need the data pivoted (or aggregated)? How will the re-arranged data be used? Post your best attempt at a query, and CREATE TABLE and INSERT statements for the sample data, the results you want from that data, and an explanation of how you get those results from that data. If order is important, explain.
    Always say which version of Oracle you're using.

Maybe you are looking for

  • How can I use Final Cut Express in a Mac Pro

    I want to know how could I use my Final Cut Express HD programm (Version 3) in my new Mac Pro.

  • "Error while printing" error in Address Book

    When I attempt to print a list of address book contacts in Address Book.app (both as a PDF or to a printer), I receive an error message simply stating "Error while printing." I've repaired my permissions and tried deleting the preferences for Address

  • Turning on the flash again

    Somehow I have turned off the flash on my camera. I've searched everywhere I can think of but can't seem to find out how to switch it on again! It's a Nokia 2680 slide.

  • Calling servlet from Java

    Hello! I need to send XML file to servlet from Java. I generate XML in general java class. Is there any way how to call servlet directly from Java without using a page with form? I need to send it by post method. I need some java alternative to Micro

  • Moving a piece of text lower than the rest.

    I am wet behind the ears here and need a step by step instruction on how to move the 2 in H2O slightly lower than the rest of the text. I have a background layer that needs to stay blue.