Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Gaps in Check Sequence?
Message
From
14/11/2003 17:17:58
 
 
To
14/11/2003 16:39:13
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00850077
Message ID:
00850110
Views:
17
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform