Welcome Guest
Log In | Register )
You last visited January 18, 2017, 5:17 pm
All times shown are
Eastern Time (GMT-5:00)

Calculate last time number drawn using VB

Topic closed. 8 replies. Last post 12 years ago by Littleoldlady.

Page 1 of 1
PrintE-mailLink
Avatar
Austin
United States
Member #3734
February 16, 2004
57 Posts
Offline
Posted: February 7, 2005, 7:18 pm - IP Logged

I have 2 fields ID and Picks, I want to add another field(Interval) that calculates the interval the last time a number was drawn.

    hypersoniq's avatar - 8ball
    Pennsylvania
    United States
    Member #1340
    April 6, 2003
    2450 Posts
    Offline
    Posted: February 7, 2005, 9:50 pm - IP Logged

    could you copy the code in? easier to see what's going on that way...

    what version of VB?

    Playing more than one ticket per game is betting against yourself.

      Avatar
      Austin
      United States
      Member #3734
      February 16, 2004
      57 Posts
      Offline
      Posted: February 7, 2005, 11:14 pm - IP Logged

      I am using the following query but it takes too long

      ID,Picks,Interval



      SELECT A.ID, A.Picks,A.ID-Nz(Max(B.ID),A.ID) AS Interval

      FROM Pick3day AS A LEFT JOIN Pick3day AS B ON A.ID>B.ID AND A.Picks=B.Picks

      GROUP BY A.ID, A.Picks;

        Todd's avatar - Cylon 2.gif
        Chief Bottle Washer
        New Jersey
        United States
        Member #1
        May 31, 2000
        23349 Posts
        Offline
        Posted: February 7, 2005, 11:41 pm - IP Logged

        Try this, and see if it's faster:



        SELECT A.ID, A.Picks, ISNULL((SELECT TOP 1 B.ID-A.ID FROM Pick3day B WHERE (B.ID<A.ID) AND (B.Picks=A.Picks) ORDER BY B.ID DESC),0) AS Interval
        FROM Pick3day A ORDER BY A.ID


        Also, make sure the column ID is set to be a primary key.

         

        Check the State Lottery Report Card
        What grade did your lottery earn?

         

        Sign the Petition for True Lottery Drawings
        Help eliminate computerized drawings!

          Avatar
          Austin
          United States
          Member #3734
          February 16, 2004
          57 Posts
          Offline
          Posted: February 8, 2005, 1:00 am - IP Logged

          "wrong number of arguments" error message

            Todd's avatar - Cylon 2.gif
            Chief Bottle Washer
            New Jersey
            United States
            Member #1
            May 31, 2000
            23349 Posts
            Offline
            Posted: February 8, 2005, 10:18 am - IP Logged

            Are you using SQL Server?  What version?  (If you're using Access, it may not support the code I wrote.)

             

            Check the State Lottery Report Card
            What grade did your lottery earn?

             

            Sign the Petition for True Lottery Drawings
            Help eliminate computerized drawings!

              SirMetro's avatar - center
              East of Atlanta
              United States
              Member #6191
              August 11, 2004
              1389 Posts
              Offline
              Posted: February 8, 2005, 5:25 pm - IP Logged

              You may be able to get some additional assistance here

              http://www.talkaboutsoftware.com/

              They are very helpfull here. Only takes a minute to sign up and it's all free.

              Sir Metro

                Avatar
                Austin
                United States
                Member #3734
                February 16, 2004
                57 Posts
                Offline
                Posted: February 9, 2005, 1:09 am - IP Logged

                I'm using Access 2000 as the database.

                  Littleoldlady's avatar - basket
                  Clarksville
                  United States
                  Member #487
                  July 15, 2002
                  17638 Posts
                  Offline
                  Posted: February 13, 2005, 8:09 am - IP Logged

                  I don't know anything about this stuff but it is so-o-o interesting. I joined that site..

                  If you know your number is going to hit, have patience and then KILL IT!

                  You never know when you will get another hit.