Comparing a sequence of numbers

Morning Everyone,
I have a little challenge on board and would like to have some ideas about how to proceed with it.
As you all are aware of the Lotto game. u have to choose 6 numbers out of 40. There are exactly 3,838,380 combinations that can be played.
these combinations can be generated and stored in a table.
Now lets say i have 1000's people playing and i would like to find a way to know how many combinations are repeating and also what combinations have not been played.
How can i do that?
Kind Regards
Kevin

Billy Verreynne wrote :
The universe does not keep a scoreboardWell, actually, you cannot prove that. Maybe it does...
:D
To the OP.
I think you can generate the table containing all possible combination using the following query (assuming that you cannot chose the same number twice) : with b as (select level n from dual connect by level <=40)
select count(*)
from (
select
b1.n,
b2.n,
b3.n,
b4.n,
b5.n,
b6.n
from b b1, b b2, b b3, b b4, b b5, b b6
where
b6.n>b5.n
and b5.n>b4.n
and b4.n>b3.n
and b3.n>b2.n
and b2.n>b1.n
/I just ran the count(*) on the query and it brings me 3838380 rows, as expected.
the query gives each row with the 6 different values in ascending order (1st column being < than 2nd, being < than 3rd, and so on).
If you want to compare with played combination, you should make sure you store those combination the same ways (col1 < col2 < col3 ...) using a constraint on the table.
SQL> create table possible_combinations (
  2  c1 integer not null,
  3  c2 integer not null,
  4  c3 integer not null,
  5  c4 integer not null,
  6  c5 integer not null,
  7  c6 integer not null,
  8  primary key (c1,c2,c3,c4,c5,c6)
  9  );
Table created.
SQL> alter table possible_combinations add constraint asc_ordered check (c6>c5 and c5>c4 and c4>c3 and c3>c2 and c2>c1);
Table altered.
SQL> insert into possible_combinations
  2  with b as (select level n from dual connect by level <=40)
  3  select
  4  b1.n,
  5  b2.n,
  6  b3.n,
  7  b4.n,
  8  b5.n,
  9  b6.n
10  from b b1, b b2, b b3, b b4, b b5, b b6
11  where
12  b6.n>b5.n
13  and b5.n>b4.n
14  and b4.n>b3.n
15  and b3.n>b2.n
16* and b2.n>b1.n;you can then create another table that store the played combinations :
SQL> create table played_combinations(
  2  userid integer not null,
  3  dateplay date not null,
  4  c1 integer not null,
  5  c2 integer not null,
  6  c3 integer not null,
  7  c4 integer not null,
  8  c5 integer not null,
  9  c6 integer not null);
Table created.
SQL> alter table played_combinations add constraint playordered check (c6>c5 and c5>c4 and c4>c3 and c3>c2 and c2>c1);
Table altered.You can easily get :
- the number of time a combination was played :select c1, c2, c3, c4, c5, c6,
count(*) Nbr_of_time_played,
trunc(100*count(*)/(select count(*) from played_combinations),3) pct_of_played
from played_combinations
group by c1, c2, c3, c4, c5, c6
order by count(*) desc;-the list of combinations that were never played :select t.c1, t.c2, t.c3, t.c4, t.c5, t.c6
from possible_combinations t
where not exists (select null
from played_combinations p
where t.c1=p.c1
and t.c2=p.c2
and t.c3=p.c3
and t.c4=p.c4
and t.c5=p.c5
and t.c6=p.c6
);

Similar Messages

  • Strange display of a long sequence of numbers - Should I press OK ?

    From type to time my iphone displays a long sequence of numbers and waits for me to press a green "OK" button. For example last sequence starts with 1259752976 1 199.664277......
    Anybody knows what's going on ?

    Yolanda,
    Yolanda Arroyo wrote:
    Hi folks,
    I have problems with my Tuxedo cofiguration using domains.
    I have Tuxedo8 installed in Linux 7.1. It connects to an Oracle 8.1.7 database,
    and has 2 domains cofigured to connect to a remote domain. (this domain is in
    fact WebLogic Server 6.1 running in the same machine)
    If I run this configuration, the servers in LDOM2 (for example, server1) are not
    able to connect to the database (this group don't include a TMS because is
    associated with the domain, and I cannot put an OPENINFO information in that
    group, for the same reason)
    BUT!!!! the most amazing thing is that, if I make no changes in the bdmconfig
    file, and in the UBBCONFIG I change the group WTC2 for a group that contains a
    TMS, in this way:
    I think that you are confusing the purpose of the 2 config files, ubbconfig and
    dmconfig.
    You should configure you application servers in the ubbconfig file. They
    should be in server groups configured with the correct TMS servers, OPENINFO, etc.
    One you have done this, you have a single domain.
    To extend this to talk to external domains, now you need to configure the gateways.
    Add a new server group to your ubbconfig and configure the domain gateway
    processes (GWADM, DMADM, GWTDOMAIN) in it. This group does not need a TMS (TMS
    services are provided by the domain gateway) or any OPENINFO.
    Now, write a dmconfig file. This does not reference any servers it does
    reference services that you want to import from other domains, or export to them.
    I hope this explains how you can successfully get your configuration working...
    Regards,
    Peter.

  • Compare two sequences loaded in a C# code module.

    Hi,
    Is it possible to compare two sequences loaded in a C# code module using functionality from the TestStand API?
    Best regards

    Hello,
    Here you can find a related post:
    http://forums.ni.com/ni/board/message?board.id=330&message.id=26058&requireLogin=False
    Let me know if you have further questions or if this doesn't help you.
    Kind Regards,
    Thierry C - Applications Engineering Specialist Northern European Region - National Instruments
    CLD, CTA
    If someone helped you, let them know. Mark as solved and/or give a kudo.

  • Cryptic sequence of numbers as sender name for invitations

    When I want to send an calendar invitation to my business address, my sender name is a cryptic sequence of numbers instead of "first name last name". These are the steps:
    1. Receiving Email form my iPad with the invitation
    2. Download the attached ics to my desktop of the windows PC
    3. Drag&Drop the ics to the Lotus Notes Calendar
    4. The invitation is visible, the sender name is i.e. 2fjfu3oodsjdf90499fj993efj0ßßejfefjß39eß939hgsdlfnasdäfa9e9
    I know that this invitation is from my private account. But what about friends I wanted to invite? Or should I invite only friends with apple equipment?!?! ;-)

    Well,
    Nokia MfE doesn't reply to my mails. I guess that only poeple using MfE v 2.09.158 who are not registered to the MfE Service (I guess you have to pay a monthly fee as it is with the Blackberry service) have the sender name problem. Of course you can use MfE with other mail providers than Nokia MfE. But in this case "Mail for Exchange" will appear as sender name.
    I now switched over to MfE's competitor "RS" and don't have this annoying problem anymore. The alternative to RS would be using the old MfE version where I didn't have that sender name prob. But as my battery was empty after 15 hrs using the old MfE version (with RS my battery lasts 3 days !!!) there is no real alternative to RS!
    This sender name problem seems to be part of Nokia's business strategy. As they want to compete with Blackberry they want you to register (and pay the MfE mail service monthly). Probably that's the reason why you get MfE for free (RS costs 50 US$).
     Any comments on my theory?!
    BR, Johnny

  • Comparing Bit Sequences - O - Bits are One

    Hi Gurus,
    I need an info on Comparing Bit Sequences, for example O operator - Bits are One.
    An ABAP code piece from Include LBZFCF01; Form BMASKE_TO_FTAB looks like this:
      IF <b> O hex01. ftab-inp = on. ENDIF.
      IF <b> O hex02. ftab-req = on. ENDIF.
      IF <b> O hex04. ftab-out = on. ENDIF.
      IF <b> O hex08. ftab-act = on. ENDIF.
      IF <b> O hex16. ftab-int = on. ENDIF.
      IF <b> O hex32. ftab-inv = on. ENDIF.
    Now I would like to know; whether this is bit wise equivalent XOR operation.
    II need to do the similar comparison in SAP BO Data services.
    Please help.
    Best Regards, Murugesh

    *

  • How to compare consecutive groups of numbers in arrays

    Hi
    I require to place the solution into a 1D array.
    I need to compare two arrays and save the same numbers that are in both arrays but also save groups of numbers that may be in only one of the two arrays being compared.
    In the example l have not been able to place all consecutive groups of numbers 8,9,10,11,12 into a 1D array.
    In the example l need to filter out the zeros and the number four.
    The numbers in both arrays are always in descending order however may not be in the order of index number of array. That is 15 = 15 index number
    A consecutive group of numbers in this example is a group that increase by a value of 1. E.g.. 8,9,0,22,23,24 are two consecutive groups of numbers.
    Thank  you
    Solved!
    Go to Solution.
    Attachments:
    Compare numbers and consecutive numbers in arrays.vi ‏17 KB

    Hi Lynn
    I did have a look at the consecutive array solution. I have looked and looked l thought l knew how it worked but after a number of separate evaluations with other code l have failed. I am just glad it works. With the consecutive array solution l tried today my own code but l lost either the first number of the last number of a consecutive group of numbers.
    I may have confused you but in doing so you have provided a real different view which l am very grateful. You have viewed the consecutive number problem as just a single 1D array problem. By doing this you have opened my eyes to another way to do the job and a way to handle this type of data. However l am also comparing two arrays. For example l have to pick up say two equal values in two columns that the consecutive array does not detect and then correctly locate a value in the final array if the value is not in the final array.
    What l have not told you is also l have to be able to identify groups of numbers in two 1D arrays. E.g... Array 1 has 1,2,9,10 next array has 9,10 the final array ends up 9,10 when l would like 0,9,10. When viewing numbers by rows later on l can then detect with a array length vi the length of the 1,2 groups of numbers over a large number of columns. If 9,10 jumps to the front it becomes a wrong length. This is actually my main problem which has caused me a large amount of extra programming. I have gone back to basics to see what l can do differently and you have provided the first clue with the consecutive array. I placed it in my main program today and it filtered a lot variable data which l could not remove without losing real data. The main data lost in your solution was the say 17 number in two columns which in an image is a horizontal line. I know what l have just provided you in this paragraph is all new information but it provides a background as to what l am up to. I am getting pixel data from a 2D array and comparing +1 index 1D array with a normal array. This way l can view the data of the next column to see if there is a pattern. I am actually trying to program an array as how humans view objects in images.
    I will have another go at integrating your solution next week
    Regards
    Michael

  • Generating a sequence of numbers

    Hi there, I'm trying to generate a number sequence. The description is as follows:
    a)1 is in the sequence
    b) If number X is in the sequence then so are the numbers 3*X, 5*X, and 7*X.
    c) No number appears more than once in the sequence, and
    d) No other number is in the sequence.
    Thus, first few numbers in the sequence are:
    1,3,5,7,9,15,21,25,27,35,45,49,63,75,81,105...
    I need to print out the first 1000 elements of this sequence which is fairly large.
    How can i compute this sequence and print the first 1000 elements of this sequence? I think that we need 3 separate methods, 1 for 3*X, 5*X and 7*X. Can anyone out there help me with this?

    The following code is in ML (because that's what I did this in for an exercise in my first year). datatype stream = Item of int * (unit->stream);
    fun cons (x,xs) = Item (x,xs);
    fun head (Item(i,xf))=i;
    fun tail (Item(i,xf))=xf();
    fun maps f xs = cons(f (head xs), fn()=> maps f (tail xs));
    fun merge (xs,ys)=
        let val x = head (xs);
            val y = head (ys)
        in if x=y then cons(x, fn()=>merge((tail(xs)), (tail (ys))) )
           else if x<y then cons(x, fn()=>merge((tail(xs)), ys) )
                else cons(y, fn()=>merge(xs,(tail(ys))) ) end; (* y<x *)
    fun merge3(xs,ys,zs) = merge(xs,merge(ys,zs));
    fun threefiveseven()=
        cons(1, fn()=>
             merge3( maps (fn x=> 3*x) (threefiveseven()),
                     maps (fn x=> 5*x) (threefiveseven()),
                     maps (fn x=> 7*x) (threefiveseven()) )); Translating into Java elegantly isn't easy, because Java doesn't have function pointers. It took me quite a while, because it's difficult to avoid infinite recursion. (That's what the unit->stream and fn()=> is all about). Here you go: abstract class Function
        abstract int f(int i);
    class Maps extends Stream
        Function f;
        Maps(Function f, Stream xs)
            this.head = f.f(xs.head());
            this.tail = xs;
            this.f = f;
        Stream tail()
            return new Maps(f, tail.tail());
    class Merge extends Stream
        Stream xs;
        boolean tailxs;
        Stream ys;
        boolean tailys;
        Merge(Stream xs, Stream ys)
            int x = xs.head();
            int y = ys.head();
            this.xs = xs;
            this.ys = ys;
            if (x == y)
                head = x;
                tailxs = true;
                tailys = true;
            else if (x < y)
                head = x;
                tailxs = true;
                tailys = false;
            else
                head = y;
                tailxs = false;
                tailys = true;
        Stream tail()
            Stream left = (tailxs) ? xs.tail() : xs;
            Stream right = (tailys) ? ys.tail() : ys;
            return new Merge(left, right);
    abstract class Stream
        int head;
        int head() { return head; }
        Stream tail;
        abstract Stream tail();
    public class Test
        public static void main(String[] args)
            printFirst(new ThreeFiveSeven(), 10);
        static void printFirst(Stream stream, int n)
            while(n-- > 0)
                System.out.println(stream.head());
                stream = stream.tail();
    class ThreeFiveSeven extends Stream
        ThreeFiveSeven()
            head = 1;
        Stream tail()
            Stream three = new Maps(new Times3(), new ThreeFiveSeven());
            Stream five = new Maps(new Times5(), new ThreeFiveSeven());
            Stream seven = new Maps(new Times7(), new ThreeFiveSeven());
            return new Merge(three, new Merge(five, seven));
    class Times3 extends Function
        int f(int i) { return 3 * i; }
    class Times5 extends Function
        int f(int i) { return 5 * i; }
    class Times7 extends Function
        int f(int i) { return 7 * i; }
    }

  • Find gaps in sequence of numbers

    Hi,
    I'm trying to scan through multiple records containing millions of numbers. What I need to do is to print out the numbers that are sequential as such:
    If the record contains a sequence like this:
    46859995600
    46859995699
    And there is no breakage in that sequence, then print:
    46859995600 100
    If that sequence is broken somewhere, then print series of 10 that are sequential, f.e:
    46859995600 10
    46859995620 10
    46859995630 10
    I already have a bash script for this, but it's way too slow. If anyone can help me out I'd be very grateful, perhaps a "awk" solution.
    Thanks!

    Indeed.  Also, note that the code above makes several assumptions: 1) monotonicity ... but "sort" can take care of that; 2) there is no zero.  This would be easy to fix, but in the first draft I didn't bother with it: 000-009 will not currently be counted; 3) the application is not mission critical; 4) there are no blank line; 5) each line contains *only* the number.
    On #3, my code may be faster, but it hasn't been checked for accuracy.  Be sure to test for accuracy before trusting its output.  In fact, I just tested it ... it failed.
    I tested it after I recoded it in C.  The speed went from 2min 3sec to 0.39sec ... that's nice.  But the results file was *much* smaller.
    The results from the bash version includes several duplicates, and some erroneous inclusions.  Given that so far the C version seems more accurate (but still needs testing) and *much* faster, I'd go with patching this up further:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    unsigned long lt = 0, lh = 0;
    unsigned long n, prev = 0, tens[10];
    int nten=0;
    void check_tens() {
    int i;
    if (lh) printf("%lu 100\n",lh);
    else for (i = 0; i < 10 && tens[i]; i++)
    printf("%lu 10\n",tens[i]);
    memset(tens,0,10*sizeof(unsigned long));
    nten = 0;
    int main() {
    int i;
    memset(tens,0,10*sizeof(unsigned long));
    while (fscanf(stdin,"%lu\n",&n) == 1) {
    if ((n % 10) == 0) lt = n;
    else if ((n % 10) == 9) {
    if (!lt || n - 9 == lt) tens[nten++] = lt;
    lt = 0;
    if ((n % 100) == 0) lh = n;
    else if ((n % 100) == 99) check_tens();
    if (n - prev != 1) {
    lt = lh = 0;
    for (i = prev; i < n; i++)
    if ((i % 100) == 99) { check_tens(); break; }
    if ((n % 10) == 0) lt = n;
    if ((n % 100) == 0) lh = n;
    prev=n;
    lh = 0;
    check_tens();
    return 0;
    EDIT: I can actually confirm the C version is not yet accurate.  ARGH!
    Last edited by Trilby (2014-05-02 00:11:09)

  • Trouble with SEQUENCE, loosing numbers

    Hi all, I use a sequence to generate the number of an invoice like this:
    Insert into table
    values(owner.sequence_name.nextval);
    But, if an error occurs this number get lost because of the way the sequence works, how can I avoid this??, there is another way to do it??? It doesnt matter if that solution doesn't use the sequence, but my design cannot accept numbers like 1,3,4,5,7, it has to be 1,2,3,4,5,6,7....
    Leo
    null

    Unfortunately, this is another one of those concepts that sounds simple but isn't.
    Yours is not an Oracle (or any other DB) problem; it is a design problem.
    The reason that none of the suggested alternatives solve your problem is that there are undefined elements in your requirements.
    There are actually two aspects to your of problem: 1) generating unique sequential numbers and 2) using those numbers.
    I would suggest starting over and try to clearly define the problem and the requirements.
    For example your stated requirements appear to be something like:
    1. Invoice numbers must to be unique
    2. Invoice numbers must be numeric
    3. The first invoice number must be 27 (modify per your requirements)
    4. Each new invoice must be numbered one higher than the previous invoice.
    5. Invoice numbers must be sequential with no missing numbers.
    While the above list seems to be complete there are some very important questions that are not yet answered.
    1. When does an invoice become an invoice? That is, when is the invoice number assigned? Is the number assigned before or after the invoice record is committed to the database? If the number is assigned before committing (e.g. when the user begins processing an invoice) but the invoice is then abandoned and never committed there will be a gap in invoice numbers.
    2. Can invoice records ever be deleted? If a committed record is deleted there will be a gap in the numbers. Some systems handle deletions by either flagging the records as deleted without actually deleting them or moving the records to a deleted table so that all invoice numbers are always accounted for.
    Check printing applications used to print on pre-numbered check forms. The line printers that were used had sprockets to feed the checks and the first check could not be printed on since the sprockets were above the print head. The operator would enter the first check number into the system and the application created a check record marked VOID for that check number. This ensured that all pre-printed checks were accounted for and had not been misplaced or stolen.
    Oracle's sequence generator can generate sequence numbers in sequential order and ensure that there are no gaps in the generation process.
    Oracle cannot ensure that your application uses those numbers in a way that avoids gaps.
    Even a normal INSERT trigger that might be used to get the next sequence value cannot be certain that the record it is inserting will actually be committed unless the COMMIT operation is performed within the trigger.
    Sorry to 'rain on your parade' but withouth a better problem definition we can't give you a better solution.

  • TCP Sequence/Acknowledgement numbers

    Hello everyone,
    Please excuse me if this question is somewhat rudimentary, but I was as much looking for reassurance as anything else.
    As I understand TCP sequence numbers and Acknowledgments, in a nutshell it's case that:
    A Sequence number is sent from the host and is total number of bytes sent UP to this point, during the conversation, not including the current payload
    The acknowledgement number would be the total number of bytes recevied by the destination, FROM the sender, plus one (i.e. the one being the next byte it expects to get).
    Assuming this is right, I am somewhat confused by the following explanation, taken from this article (page 2): 
    https://www.novell.com/connectionmagazine/2001/05/sequence51.pdf
    Explanation goes:
    Host 1 ———> 
    Sequence number 1 with 9 bytes of data 
    Acknowledgment number field = 100
    <——— Host 2
    Sequence number 100 with no data (ACK)
    Acknowledgment number field = 10 (in 1 + 9 bytes of data)
    Host 1 ———>
    Sequence number 10 with 5 bytes of data 
    Acknowledgment number field = 100
    <——— Host 2
    Sequence number 100 with no data (ACK)
    Acknowledgment number field = 15 (in 10 + 5 bytes of data)
    <——— Host 2
    Sequence number 100 with 20 bytes of data 
    Acknowledgment number field = 15
    Host 1: ———->
    Sequence number 15 with no data (ACK) 
    Acknowledgment number field = 120 (in 100 + 20 bytes of
    data)
    If you would be so kind, I'm sort of looking for some confirmation that, in a nutshell, my appraisal as right, and also that the above explanation between Hosts 1 and 2 is a little confusing.
    As a side note, I believe only the SYN and FIN flags actually count as payload data, and the article above begins at Byte 1 but makes no mention of SYN.
    Thank you for reading.

    Hi,
    I believe the example is correct. Let's take it apart:
    Host 1 ———> 
    Sequence number 1 with 9 bytes of data 
    Acknowledgment number field = 100
    Host1 sends 9 bytes, numbering them from 1 (the Seq). The last byte is numbered as 9, and the subsequent byte will be numbered as 10 so this is what Host2 should acknowledge in its own segment. In addition, Host1 asks Host2 to continue sending data starting with the sequence number 100 (the Ack).
    <——— Host 2
    Sequence number 100 with no data (ACK)
    Acknowledgment number field = 10 (in 1 + 9 bytes of data)
    As requested by Host1, Host2 sends a segment with Seq=100. Because Host2 received the 9 bytes from Host1, it acknowledges them and tells Host1 to continue sending bytes starting with Seq=10.
    Host 1 ———>
    Sequence number 10 with 5 bytes of data 
    Acknowledgment number field = 100
    Host1 continues sending data starting from Seq=10, and with 5 sent bytes, these are numbered 10-14. The next byte would be 15 which is the Ack number expected from Host2. Because Host2 did not send any data itself, Host1 just tells Host2 again to continue sending data, if any, starting with sequence number 100 (the Ack).
    <——— Host 2
    Sequence number 100 with no data (ACK)
    Acknowledgment number field = 15 (in 10 + 5 bytes of data)
    Host2 has received additional 5 bytes from Host1 numbered as 10-14, so it sends back a segment with Ack=15 (all up to 14 is received, continue with 15). As there are no data to be sent by Host2 at this point, the Seq=100 and the body is empty.
    <——— Host 2
    Sequence number 100 with 20 bytes of data 
    Acknowledgment number field = 15
    Host2 suddenly has a data to send, and the bytes start with the sequence number of 100, so this is the Seq. Because no further bytes arrived from Host1 yet, we simply tell it to continue with byte 15 whenever Host1 has any bytes to send.
    Host 1: ———->
    Sequence number 15 with no data (ACK) 
    Acknowledgment number field = 120 (in 100 + 20 bytes of data)
    Host1 has no data to send itself but it needs to acknowledge the received data from Host2. There were 20 bytes in the segment received from Host2, starting from 100 and ending with 119. The upcoming expected byte from Host2 is thus 120, hence the Ack field value. The Seq field value is 15, the upcoming byte number.
    As a side note, I believe only the SYN and FIN flags actually count as payload data
    This is true.
    and the article above begins at Byte 1 but makes no mention of SYN.
    In fact, the article above seems to omit the TCP session establishment phase, and simply starts showing the Seq and Ack values in the midst of an already established session.
    Please feel welcome to ask further!
    Best regards,
    Peter

  • Inserting a Sequence of Numbers

    Hi all
    I have a number field restricted to 3 digits, and when someone navigates to the block to insert a record I want the number field to display 001 to state this is the first record, then if a second record is inserted put in 002 etc. Currently you can go and put any old 3 digit number in but I want to restrict it to a display field only, showing the number of records in this block in a sequence, for a particular parent record.
    I am trying to work out the following:
    How to build a counting generator (the most obvious bit)
    How to get the count generator to recognise what the existing number is (related to the parent record) and insert the next sequence of number say it is 001, then it now needs to put in 002.
    I currently have this piece of code (and result) as a start and am finding it difficult to decide how to build on it from that:
    SELECT ltrim (to_char (rownum, '009'))
    FROM dual
    LTRI
    001
    Any ideas on this would be appreciated.
    Thanks
    USER605593

    If you had a date column which held the date the row was added (or whatever it is that denotes the order) then you don't need to bother with an explicit sub sequence in the table.
    eg.
    with my_data as (select 1 record_id, 'hello' val, trunc(sysdate) -1 date_inserted from dual union all
                     select 1 record_id, 'there' val, trunc(sysdate) -1 + 2/24 date_inserted from dual union all
                     select 1 record_id, 'sailor' val, trunc(sysdate) -1 + 5/24 date_inserted from dual union all
                     select 1 record_id, 'boy' val, trunc(sysdate) -1 + 18/24 date_inserted from dual union all
                     select 2 record_id, 'hi' val, trunc(sysdate) -1 + 1/24 date_inserted from dual union all
                     select 2 record_id, 'ho' val, trunc(sysdate) -1 + 12/24 date_inserted from dual union all
                     select 2 record_id, 'off to work' val, trunc(sysdate) -1 + 13/24  date_inserted from dual union all
                     select 2 record_id, 'we go' val, trunc(sysdate) -1 + 23/24  date_inserted from dual union all
                     select 3 record_id, 'good' val, trunc(sysdate) -1 + 1.5/24 date_inserted from dual union all
                     select 3 record_id, 'bye' val, trunc(sysdate) -1 + 5/24 date_inserted from dual union all
                     select 4 record_id, 'geronimo' val, trunc(sysdate) -1 + 4/24 date_inserted from dual)
    -- end of data setup. Query below:
    select record_id, val, row_number() over (partition by record_id order by date_inserted) rn
    from   my_data
    RECORD_ID     VAL     RN
    1     hello     1
    1     there     2
    1     sailor     3
    1     boy     4
    2     hi     1
    2     ho     2
    2     off to work     3
    2     we go     4
    3     good     1
    3     bye     2
    4     geronimo     1This has the added advantage that if you need to insert a row at the end or in the middle, the ordering will automatically be taken care of. If you store the number, you then have to work out a way of updating the sub-sequence number manually. (Obviously, you'll have to format the rn into the 3 digit format for your display purposes, but you already know how to do that.)

  • SEQUENCE OF NUMBERING SCHEME IS TO BE CHANGED.

    Hi All,
    In iProcurement contracts we have the possibility to use numbering schemes.
    After defining a numbering scheme we are able to use the defined scheme, when we define a
    contract template. When we activate the
    renumber button, the contract terms are numbered according to the chosen (defined) scheme.
    The present numbering is like this:
    Headsection A
    Part 1
    Part 2
    Part 3
    Headsection B
    Part 1
    Part 2
    Part 3
    But we want to change this to
    Headsection A
    Part 1
    Part 2
    Part 3
    Headsection B
    Part 4
    Part 5
    Part 6
    iProcurement Super User -> Setup : Contract Terms -> Numbering Schemes
    Product Version 11.5.10
    Could any please suggest a workaround for thsi issue .

    Amol,
      You would have to " Back date" the uninstall date and time as well.The Oldest date that you could have here has to be greater than the "end date" of the Previous time segment for the piece of equipment
    The current date and time is always defaulted for Uninstall and Installation process, You would need to manipulate the same. You will not be be able to change the dates of the old time segments once a record has been created.
    Regards
    Narasimhan

  • Create continous sequence of numbers

    Hello
    I need to create numbers starting from 1 to n. I need these numbers to add as ending in the name of files that are being saved. For example File_1, File_2........etc.
    I tried to create a for loop (n= 100) and wired the "i" outside. Only i need is these i values ( 0,1,2,3,.....100)
    How is i possible? See attachment ffor what i have done.
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************
    Attachments:
    Numbers_file name.vi ‏18 KB

    Nghtcrwlr wrote:
    Ok Alain... here s the problem. I have a VI that writes some values to Excel and saves. Each time the VI is run it saves an Excel file. I need the Excel file naming like " File_1, File_2...etc.Those numbers 1, 2 should come at the ending in name. That was what i needed. But as i mentioned, i already got the solution in another way.
    In that case, the following vi is what you need.  You send in the basic file name, like "File_", and it returns the next numbered file name, like "File_003".  The next time you call it, it will return "File_004", and so on.  The first time you ever call it, send in a True on the Start Over? boolean input.  After than send in a False.  The vi contains a LV2 Style Functional Global.  The shift register is uninitialized.  It remembers what is in the shift register from the time it was called before.  The first time you call it, you must make Start Over as True so that it can initialize the shift register with 1.  Then the file name will be FIle_001.  Next time you call it, Start Over is False, and the shift register gets incremented, so the 1 becomes a 2, and the output is File_002.
    I think this is the best way to handle your problem.  It is both quick and easy.
    - tbob
    Inventor of the WORM Global
    Attachments:
    FileName_Incrementer.vi ‏10 KB

  • I seem to be unable to follow date sequences in Numbers

    Hi all, when I create a sheet in Numbers, in many instances, I like to highlight things such as
    all dates that fall on a Sunday like this:
    However, when I click on each date in succession all the system does is to group all days in between e.g if I click on the 8th Sept, and then want to highlight each Sunday after that, I click on the 15th but the system throws a frame around all 8 days, instead of just letting me just click on those dates that I wish to highlight i.e. 15th, 22nd and 29th. I was able to do what I'm trying to explain with iWork '08, but this '09 version is just not doing what I want it to do, or am I missing something? 

    Sapper,
    It seems you post is missing the screenshot or image you meant to include:
    I think based on your description you want to select non-contiguous cells.  In this case click the first cell, then hold the <COMMAND> key while click other cells:
    As you can see the cells that are highlighted are NOT all contiguous.

  • SEQUENCE issuing numbers more than once?

    This is all on
    Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64) 
    Oct 19 2012 13:38:57 
    Copyright (c) Microsoft Corporation
    Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
    Running on Server 2008 Standard as a VMWare instance
    I have an ETL load process that requires me to merge data form 4 sources. To do this we load data incrementally from each of the 4 instances into a STAGING table then we load it onwards into the destination table. During the load into the STAGING table we
    issue a unique RowID value for each loaded row based on a SEQUENCE attached to the STAGING table which is built using a script like this
    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[STAGING].[Fact_Bert]') AND type in (N'U'))
    DROP TABLE [STAGING].[Fact_Bert]
    GO
    IF  EXISTS (SELECT * FROM sys.sequences WHERE name = N'Bert_SEQ')
    DROP SEQUENCE [FACT].[Bert_SEQ]
    GO
    IF NOT EXISTS (SELECT * FROM sys.sequences WHERE name = N'Bert_SEQ')
    BEGIN
    CREATE SEQUENCE [FACT].[Bert_SEQ] 
     AS [int]
     START WITH 1
     INCREMENT BY 1
     MINVALUE -2147483648
     MAXVALUE 2147483647
     CYCLE 
     CACHE  100 
    END
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [STAGING].[Fact_Bert](
    [source_system_sk] [int] NOT NULL,
    [RowID] [int] NOT NULL,
    ... other cols for data
    CONSTRAINT [PK_STAGING_Bert] PRIMARY KEY CLUSTERED 
    [source_system_sk] ASC,
    ... other PKEY cols form source system
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
    IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
    ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [STAGING]
    ) ON [STAGING]
    GO
    IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[FACT].[DF_Bert_RowID') AND type = 'D')
    BEGIN
    ALTER TABLE [STAGING].[Fact_Bert] ADD  DEFAULT (NEXT VALUE FOR [FACT].[Bert_SEQ]) FOR [RowID]
    END
    GO
    So each row in STAGING ends up with a unique RowID, we carry these forwards into the LIVE tables and RowID is used as the PKEY on the LIVE tables.
    This should be all well and good.
    Every day a SQL Agent job runs a SSIS package that loads data into STAGING (after truncating it) and then moves it into LIVE.
    The problem is that for some of the STAGING tables every time we run the daily load jobs we find that it re-allocates SEQUENCE values. So when we try and move data into the LIVE tables we get a PKEY error. Looking at the data before we run a load we can
    see that there are values in the STAGING table that run to 2700010 but if I look at the sys.sequences DMV the current_value for the sequence concerned is 2700000 and
    SELECT NEXT
    VALUE FOR
    [FACT].[Bert_SEQ]
    -- returns 2700008
    So when we run the package we end up with values in STAGING that already exist in the LIVE table and hey presto a PKEY violation when we try and move the data into LIVE
    I've got an SP that I can run on the table that will look at the sequence and reset it to start at a new value if the currently used value is higher than the current value returned by the DMV (it pads the values by 1000) I had to write this as manually figuring
    it out was taking forever
    The server isn't usually restarted between loads, though I have done that deliberately today between load issues and it seems to make no difference.
    The SEQUENCES are CACHED but the CACHE size is 100 and the overlaps seem pretty randomly sized. Though the more data I load the bigger the overlap seems to be. This makes me think that something is amiss in the way data is loaded by the OLEDB Destination
    in the SSIS packages that populate the STAGING tables. I'm not using transactions anywhere nor am I using SSIS transaction/rollback capability
    I'm going to try switching the SEQUENCES to NO CACHE to see if that fixes the issue, though I don't like the perf hit I'm going to take as we're loading many tens of thousands running to hundreds of thousands of rows a day across 30+ tables. I appreciate
    this isn't exactly big but its big enough to be a problem.
    Has anyone got an ideas/advice?
    many thanks
    Steve
    BI Addict!

    I have built a small DB and SSIS package that reproduce the issue reliably and have been testing out the scenarios where it fails.
    Interestingly it seems this is only failing on 2 environments nth have the build number mentioned at the top of the post.
    The other environments seem to have 
    Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64) 
    and do not exhibit the same behaviour. So it would seem this was fixed between these two builds and it is a legacy
    issue of the mixed platforms we have.
    I will update the connect item with this info as well.
    BI Addict!

Maybe you are looking for

  • Back with Windows 7

    Been away for a while.  Have just upgraded to windows 7 - can't r emember the older version of elements thaqt I had - but pretty sure it was not compatible with windows 7.  So now do I go to Elements 8 ( is that the latest) - or is there a new versio

  • Corrupted movie files

    I have a large number of .mp4 files that no longer read into Quicktime player. It gives the "The file is not a movie file" message. These files used to be OK. I have checked some files from some older archives and they run fine. The movies are from s

  • Why we use PCLn tables  only in HR ?

    Hii     Kindly explain me why we use special PCLn tables for storing data in data clusters ,This kind of storing data is not used in other modules such as SD MM etc why only in HR module ?          That too in cluster tables we store specific data li

  • Modifying a DOM document.

    i have a 100 MB file...where I am suppose to change a node value to null.. i am using simple dom parser to achieve this task and it is working fine... but i need to pass -server -Xms 1G -Xmg 1G option to the java compiler and height is...it is taking

  • On Mac-keeps telling me to install latest version of Flash Player. I have successfully. Doesn't work

    I cannot get Flash to work on my Mac-have uninstalled and reinstalled, Cannot play any you tube videos