Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Column not found
Message
 
À
26/09/2007 13:29:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01256984
Message ID:
01257115
Vues:
15
>Try:
Select crsprod, crsitemcode, sum(crsrequestamt) as inreq, sum(crsaccptamt) as whsaccpt, Count(*) as cntdup From crs_grid1 ;
>    Group By  crsprod, crsitemcode WHERE COUNT(*) > 1 INTO CURSOR dupcount
HTH
>
>>I am trying to select record that have more than 1 duplicate record into a cursor but I keep getting a message saying "SQL : Column 'CNTDUP' not found". Here is my select statement:
Select crsprod, crsitemcode, sum(crsrequestamt) as inreq, sum(crsaccptamt) as whsaccpt, Count(*) as cntdup From crs_grid1 ;
>    Group By  crsprod, crsitemcode WHERE cntdup > 1 INTO CURSOR dupcount
>Is it not possible to use where clause on the count column.

When you use a query result to filter records you must use HAVING clause not where:
Select crsprod, crsitemcode, sum(crsrequestamt) as inreq,;
       sum(crsaccptamt) as whsaccpt, Count(*) as cntdup;
From crs_grid1 ;
Group By  crsprod, crsitemcode;
HAVING cntdup > 1;
INTO CURSOR dupcount
or
Select crsprod, crsitemcode, sum(crsrequestamt) as inreq,;
       sum(crsaccptamt) as whsaccpt, Count(*) as cntdup;
From crs_grid1 ;
Group By  crsprod, crsitemcode;
HAVING COUNT(*) > 1;
INTO CURSOR dupcount
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform