Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count of Items excluding some

Status
Not open for further replies.

duanecwilson

Programmer
Jul 15, 2005
26
US
I can't seem to get this simplest concept into SQL and work properly. All I want is to (pseudocode)
SELECT
WorkstationID
Count(Product)
From MyTable
Where Count(Product > 1)
AND Product NOT IN ('Product1','Product2', etc.)

No matter what I write, I either get an error or I get the wrong results (usually all of them disregarding the IN list). I have tried GROUP BY ... HAVING, all kinds of things.

I haven't included my SQL because I have tried 100 things, all wrong. Please help me with this.

Thank you.

Duane Wilson
 
Code:
SELECT
WorkstationID,
Count(Product)
From MyTable
Where Product NOT IN ('Product1','Product2', etc.)
GROUP BY WorkstationID
HAVING Count(Product) > 1
 
Thank you so much. I had a mental block on this. This is my actual SQL now that works.
SELECT
WorkstationID,
Count(Product) InstallsCount
From OfficeInstallations
Where Product NOT IN (
'Microsoft Office 2003 SP2',
'Microsoft Office Professional 2007 Trial',
'Microsoft Office Shared 64-bit MUI (English) 2007',
'Microsoft Office Shared MUI (English) 2007',
'Microsoft Office Shared Setup Metadata MUI (English) 2007',
'Microsoft Office Small Business Connectivity Components'
)
GROUP BY WorkstationID
HAVING Count(Product) > 1

Duane Wilson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top