Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Network:
Windows 2000 Server
>This SQL code works in VFP v6.0 but not in v9.0
>
>Select *, Count(*) From assettNavigatorData Group By name Having Count(*) > 1 InTo Cursor duplicateComputerAssignments Order By Name
>
>What am I doing wrong?
You're including fields in the field list that are neither aggregated, not listed in the GROUP BY clause. This is a no-no in SQL, which was added to VFP's version in VFP 8.
The problem is that when a field is neither aggregated nor grouped, VFP has to choose a value at random to put in the result.
To solve your problem, list only the fields you need (instead of *). Then, for fields other than Name, either add them to the GROUP BY clause or, if the value is the same for each record, wrap them with MIN() or MAX().
Tamar
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