Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8793623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:08:46+00:00 2026-06-13T23:08:46+00:00

In WORK_TIME column in my database table ( EMP_WORKS ), i have records as

  • 0

In WORK_TIME column in my database table (EMP_WORKS), i have records as below.

WORK_TIME

19:03:00
20:00:00
21:02:00
21:54:00
23:04:00
00:02:00

i want to create a database view using these data. for it i need to get Gap between these times as below.

WORK_TIME  GAP

19:03:00  -
20:00:00  00:57:00  (Gap between 19:03:00 and 20:00:00)
21:02:00  01:02:00  (Gap between 20:00:00 and 21:02:00)
21:54:00  00:52:00  (Gap between 21:02:00 and 21:54:00)
23:04:00  01:10:00  (Gap between 21:54:00 and 23:04:00)
00:02:00  00:58:00  (Gap between 23:04:00 and 00:02:00)

How could i do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:08:47+00:00Added an answer on June 13, 2026 at 11:08 pm

    According to your desired result, provided in the question, you want to see time interval. And also I suppose that the WORK_TIME column is of date datatype and there is a date part(otherwise there will be a negative result of subtraction (previous value of WORK_TIME from 00.02.00)).

    SQL> create table Work_times(
      2    work_time
      3  ) as
      4  (
      5  select to_date('01.01.2012 19:03:00', 'dd.mm.yyyy hh24:mi:ss') from dual union all
      6  select to_date('01.01.2012 20:00:00', 'dd.mm.yyyy hh24:mi:ss') from dual union all
      7  select to_date('01.01.2012 21:02:00', 'dd.mm.yyyy hh24:mi:ss') from dual union all
      8  select to_date('01.01.2012 21:54:00', 'dd.mm.yyyy hh24:mi:ss') from dual union all
      9  select to_date('01.01.2012 23:04:00', 'dd.mm.yyyy hh24:mi:ss') from dual union all
     10  select to_date('02.01.2012 00:02:00', 'dd.mm.yyyy hh24:mi:ss') from dual
     11  )
     12  /
    
    Table created
    
    SQL> 
    SQL> select to_char(t.work_time, 'hh24.mi.ss') work_time
      2         , (t.work_time -
      3            lag(t.work_time) over(order by WORK_TIME)) day(1) to second(0) Res
      4  from work_times t
      5  ;
    
    WORK_TIME RES
    --------- -------------------------------------------------------------------------------
    19.03.00  
    20.00.00  +0 00:57:00
    21.02.00  +0 01:02:00
    21.54.00  +0 00:52:00
    23.04.00  +0 01:10:00
    00.02.00  +0 00:58:00
    
    6 rows selected
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i create a multi-column primary key within the CREATE TABLE statement using
I have a column in my database's messages table. It is called status and
I want to have one table with two TIMESTAMP columns. One column to keep
I am using QSqlQuery to insert data into a MySQL database. Currently all I
My table has a timestamp column named RowVer which LINQ maps to type System.Data.Linq.Binary.
Currently I have a database object, vacancies which has a column (foreign key) CareerLevels.
I have am trying to create some integration tests with no external database dependencies
I have column in my table, say updateStamp . I'd like to get an
Our SSDT database project includes a table that has a computed column that can
How do you insert another column, data/timestamp in a database and display it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.