Numbers range overlap

Range overlapping
the problem I'd like to solve :
given a table ranges (range_id#,external_key, from, to)
I need to detect overlapping grouping by external key, ie:
range_id external_key from to
------------------------+----
1 A 1 5
     2 A 8 10
     3          A 12 15
     4 A 3 9
     5 B 2 12
     6 B 13 24
     7 B 25 50
I need to detect the overlap in group A because the row #4 overlaps #1
The table contains 10 millions rows and I would like it to be fast, I think a good solution could be coding a aggregation function and use it as follows:
select external_key
from ranges r
group by external_key
having overlaps(from,to) = 1
I am in the process of coding function overlaps and I'll post it here , any ideas about the function overlaps? can you think about a different approach that would perform better?
thanks you for reading.
Miguel Corrales.

Good one Sergey.
To make the concept of read consistency even more clear:
SQL> select count(*),
  2         to_char(min(dt1),'dd.mm.yyyy hh24:mi:ss.ff') as min_dt1,
  3         to_char(max(dt1),'dd.mm.yyyy hh24:mi:ss.ff') as max_dt1,
  4         to_char(min(dt2),'dd.mm.yyyy hh24:mi:ss.ff') as min_dt2,
  5         to_char(max(dt2),'dd.mm.yyyy hh24:mi:ss.ff') as max_dt2,
  6         to_char(min(dt3),'dd.mm.yyyy hh24:mi:ss.ff') as min_dt3,
  7         to_char(max(dt3),'dd.mm.yyyy hh24:mi:ss.ff') as max_dt3,
  8         to_char(min(dt4),'dd.mm.yyyy hh24:mi:ss.ff') as min_dt4,
  9         to_char(max(dt4),'dd.mm.yyyy hh24:mi:ss.ff') as max_dt4
10   from (select systimestamp as dt1, systimestamp as dt2, systimestamp as dt3, systimestamp as dt4
11           from dual connect by level <= 1000000)
12  /
                              COUNT(*)
MIN_DT1
MAX_DT1
MIN_DT2
MAX_DT2
MIN_DT3
MAX_DT3
MIN_DT4
MAX_DT4
                               1000000
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
18.07.2008 11:24:49.029804
1 row selected.Regards,
Rob.

Similar Messages

  • Division wise Separate numbering range required for invoices

    Hi Gurus,
    The requirement is Division wise Separate numbering range required for invoices. For e.g  like 11 Steel Fabrication, 12 Aluminum Fab, 13 Carpentry & Join, 14 GRP/GRC, 15 Stone & Marble
    Already a table ZSD_NUM_RANGE with fields like Client, Plant, Number range in the case of internal number assignment
    Presently number range is based on plants.
    I understand that Division field SPART is to be included in this table by using the exit given below:
    User Exit For Billing
    USEREXIT_NUMBER_RANGE (Module pool SAPLV60A, program RV60AFZZ)
    The internal number range used in the standard system is specified in the billing type table and can be changed in this user exit. This user exit is only called when the billing documents is created.
    May I know how far this is feasible to shift plant wise no. range to division wise no. range.?
    Also if we do division wise number range, How about shifting to new invoice numbers in the middle of the FISCAL year?
    Kindly revert back to me at your earliest.
    Regards,
    Anbu

    Dear Anbu
    Ideally speaking, invoice number range should be per plant and the user exit what you had indicated holds good.  May be you can try with the same user exit.
    thanks
    G. Lakshmipathi

  • Delivery and Invoice Numbering range

    Hi Friends
    Delivery and Invoice Numbering range Plant Wise.
    1. I have one Company Code Many Plant. Whenever i am creating the Delivery and Invoice, i should want different Numbering range of Delivery Number and Invoice Numbers. So that i can understand that these invoice raised from particular plants
    Regards,
    Udhay

    HI
    To achieve this you have to for Development using Userexits in MV50AFZZ and RV60AFZZ respectively for Delivery and Billing.
    Create a ZTales and maintain the list of Plants and the corresponding Number ranges.
    Then the system takes the  Number corresponding to that plant in the document under creation, from the list in Ztable.
    Thanks,
    Ravi

  • IN: int a, int b; OUT:Vector filled with numbers ranging from a to b

    Hello,
    is there any method to fill in a vector with numbers ranging from a value "a" to value "b"? Of course it can be done using a for-loop, but I was wondering if there is not a simpler way to do it. Thanks for your advices.
    Example:
    INTPUT:
    int a = 4;
    int b = 9;
    Vector seq = new Vector();
    seq.setSize(b-a);
    OUTPUT:
    pseudocode: seq = {4,5,6,7,8,9};

    Darryl.Burke wrote:
    Hmmm.. what happens when the other methods of AbstractList are invoked on an instance of IntRangeList? Wouldn't you need to override pretty nearly all the methods for consistency? And some methods, like remove and set, would have to throw a UnsupportedOperationException.If you read the API documentation of AbstractList then you could find out that you could implement a fully functional, fully compliant (unmodifiable) List implementation by just providing size() and get(int). All other accessor methods (including subList() and iterator()) will be using those two methods and fully work.
    Writing a loop to populate a simple ArrayList would be trivial by comparison :-)Indeed, but if it's needed often and with big ranges, then there's no loss in using this implementation.
    db
    edit In fact, extending AbstractList appears irrelevant as none of the features of AbstractList are used. The IntRangeList, in fact, is-NOT-a AbstractList but just fakes it in respect of the 2 methods overridden in your code sample.What? All the features are used. Read the API doc. If I handn't extended AbstractList, but instead implemented List directly, then I'd have to implement all the methods myself (including an Iterator, which, while trivial in this case, can be non-fun to implement correctly).

  • Billing Number Range /Sales Documents Numbering Range

    HI Friends
    HI Friends
    I would like to control Numbering Range  Year Wise  Like 2008-2009 Should be Started Numberings Range From  10000000 TO  2000000 (2008-2009) , 30000000 TO 40000000 (2009-2010) Automatically. How we can control in this scenario.
    Regards,
    Udhay

    Unlike FI (RF_BELEG) and Excise (CIN),  in SD (RV_BELEG) fiscal year is not part of the number range.
    Your requirement is not possible as such.
    During closing you can change the last number to, say 199999, so the next document fetches the number 200000. But the user can make a document in year 2009-10 with document date in 2008-09.

  • TIPS(46) : ROWNUM(ORDERING 순으로 NUMBERING, RANGE SELECT)

    제품 : SQL*PLUS
    작성날짜 : 2003-07-30
    TIPS(46) : ROWNUM(ORDERING 순으로 NUMBERING, RANGE SELECT)
    =========================================================
    PURPOSE
    Explanation
    SQL*PLUS에서 ORDERING 순으로 NUMBERING하기를 원하는 경우가 많으나,
    ORDERING이 되기 전에 RANDOM ACCESS 시
    ROWNUM이 ASSIGN되기 때문에, 다음과 같은 결과가 나타날 것이다.
    SQL> select ename, rownum from emp;
    ENAME ROWNUM
    ALLEN 1
    JONES 2
    BLAKE 3
    CLARK 4
    KING 5
    ADAMS 6
    JAMES 7
    FORD 8
    SQL> select ename, rownum from emp order by ename;
    ENAME ROWNUM
    ADAMS 6
    ALLEN 1
    BLAKE 3
    CLARK 4
    FORD 8
    JAMES 7
    JONES 2
    KING 5
    Example
    다음의 몇 가지 방법을 이용하여 ORDERING 순으로 NUMBERING을 나타내어 보자.
    1) RECORD를 COUNT하는 방법 (DATA가 많은 경우 부적절)
    SQL> select A.ename, count(*) position
    2 from emp A, emp B
    3 where A.ename > B.ename
    4 or A.ename = B.ename and A.empno >= B.empno
    5 group by A.empno, A.ename
    6 order by A.ename, A.empno;
    ENAME POSITION
    ADAMS 1
    ALLEN 2
    BLAKE 3
    CLARK 4
    FORD 5
    JAMES 6
    JONES 7
    KING 8
    2) INDEX를 이용하는 방법
    SQL> create index sort_ix on emp (ename);
    Index created.
    SQL> select ename, rownum from emp where ename > ' ';
    ENAME ROWNUM
    ADAMS 1
    ALLEN 2
    BLAKE 3
    CLARK 4
    FORD 5
    JAMES 6
    JONES 7
    KING 8
    cf) descending인 경우 아래처럼 hint 사용 바람
    select /*+ index_desc(emp ename_ix) */
    ename, rownum from emp
    where ename > ' ' and rownum < 4;
    3) OPTIMIZER를 이용하는 방법
    SQL> select rownum, ename
    2 from emp , dual
    3 where emp.ename = dual.dummy (+);
    ROWNUM ENAME
    1 ADAMS
    2 ALLEN
    3 BLAKE
    4 CLARK
    5 FORD
    6 JAMES
    7 JONES
    8 KING
    위에서 언급한 내용에 더해서 rownum을 where 절에 사용함에 있어서는
    rownum 1을 포함하는 range(예 : 'where rownum <= 100')에 대해서만
    정상적인 조회가 가능하다.
    만약 rownum 1을 포함하지 않는 range(예 : 'where rownum between 50 and 100')
    에 대한 자료 조회를 원한다면 다음과 같이 in-line view를 이용하는 방법을
    사용할 수 있다.
    select rn, ename
    from ( select rownum rn, ename
    from emp)
    where rn between 3 and 5 ;
    RN ENAME
    3 BLAKE
    4 CLARK
    5 KING
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 VIEW
    2 1 COUNT
    3 2 TABLE ACCESS (FULL) OF 'EMP'
    * 이 때 in-line view의 rownum에는 반드시 alias를 이용해야 한다.
    in-line view에 의해서 선택되어지는 data가 많다면 performance가
    떨어질 수 있다.
    Reference Documents
    -------------------

    제품 : SQL*PLUS
    작성날짜 : 2003-07-30
    TIPS(46) : ROWNUM(ORDERING 순으로 NUMBERING, RANGE SELECT)
    =========================================================
    PURPOSE
    Explanation
    SQL*PLUS에서 ORDERING 순으로 NUMBERING하기를 원하는 경우가 많으나,
    ORDERING이 되기 전에 RANDOM ACCESS 시
    ROWNUM이 ASSIGN되기 때문에, 다음과 같은 결과가 나타날 것이다.
    SQL> select ename, rownum from emp;
    ENAME ROWNUM
    ALLEN 1
    JONES 2
    BLAKE 3
    CLARK 4
    KING 5
    ADAMS 6
    JAMES 7
    FORD 8
    SQL> select ename, rownum from emp order by ename;
    ENAME ROWNUM
    ADAMS 6
    ALLEN 1
    BLAKE 3
    CLARK 4
    FORD 8
    JAMES 7
    JONES 2
    KING 5
    Example
    다음의 몇 가지 방법을 이용하여 ORDERING 순으로 NUMBERING을 나타내어 보자.
    1) RECORD를 COUNT하는 방법 (DATA가 많은 경우 부적절)
    SQL> select A.ename, count(*) position
    2 from emp A, emp B
    3 where A.ename > B.ename
    4 or A.ename = B.ename and A.empno >= B.empno
    5 group by A.empno, A.ename
    6 order by A.ename, A.empno;
    ENAME POSITION
    ADAMS 1
    ALLEN 2
    BLAKE 3
    CLARK 4
    FORD 5
    JAMES 6
    JONES 7
    KING 8
    2) INDEX를 이용하는 방법
    SQL> create index sort_ix on emp (ename);
    Index created.
    SQL> select ename, rownum from emp where ename > ' ';
    ENAME ROWNUM
    ADAMS 1
    ALLEN 2
    BLAKE 3
    CLARK 4
    FORD 5
    JAMES 6
    JONES 7
    KING 8
    cf) descending인 경우 아래처럼 hint 사용 바람
    select /*+ index_desc(emp ename_ix) */
    ename, rownum from emp
    where ename > ' ' and rownum < 4;
    3) OPTIMIZER를 이용하는 방법
    SQL> select rownum, ename
    2 from emp , dual
    3 where emp.ename = dual.dummy (+);
    ROWNUM ENAME
    1 ADAMS
    2 ALLEN
    3 BLAKE
    4 CLARK
    5 FORD
    6 JAMES
    7 JONES
    8 KING
    위에서 언급한 내용에 더해서 rownum을 where 절에 사용함에 있어서는
    rownum 1을 포함하는 range(예 : 'where rownum <= 100')에 대해서만
    정상적인 조회가 가능하다.
    만약 rownum 1을 포함하지 않는 range(예 : 'where rownum between 50 and 100')
    에 대한 자료 조회를 원한다면 다음과 같이 in-line view를 이용하는 방법을
    사용할 수 있다.
    select rn, ename
    from ( select rownum rn, ename
    from emp)
    where rn between 3 and 5 ;
    RN ENAME
    3 BLAKE
    4 CLARK
    5 KING
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 VIEW
    2 1 COUNT
    3 2 TABLE ACCESS (FULL) OF 'EMP'
    * 이 때 in-line view의 rownum에는 반드시 alias를 이용해야 한다.
    in-line view에 의해서 선택되어지는 data가 많다면 performance가
    떨어질 수 있다.
    Reference Documents
    -------------------

  • Multi numbering range into Purch.order type

    Dear All,
    I need to maintain multi numbering range into one Purch.order type.
    e.g.
    Purch.Order type: 90NB
    company : A
    Number range: 9100000000
    company : B
    Number range: 3000000000
    company : C
    Number range: 3100000000
    Is there anybody advice me?
    Thanks & B.Rgds
    Bishnu
    02/06

    Hi
    In standard sap, it is not possible to maintain different number range for same document type in different company codes.
    try if any enhancement possible or not?
    Regards,
    Raman

  • Validate date range overlapping

    Hello all. I am trying to write a code which checks if the date does not overlap. For example, in my form I have id, from_date (mm/dd/yyyy), to_date (mm/dd/yyyy).. what i am trying to do is, the dates must not ovelap for particular id..
    Sample:
    id | from_date | to_date
    1 | 01/01/2012 | 01/31/2012
    1 | 04/01/2012 | 04/30/2012 --> this must be allowed
    2 | 01/15/2012 | 01/15/2012 --> this must also be allowed as id differs
    1 | 01/15/2012 | 01/15/2012 --> this must not be allowed because for id=1, 15th Jan is overalapping with the 1st row's date range (1st Jan to 31st Jan).
    PS : I dont want to use DB trigger, but rather write a code in Backing bean
    (I will let you know what code i tried so far, if needed)
    Edited by: 925715 on Apr 5, 2012 3:36 AM

    Assalaam Alaikum Jabr. thankss for the reply. For some reason it doesn't seem to work. I tried to create a validation method, at Entity level and also at Attribute level in Entity class of detail table. it is committing all the dates. Any ways, i will check again, if I am missing something here. And, must the validator be created at entity or attribute level??
    Edited by: 925715 on Apr 7, 2012 4:32 PM

  • While Updating Item master 1250000088 - Date ranges overlap; change the active or inactive date range

    hi.
    i am updating item master.
    just i am trying to update to inactive from active
    i allready given the date ranges
    but above error is comming..
            Dim vItem As SAPbobsCOM.Items
                        Dim RetVal As Long
                        Dim ErrCode As Long
                        Dim ErrMsg As String
                        vItem = ocompany.GetBusinessObject(BoObjectTypes.oItems)
                        'Retrieve a record by its key from the database
                        RetVal = vItem.GetByKey(Icode)
                        '' vItem.UserFields.Fields.Item("U_Status").Value = "Sold"
                        vItem.Frozen = BoYesNoEnum.tYES
                        vItem.FrozenFrom = "09/02/2014"
                        vItem.FrozenTo = "09/02/2014"

    hi.
    Thanks for your reply..
    overlapping ..means
         'Retrieve a record by its key from the database
                        RetVal = vItem.GetByKey(Icode)
                        '' vItem.UserFields.Fields.Item("U_Status").Value = "Sold"
                        vItem.Frozen = BoYesNoEnum.tYES
                        vItem.FrozenFrom = "09/02/2014"
                        vItem.FrozenTo = "09/02/2014"
        vItem.FrozenFrom = "09/02/2014"
          vItem.FrozenTo = "10/02/2014"
    i all ready tried  above  two ways.. given date same and given two  diff dates....
    but the same Error is comming..
    Any info.plz update me..

  • Fbn1 number range overlap

    hi all,
    we are updating the number range for the fiscal year in FBN1 where we are getting the error message  as ENTER INTERVALS WITHOUT OVERLAP
    no              year        from                to  
    20                  2008          2008000000                    2008999999
       20                     2009          2009000000                    2009999999
    year 2011 and  2012 2013 not used
        20                     2014          2014000000                   2014999999   here its showing the error ENTER INTERVALS WITHOUT OVERLAP
    kindly help how to solve this problem
    thanks and regards,
    chethan

    Hi
    In table NRIV, give object name as RF_BELEG, Subobject value as company code. Sort entries in ascending order of "From number" and check the overlapping entry.
    In FBN1 when you add interval use F4 for "from" field there you will be able to see non-overlapping entries and available options. If this doesn't help you to identity overlapping number range, then select any available number range, save. Then go to added number range try changing it there, when you try to save it there, it will display all overlapping entries.
    Regards
    Aniket

  • Number range overlap

    Dear all,
    when i am maintaining the number range for remittance challan getting error "enter number range with out overlap".
    even i have not maintained any number range related to TDS
    Please suggest
    Regards,

    Hi Priya,
    check number group and year
    Best Rgds
    Suma

  • PSL Serial Numbers Range

    Hi Friends,
    Does anyone know if we can define exceptions in the serial number range defined in PSL
    Scenario is this:
    In PSL when u are creating the Engineering change, you usually define the range of serial numbers in the objects list to mention that all the serial numbers listed are covered under that change.
    Question is:
    Do we have an option to exclude some numbers in the range,, lets say the range of serial numbers is 1-1000 can we say 586 and 654 are not included in the range
    Please help ,, I will reward points immediately
    Thanks
    Raj

    Hi abhi,
    First sort the internal table.
    Create an local variable to store next serial number that should be in sequence.
    Now iterate through each record in internal table.
    LOOP AT itab INTO wa.
      IF sy-tabix <> 1.
        " Check if the numbers are in sequence
         IF lv_next = wa-serial_no.
            * Write your logic 1*
        ELSEIF lv_next NE wa-serial_no.
            * Write your logic 2*
         ENDIF.
    ELSE.
         * Write your logic 1 *
      ENDIF.
       " Store the next number to be in sequence
      lv_next = wa-serial_no + 1.
    ENDIF.
    Hope this will helps you.
    Regards,
    Satish

  • How to use different  numbers ranges in LSMW for a material in 8plants

    Hi all,
    I have to upload data using MM01 in LSMW by using external numbers.
    the MATNR for materials are like this 17240,22818,82618,487218,7218,26418
    how can i take these numbers in LSMW.i have 61 material numbers to be extended to 8plants.can i upload these material numbers at a time in LSMW
    the above material number should be extended to 8plants.but the field values for some fields are varying.the material number should be same for 8plants
    For this issue, which method i should follow in LSMW.

    Just do one thing,
    while recording enter the material numer field by yourself(Not blank).This material is the material which you mention out of 61,
    and upload the same in your upload file, and just change plant.i mean 8 records are there for each material( all 61)
    reward if useful.
    Amit Singla

  • When to use primitive numbers range

    Hi
    I am a noob and was just wondering in what programming situations I would use javas various number primitives e.g. int, double, byte, long, short, float.
    The only situations I have used numbers is:
    int - to represent whole numbers
    double - to represent decimals, real life example would be prices
    Can anyone give me real life examples of where I might use the other number primitives?
    Many thanks

    Can anyone give me real life examples of where I
    might use the other number primitives?Actually to use double (or floating points in general) for currency isn't such a good idea because of rounding problems. An integral type like int or long is a much better alternative for handling "prices".
    Floats are often used in graphics applications because it's the "natural" floating point type in OpenGL.
    Say you need to store a huge number of integers in an array. You can cut the memory requirements in half by using shorts instead of ints.
    So I'd say all primitives have their uses but int and double are probably the most frequently used. If you standardize on them you also avoid implicit conversions in expressions which makes life a lot easier.

  • How can I make this in labview : find the numbers of overlapping between bits

    Dear
    I have this problem it really so complex to solve for me
    its not home work its related to my academic research
    I have two stream of bits each one with fixed n bits length as follow:
    x=1,1,1,1,0,0,0,0
    y=1,1,1,0,0,0,0,0
    I need to extract the following information
    a1, the number of overlapping 1s:in this case is 3
    a2, the number of overlapping 1s of X and 0s of Y :in this case is 1
    a3, the number of overlapping 0s of X and 1s of Y:in this case is 0
    a4, the number of overlapping 0s on both x,y.:in this case is 4
    thank in advance
    best regards
    hi ?Q>
    Solved!
    Go to Solution.

    alexderjuengere wrote:
    just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.
    Alex, I think the idea was a binary representation, not a decimal array of 1's or zeros:
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    checkbits.png ‏8 KB

Maybe you are looking for

  • Problem with Syslog in Solaris 10

    I have 2 hosts (both are actually Solaris 10 Zones). One has no issues with syslog and the other won't send its messages to our loghost. Both have the same /etc/syslog.conf files, /etc/resolv.conf and /etc/nsswitch.conf files. The one works and the o

  • Open Authorization Objects in role after role Transport

    Hi All, I have transported a R/3 (ECC6, support) role from Dev to QA and Dev (Multiple clients). After transport, Role has authorization tab with status (green) but when i display authorization data i found one new open authorization object (yellow).

  • Is there a program that can delete duplicate emails

    I was doing a sync on my MBP and got panic when all my emails in my inbox disappeared. I quickly jumped on my iMac and made a duplicate copy of my inbox only to have it copy all of them back into my inbox. Short of the long I now have 11,000 duplicat

  • Retrieve the hided source code

    hi all.        I have hided the source code of a program by appending the program to a internal table and inserting   '*@#@@[SAP]'  to the internal table at in dex one its working well. My task is to retrieve the hided source code of the program in t

  • Driver help after format from Windows 8 to 7(64bit)

    Hello all! My laptop was having issues, and I have been wanting to convert back to Windows 7 for a while and took this time to go ahead and make the chage. After finishing I found that I didn't have the original drivers to get the basics up and runni