Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL quiz. Statement that returns *missing* values
Message
De
15/07/2011 12:49:56
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01518034
Message ID:
01518261
Vues:
43
Thanks again,

Alex

>In case you're interested in solving this problem in SQL Server, this is a cool solution
>http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
>
>>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform