Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL quiz. Statement that returns *missing* values
Message
 
 
To
12/07/2011 23:44:08
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01518034
Message ID:
01518035
Views:
77
>A table has an index column that starts at one and goes to N, with some missing values. Is there an SQL Select statement (its ok to use more than one) that will return the first x items that are NOT present in the column?
>
>TIA,
>
>Alex

Create a Numbers table (see, for example):
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/passing-multiple-ranges-to-stored-proced

Once you have the Numbers table:
select top (N) N.Number from myTable T RIGHT JOIN Numbers N on T.IndexCol = N.Number
WHERE T.IndexCol IS NULL
ORDER BY N.Number
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform