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
 Working with counts

Author  Topic 

offspring22
Starting Member

38 Posts

Posted - 2009-11-03 : 12:31:35
I need to do a search, where I need to find how many product ID's sold how many times between specific dates, ie, in 2006, in 2007, etc. I can run them as seperate searches for each date though.

IE, that results in 2 have sold 4 times, 8 have sold 3 times, 9 sold twice, etc.

Hopefully that makes sense.... Any idea of how to get started?


offspring22
Starting Member

38 Posts

Posted - 2009-11-03 : 12:32:18
Oh, this is in MS SQL 2000
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-03 : 16:17:16
can you post some sample Data

SELECT ProductID, YEAR(someunkowndate), COUNT(*)
FROM TABLE
GROUP BY ProductID, YEAR(someunkowndate)

DDL would be good as well as the expected result you have in mind

Read the hint link in my sig



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -