Mike Yearwood
Toronto, Ontario, Canada
Versions des environnements
>Yes, but I was trying to get to the duplicate pk records and flag them in a different field, without disturbing the now corrupted index, and then go on with the processing.
>
>
>As a related question, can you tell me why
>
>select key from mytable group by 1 having count(*) > 1
>
>returns no records, and
>
>select key from mytable having count(*) > 1
>
>retuns the last record?
>
>Thanks,
>
>Al Allison
>
You cannot even do this query in VFP9 unless you SET ENGINEBEHAVIOR 70. This is one of the reasons one should stick to SQL standards IMO. You have to know what you're asking for.
Aside from the fact that computers are so dumb that they will do whatever we tell them, I can only explain how I think SQL works. :)
Count(*) is supposed to start counting on each group. In this case there is no group, so it counts all the way to the end of the table, resulting in a count(*) of the number of records in the table which is certainly >1. The having takes place after returning the set of records indicated by select key from mytable. So VFP is physically sitting on the last record when the having count(*)>1 condition evaluates to .T. and so you get the last record.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement