Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Gaps in Check Sequence?
Message
De
14/11/2003 17:17:58
 
 
À
14/11/2003 16:39:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00850077
Message ID:
00850110
Vues:
16
>If I have a series of checks say 1, 2, 3, 4, 6, 7, 8 - how can I write a SQL statement to show that the number FIVE (5) is missing in this sequence?

I'd do something like this:
** setup example
** add some checks to a register
Create Cursor cuRegister (icheckno i, yamount Y, ddate d)
Index On icheckno Tag icheckno
Do While RecNo()<10000
  Insert Into cuRegister (yamount, ddate) Values (Rand()*1234.43, Date()-Int(Rand()*23))
EndDo
Replace icheckno With RecNo() All
** make some of them missing
Delete For RecNo()%Int((Rand()*123+1))=0


FindMissing(25,815)

*------------------
*	FindMissing()
*------------------
Function FindMissing(tnStart, tnEnd)
  Local lnAdd

  ** find the missing ones
  Create Cursor cuRange (icheckno i)
  lnAdd=tnStart
  Do While lnAdd<=tnEnd
    Insert Into cuRange Values (lnAdd)
    lnAdd = lnAdd + 1
  EndDo

  Select icheckno ;
    from cuRange ;
    where icheckno Not In (Select icheckno From cuRegister) ;
    into Cursor cuMissing2
  If RecCount()>0
    Browse Last NoWait
  EndIf
EndFunc
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform