Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update sql with conditions
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00895697
Message ID:
00895730
Vues:
16
>hiall, i just have this table with the following date that i need to change:
>customer charge date
>01 2201 2004/04/30
>01 2201 2004/04/30
>01 2201 2004/04/30
>01 2202 2004/04/30
>01 2202 2004/04/30
>02 2201 2004/04/30
>02 2201 2004/04/30
>
>customer 01 has 3 charge 2201 then i need to keep the third record with that date, but the previous record i need to discount 30 days, and the previous record another 30 days, in his charge 2202 only discount 30 days to first record, just like the customer 02. This table has 125,226 records
>Any ideas?
>
>Thanks all


Maybe this will help. Assuming that your table is ordered by cust and then charge, this code would change the 1st record by 0 days, the second record by 30 days and the third record by 60 days.


SELECT ThisTable
GOTO TOP
SCAN
save_cust = ThisTable.cust
save_charge = ThisTable.charge
item_cnt = 0
DO WHILE NOT EOF() AND save_cust = ThisTable.cust AND save_charge = ThisTable.charge
REPLACE ThisTable.date WITH (ThisTable.date - (30 * item_cnt))
item_cnt = item_cnt + 1
SKIP
ENDDO
SKIP -1
ENDSCAN
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform