Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Column not found
Message
From
27/09/2007 08:42:21
 
 
To
26/09/2007 13:29:33
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01256984
Message ID:
01257115
Views:
14
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform