Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select SQL problem
Message
 
To
11/04/2022 18:06:02
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01684152
Message ID:
01684157
Views:
59
>Hello all,
>
>I'd like for the following code to work. The where is the important part that doesn't want to cooperate ;-)
>
>SELECT Field1, COUNT(IdCase) as TotCases;
>FROM Table1 ;
>group by Field1;
>where TotCases > 3
>
>So to only get the rows where TotCases is greater thant 3 how should I code my where?

When you want to filter your result by some of aggregate fields you should use HAVING clause instead of WHERE.
SELECT Field1, COUNT(IdCase) as TotCases;
FROM Table1 ;
group by Field1;
HAVING COUNT(IdCase) > 3 && I use this because SQL Server do not like if I use the result field name
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform