Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sum(count)

Author  Topic 

Rheinhardt
Yak Posting Veteran

66 Posts

Posted - 2009-11-12 : 04:59:27
Hi,

I have monthly sales data per item...

Year Month QTY
2007 01 2
2007 02 0
2007 03 1
2007 04 2
2007 05 0
2007 06 5......

I want to exclude Items where there isn't more than x amount of months with a quantity (qty) present.

Example: The above only had sales in 4 months of the 12 months, I only want Item's sales data were the item has more than 5 months of data?Therfore the above Item will not be included.

So how do I get the total (sum) number of "count" where there is quantity/qty present?

Thanks



khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-12 : 05:21:57
[code]
select Items
from [monthly sales data]
where QTY > 0
group by Items
having count(*) > 4
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -