Help with query for entries that take over 4 mins for the current day.

Posted on 2014-09-02
Last Modified: 2014-09-02

I need help writing a query that reports all entries that take over 4 mins for the current day.

Current Query:

select tsjkeyi import_id, TSJSTAD start_time, TSJENDD end_time from TSJ
where TSJTYPS = 22
order by TSJSTAD desc;

import_id   start_time                                               end_time
379324         02-SEP-14 AM         02-SEP-14 AM
379316         02-SEP-14 AM         02-SEP-14 AM

I just want the record where the total time was over 4 minutes:

import_id   start_time                                               end_time
379324         02-SEP-14 AM         02-SEP-14 AM

Thanks in advance!
Question by:xbox360dp
    LVL 73

    Accepted Solution

    SELECT tsjkeyi import_id, tsjstad start_time, tsjendd end_time
        FROM tsj
       WHERE tsjtyps = 22 AND tsjendd - tsjstad > INTERVAL '4' MINUTE
    ORDER BY tsjstad DESC;

    this assumes your tsjendd and tsjstad columns are both of type timestamp.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now