Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query challenge 5 - fill in the holes
Message
De
26/06/1998 09:48:06
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00111733
Message ID:
00111904
Vues:
19
Hi Barbara and Bret ----

>>I have a table with null values in fields here and there. I would like a query that fills these in with values from the most recent record with something in that field. For example, if I have:
>>
>>field1     field2     field3
>>
>>3          5          6
>>5          6
>>7                     2
>>                      9
>>2          1          8
>>3          2
>>
>>I want:
>>
>>field1     field2     field3
>>
>>3          5          6
>>5          6          6
>>7          6          2
>>7          6          9
>>2          1          8
>>3          2          8
>>
>>
>>Thank you.
>
>Bret, instead of a query, try a method/prg with scan..endscan. That way you can scatter the values of record 1, then in the next loop check record 2 for blanks and fill them in etc.
>

LOCAL nField1,nField2,nField3
STORE 0 TO nField1,nField2,nField3
USE {table}
STORE IIF(ISNULL(field1),0,field1) TO nField1
STORE IIF(ISNULL(field2),0,field1) TO nField2
STORE IIF(ISNULL(field3),0,field1) TO nField3
SKIP
SCAN REST
REPLACE field1 WITH IIF(ISNULL(field1),nField1,field1)
REPLACE field2 WITH IIF(ISNULL(field2),nField2,field1)
REPLACE field3 WITH IIF(ISNULL(field3),nField3,field1)
STORE field1 TO nField1
STORE field2 TO nField2
STORE field3 TO nField3
ENDSCAN

***
Along these lines?
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform