We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

How to Filter a Count

Dovberman
Dovberman asked
on
Medium Priority
318 Views
Last Modified: 2012-06-21
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

Comment
Watch Question

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

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
That was almost too easy.
Thanks for the quick response. I had spent one hour on this. It saved me a lot of time.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.