Results 1 to 3 of 3
  1. #1
    nigelbloomy is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    51

    Query where count of a value is 0


    I am trying to get a query where I can pull all of the line items that don't have a certain value.
    I have an item code and for each item code I have several instances of the letter "P" in a field [Acquired] for each time the item was purchased. Sometimes we can get the item through another method, so that same field might have an "S" or maybe even just be blank. I am trying to put together something to just get the items that have never been purchased, ie there are no "P"s in the Acquired field in all the history for the item number. I keep trying to use count, but I can't figure out how to conditionally count just the P's, or how to filter out just the ones that have a 0 count for the P's.

    Any ideas?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Do you have a table of all possible item codes?

    SELECT * FROM ItemCodes WHERE NOT ItemCode IN (SELECT ItemCode FROM Purchases WHERE Acquired="P");
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    nigelbloomy is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    51
    That's it. I hadn't thought of using anything like that, but it makes sense.

    Thank you so much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Year Count and Month Count Same Query
    By NateSmith in forum Queries
    Replies: 1
    Last Post: 05-13-2015, 08:23 AM
  2. Replies: 2
    Last Post: 04-15-2014, 01:59 PM
  3. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  4. Replies: 7
    Last Post: 05-02-2012, 08:04 AM
  5. Max of Count Query
    By dssrun in forum Queries
    Replies: 4
    Last Post: 03-05-2012, 12:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums