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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Having Count?

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2010-11-18 : 05:43:10
Hello Experts!

I have a table, "ITEMS" which has numbers and codes.

I am trying to return the job number where there are more than one item "CA" against a single job number.

So something along the lines of,

SELECT Item.JobNo FROM Item WHERE Item.Code = 'CA' Having COUNT(Item.Code) * 2

I know that I am wrong, I just hope I am communicating what I am trying to do.

Thank you for your time.
Pace

"Impossible is Nothing"

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-11-18 : 06:25:55
SELECT Item.JobNo FROM Item WHERE Item.Code = 'CA' GROUP BY Item.JobNo Having COUNT(Item.Code) > 1
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2010-11-18 : 08:13:30
Thats great, thank you.

Hehe I was closer than I thought :)

"Impossible is Nothing"
Go to Top of Page
   

- Advertisement -