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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a Query Please

Status
Not open for further replies.

mcbigj

Programmer
Joined
Dec 14, 2001
Messages
83
Location
US
Hi,
I need to write a query that will pull records that have an Id that appears up to a set number of times and not more. Here's an example:

A table is updated every time there is a signoff done on a project. There are 3 different types of signoffs, the type is entered as well as the ID from another table for the corrosponding project when a record is inserted. I want to return a recordset that only returns records where all three signoffs have NOT been completed. So basically all records where the id is in there once, twice, but not three times.

Any ideas would be appreciated.
Thanks
McBigJ
 
SELECT id, count(id) FROM myTable GROUP BY id HAVING count(ID) < 3 Get the Best Answers! faq333-2924
&quot;A witty saying proves nothing.&quot; - Voltaire
mikewolf@tst-us.com
 
Thank you. One problem is that the id field is a uniqueIdentifier and I cannot use a ui in an aggregate operation (count(id)). I'm going to try and CAST the id to another datatype in the process and see if that works. Any other ideas other than the CAST?
Thanks again.
 
Seems to work with the Cast,, thanks a ton.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top