Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

How to Filter a Count

I can list the count for a specific condition.

I need to list only those rows where the count is greater than a specified amount.
The following statement returns the symbolID and the number of increases within a given date range.
SymbolID     Increases
1589      16  
5834      10  
7162      15  
2917      8
1566      14  

This is the list I need:
1589      16
7162      15
1566      14

I need to list only increases greater than 10.

In Psuedocode:

SELECT SymbolID
, Count(*) AS Increases  
FROM StockHist
WHERE
ClosePrice >=ClosePricePrev
AND QuoteDate >= '2009-01-05'
AND QuoteDate <= '2009-02-04'
GROUP BY SymbolID
WHERE Increases > 10

Any ideas would be appreciated.


SELECT SymbolID 
, Count(*) AS Increases  
FROM StockHist 
WHERE 
ClosePrice >=ClosePricePrev 
AND QuoteDate >= '2009-01-05' 
AND QuoteDate <= '2009-02-04'
GROUP BY SymbolID

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jamesgu
jamesgu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

That was almost too easy.
Thanks for the quick response. I had spent one hour on this. It saved me a lot of time.