How to find names that are overlapping times

Hello:

I have a table that contains names and their appeal. I need to know which of these names overlap time.

Name | StartTime | End time
A | 26/03/2011 12:33:16 | 26/03/2011 12:40:10
A | 26/03/2011 12:41:28 | 26/03/2011 12:43:19
A | 26/03/2011 12:42:28 | 26/03/2011 12:47:50
B | 26/03/2011-22:22:28 | 26/03/2011-22:50:10
B | 26/03/2011-22:49:28 | 26/03/2011-22:53:50
B | 26/03/2011-22:50:28 | 26/03/2011-22:59:50
B | 26/03/2011-22:59:58 | 26/03/2011-23:10:50
C | 26/03/2011-23:05:58 | 26/03/2011-23:10:50
C | 26/03/2011-23:40:58 | 26/03/2011-23:50:50

I need those names who have several calls and a single call starts before the end of another call. If someone has four calls and two of these overlapping (A has two overlapping and B has three overlapping), this name comes also in my list as below:

Name | Overlapping_Count
A | 1
B | 2

Can someone help me please?

Thank you/Razin

Etbin wrote:
Maybe

NOP:

SQL> select  *
  2    from  tbl
  3  /

N STARTTIME              ENDTIME
- ---------------------- ----------------------
A 26/03/2011 12:33:16 pm 26/03/2011 12:40:10 pm
A 26/03/2011 12:41:28 pm 26/03/2011 12:43:19 pm
A 26/03/2011 12:42:28 pm 26/03/2011 12:47:50 pm
B 26/03/2011 10:22:28 pm 26/03/2011 10:50:10 pm
B 26/03/2011 10:49:28 pm 26/03/2011 10:53:50 pm
B 26/03/2011 10:50:28 pm 26/03/2011 10:59:50 pm
B 26/03/2011 10:59:58 pm 26/03/2011 11:10:50 pm
C 26/03/2011 11:05:58 pm 26/03/2011 11:10:50 pm
C 26/03/2011 11:40:58 pm 26/03/2011 11:50:50 pm

9 rows selected.

SQL> select name,count(*) overlapping_count
  2    from (select x.name,greatest(x.starttime,y.starttime) low_ovlp,least(x.endtime,y.endtime) high_ovlp
  3            from tbl x,tbl y
  4           where x.name = y.name
  5             and greatest(x.starttime,y.starttime) < least(x.endtime,y.endtime)
  6             and x.starttime != y.starttime
  7             and x.endtime != y.endtime
  8         )
  9   group by name
 10  /

N OVERLAPPING_COUNT
- -----------------
A                 2
B                 4

SQL> 

It is simpler and requires no self-join:

with t as (
           select  name,
                   case
                     when max(endtime) over(partition by name order by starttime,endtime rows between unbounded preceding and 1 preceding) > starttime then 0
                     else 1
                   end start_of_group
             from  tbl
          )
select  name,
        count(*) overlapping_count
  from  t
  where start_of_group = 0
  group by name
  order by name
/

N OVERLAPPING_COUNT
- -----------------
A                 1
B                 2

SQL> 

SY.

Tags: Database

Similar Questions

  • Beginner: how to find patches that are needed?

    I have an Oracle DB or a number of (previously installed by a person) from 10.1 to 11.1.

    I would like to patch some of them if necessary, but I don't know how to find patches are needed?

    TNX

    Hello

    The following methods will help to know what are the patches installed at your HOME of ORACLE

    (1) lsinv-bugs_fixed opatch

    This option will give the description of the patches installed as below, but the opatch version should be greater than
    10.2.0.4.5 for version 10.2 ORACLE_HOMEs

    $ lsinv-bugs_fixed opatch

    8576156 8833280 kills Feb 09 16:54:18 MST 2010 PSU 10.2.0.4.3 DATABASE (INCLUDES CPUJUL2009)
    8833280 8833280 kills Feb 09 16:54:18 MST 2010 PSU 10.2.0.4.4 DATABASE (INCLUDES CPUOCT2009)

    (2) select substr(action_time,1,30) action_time,
    substr(ID,1,10) id,
    substr action (action, 1, 10),
    version of substr (version, 1, 8),
    substr(BUNDLE_SERIES,1,6) bundle,
    substr (Comments, 1, 20) comments
    history of registry of $;

    This option works when installing the posts were made for this patch

    Thank you
    Krishna

  • How to find computers that are not on the domain in an Active Directory forest.

    Hello

    I'm looking for a tool that can scan a subnet and give me the list of computers that are not on the field, but connected to the network. My company has recently spent a lot of users of the task force to the area, but there is a population of users who are unwilling to join the domain and still using the local administrator to log on to the computer.

    These computers do not meet the domain policies applied and causing many problems with the network and other systems on the field.

    Help, please.

    concerning

    Syed M. Uzair

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.msdn.Microsoft.com/forums/en-us/home

  • How to find files that are slowing down my computer

    I saw crazy files but I don't remember where I saw them.

    I saw crazy files but I don't remember where I saw them.

    Generally files, in itself, is not slowing down your computer.  Just to have files on your hard disk (because it is not completely filled) means very little - this is when things run / run they can cause problems.

    How to perform a clean boot for a problem in Windows 8, Windows 7, or Windows Vista

    http://support.Microsoft.com/kb/929135/en-us

    The less you have to run all the time, most things you want to run will perform:

    Use Autoruns to understand this all starts when your computer's / when you log in. Look for whatever it is you do not know using Google (or ask here.) You can hopefully figure out if there are things from when your computer does (or connect) you don't not need and then configure them (through their own built-in mechanisms is the preferred method) so they do not - start using your resources without reason.

    You can download and use Process Explorer to see exactly what is taking your time processor/CPU and memory. This can help you to identify applications that you might want to consider alternatives for and get rid of all together.

    Search for malware:

    Download, install, execute, update and perform analyses complete system with the two following applications:

    Remove anything they find. Reboot when necessary. (You can uninstall one or both when finished.)

    Search online with eSet Online Scanner.

  • How to find lines that are inserted in the last minutes n?

    Hi all
    I have a log table where, whenever a warning is issued, a new row is added. The table contains a field with the sysdate when the warning was issued.
    I would need to collect all the warnings in the last 30 minutes (supposed) and send a mail to the administrator. Looking at some FAQ I have explained this:

    Select * from PROCEDURE_LOGS p where ((p.DATE_LOG-sysdate) *-1440) < 30

    However, it does not do anything.
    Can someone help me correct this statement?
    Thank you very much
    Frank

    Assuming that the field is a DATE field and time information are included in this field to date. Then your application should work.

    I would write it differently, but the logic is the same.

    select *
    from procedure_logs p
    where (sysdate - p.date_log) * 24 * 60 <= 30
    ;
    

    Perhaps the information is not yet committed, so that you don't see it in your additional session?

    Look at your data and consider wheather this record must be included or not.

  • How can I find photographs that are not assigned to any collection?

    Hello!

    I use LR 5.7.1 on a Mac.

    When I've airbrushed raw with PS CC images (and do not need file PSD more) I export the PSD (which is in my catalog) in JPG format and let it automatically add to my catalog. After that, I remove the PSD file. Which works very well.

    But... the new JPG file is not assigned to any collection. This is no problem unless I forgot to do it manually after export (and import).

    This brings me to my question.

    How can I find photographs that are not assigned to any collection?

    I tried with a smart collection after I found nothing suitable in the filter library. The search criteria, I tried are Source-> Collection with any of the conditions. One with an empty field, then with just a space and so on.

    Does anyone have a good tip for me?

    Thomas

    You can also add numbers if you have collections that do not use characters of the alphabet.

  • How to find what processes are running on my computer and use it from memory?

    * Original title: find running processes

    How to find what processes are running on my computer and use it from memory?

    You can press Ctrl-Shift-Escape to see which processes are underway and those who is using memory (and how much they use).  Although the memory usage is not as important as how they use lots of CPU, which is what can make your computer slow if there are too many programs use the CPU at the same time.  For memory, even if she says that he uses a lot, an inactive program ' pages on "memory to the hard disk and it frees room for other programs to use, is not as important as the CPU generally (unless you are very very low on memory).

  • way to find vm that are not removed from disk

    Is it possible that I can find, vm that are not removed from disk

    That is to say that "take inventory" but I forgot to remove the disc.

    Thank you

    If you only need a report, you can do it like this (I've made a few changes to your script).

    $unregistered = @)

    foreach ($Datastore in (Get-Datastorecluster xxxx |)) Get - Datastore)) {}

    # Collect .vmx paths of virtual machines stored on the data store

    $registered = @ {}

    Get - VM - Datastore $Datastore | %{

    $_. Extensiondata.LayoutEx.File | where {$_.} Name - like "*.vmx"} | % {$registered. Add ($_.) Name, $true)}}

    # Set up the search. VMX files in the data store

    New-PSDrive-name TgtDS-site $Datastore - PSProvider VimDatastore-Root '-' | Out-Null

    $unregistered += (@(get-ChildItem-Path TgtDS:-Recurse |)

    where {$_.} FolderPath - notmatch ".snapshot" - and $_. Name - like "*.vmx" - and! $registered. ContainsKey ($_.) DatastoreFullPath)} |

    Select DatastoreFullPath))

    Remove-PSDrive-name TgtDS

    }

    $unregistered | Export Csv c:\temp\vm-unregister.csv - NoTypeInformation - UseCulture

  • is it possible to find pages that are not my favorites?

    is it possible to find pages that are not my favorites?

    Yes, it can be done with a script that runs through the entire tree of bookmarks (this must be done recursively, assuming that there are several layers), runs the command associated with each bookmark and then collects the page numbers in a table. All of the pages in the table at the end of the process are not pointed to by any bookmark.

  • How to find the last update date, time and user of the file field peoplecode

    How to find the last updated date time fields of peoplecode records?

    Thank you.

    We can check the update date-time using the following query

    SELECT LASTUPDDTTM IN THE PSPCMPROG WHERE OBJECTVALUE1 LIKE "RECNAME" AND OBJECTVALUE2 AS "FIELDNAME".

  • URGENT: Need to flashback table, how to find SNA for quite some time before the update that's happened?

    Hi all

    I have a new database 11G, I haven't used before flashback, but my retention time is a day... I have once the developer did a massive update to a table to corrupt.

    How can I find the RCS for this time so I can try this table of flashback?

    Thank you

    Cayenne

    Thank you.. I also found that it works:

    SQL > select timestamp_to_scn (to_timestamp('20140103152000','YYYYMMDDHH24MISS')) SNA double;

    SNA

    ----------

    98344246

    Although does NOT work all the time. But that's just what Oracle when you give him a timestamp to flashback to: it converts the timestamp of a SNA and then restores the data based on the SNA.

    See table of Flashback in the language SQL doc

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9012.htm

    TIMESTAMP CLAUSE

    Specify a value of timestamp corresponding to the point in time to which you want to return to the table. The expr must evaluate to a valid time stamp in the past. The table will flash back to a period of about 3 seconds to the specified timestamp.

    This precision "3 seconds" is because of this conversion to SNA - Oracle uses its internal table.

    YVERT is accurate, if you know, but you typically do not have.

    Read and consider these warnings in app dev guide advanced

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28424/adfns_flashback.htm

    Guidelines for Oracle Flashback Query

    . . .

    General guidelines for Oracle Flashback Table

    . . .

    • For querying the latest data at a specific time, use a SNA. If you use a timestamp, questioned real time can be up to 3 seconds before the time you specify. Oracle database uses the SNA and assigns them to the timestamps to a granularity of 3 seconds.

    For example, suppose values SNA 1000 and 1005 are mapped on the timestamps 08:41 and 08:46, respectively. A query for a moment between 08:41 and 08:45:59 is mapped to the SCN 1000; an Oracle Flashback Query at 08:46 is mapped to the SNA 1005.

    By reason of this time-to-SNA map, if you specify a time slightly after a DDL (such as a table creation) Oracle database operation can use a SNA which is located just before the DDL operation, causing the error ORA-1466.

    . . .

  • I'm trying to clean up my Start menu but don't want to delete anything, I should not. How can I find programs that are actually needed to start?

    Computer starts slowly. Try to find ways of reorganization and boost performance.

    Hello
     
    Many things contribute to this slowdown to a computer, it could be hardware or software related.
     
    Method 1.
    Computers get slower for various reasons: files become disorganized, unnecessary software consumes resources, readers of network unused slow start or too many programs run automatically at startup. Larger, serious questions can dramatically too slow down your computer's performance. You may have a virus or have need troubleshoot clean start.
    Check to see if the problem exists in Safe Mode, if the computer works as expected in mode without failure, then we can solve the problem in the clean boot state.
    a. refer to the article below for the procedure safe mode in Windows XP
    A description of the options to start in Windows XP Mode
    http://support.Microsoft.com/kb/315222

    b. you need to perform a clean boot to find the program that is causing and then disable or remove.
    How to configure Windows XP to start in a "clean boot" State
    http://support.Microsoft.com/kb/310353/en-us
    Note: When you are finished troubleshooting, follow the steps as explained in the article to reset the computer to start as usual.
     
    Method 2.
    Also, check out the steps that are listed in the articles below and check.
    How to set performance options in Windows XP
    http://support.Microsoft.com/kb/308417
    Restore the performance of your computer with Windows XP
    http://www.Microsoft.com/windowsxp/using/Setup/expert/northrup_restoreperf.mspx
  • How to harvest two images that are overlapping?

    I was hoping someone can help me with this. I Googled it a little and tried different things, but cannot understand this. I don't even think that I have the correct terminology.

    I try to combine the two images. I have attached an image that illustrates what I'm tryng to do - I want to take a common stick figure and cultures so that part of it is hidden and looks like it is coming from a door or a hole. How I get there parts that are outside the door? I know this is probably very simple, but I just can't understand it!

    PORTAL.PNG

    Thanks for any help you can offer me.

    Mary

    Artificial intelligence you have to work with duplicates and slice things, that is to put the part of the dorframe which is originally under the figure, the upper part above and then use a copy of the top to cut the dark areas of the figure with Pathfinder operations or a clipping path.

    Mylenium

  • Table of DB tools list: how to access tables that are in the different SQL database?

    Hi all

    I work on an implementation of database (SQL server) and evaluates the Toolkit OR DB for this project.

    One of the requirements is that I need access to the tables that are in two different database

    (say Table to 1 DB and Table B to 2 DB).

    Our IT guy linked table in DB1 to DB 2 and I verfied this when I use the SQL server management studio.

    When DB 2 tables is filled, table from DB1 is also there. I can also do the same thing using MS Access.

    Table A of the DB1 is available for me enven if I only connect to 2 DB.

    Here comes the problem.

    When I use DB tool list Table.vi to access DB2, it does NOT list A table in DB1. It list only the tables in

    the database (DB2) which I am connection (using DB tool opened Connection.vi with a file DSN)

    So my work around right now is to open a separate connection both DB1 and DB2. However, this approach

    obviously creates a problem when I have to access a separate database constantly in my application.

    What would be a solution to this? I have search the Forum but only to see a post that is somewhat related to

    My question. (And it was published the 2004) Maybe I need to change the code in the orignial VI (DB tool list Table.vi)?

    My computer guy told me that he has not met this scenario since he wrote code in another environment such as

    VB and others and it has always been successful in linking the different database tables.

    I hope my question is clear and healthy because I don't really know much about database terminology.

    Any comment or suggestion is appreciated!

    Thank you

    Chad

    Ok.  Here is some information that I can work with.  Good.

    Your COMPUTER staff created a view called "VISUAL_WORK_ORDER".

    A view isn't a table.  It is a "virtual" table  Views are used to collect data (usually) in several different tables.

    But I guess that the code inside the DB tool list Table.vi returns a list of tables.  Views are not the tables.  Then "VISUAL_WORK_ORDER" does not appear in the list.

    HOWEVER, this should not really matter.  The view is here!  And it can be queried like any table.  So, you can use DB tools Select Data.VI... and wire in "VISUAL_WORK_ORDER" as the name of the table.  This will return the contents of the view.  Alto!

  • How to get data that are created the or before the last Wednesday

    Hi, can someone please tell me how to write a query to retrieve the data that are created the or before last Wednesday.

    Thanks in advance...

    Hello

    Here's one way:

    WHERE created_date< next_day="" (="" trunc="" (sysdate="" )="" -="">

    , "THURSDAY".

    )

    "Before Thursday' means the same as 'the or before Wednesday '.

    This assumes that NLS_DATE_LANGUAGE is English.  If you are not sure what is NLS_DATE_LANGUAGE, you can do this:

    WHERE created_date< next_day="" (="" trunc="" (sysdate="" )="" -="">

    , TO_CHAR (DATE ' 2014-03-06' - or any Thursday)

    , 'DAY '.

    )

    )

    There is nothing magical about March 6, 2014; will do any Thursday.  To_char will return the translation of 'Thursday' in all that is the current NLS_DATE_LANGIUAGE, and NEXT_DAY can use this value.

Maybe you are looking for