Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2014
    Posts
    2

    "And" function

    Querying a table which has people and colors they like. Every person has multiple entry as they like different colors. Question: How do I get a list fo poeple who like 2 or more different colors. Lets say: give me a list of people who like yellow, red and blue.
    Thanks, Paula

  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,601
    Getting a list of people who like more than 1 color is a simple aggregate (GROUP BY) Totals query.

    SELECT PersonID, Count(Colors) AS CountColor FROM tablename GROUP BY PersonID HAVING Count(Colors) > 1;

    If you want to filter based on specific colors with the AND operator that is tricky. Maybe a CROSSTAB query will help, otherwise I expect will need custom VBA function.
    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
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You could use a 'search' table that has the 3 colors in it. It will return only those that match any in the list...do a count on this to get those that have count=3

  4. #4
    Join Date
    Sep 2014
    Posts
    2

    thanks

    yes, that was my thinking as well as it works. I would import 3 excel sheets with the info into the same table and group and count >3. What do you mean by the "search table". Thanks, Paula

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

Similar Threads

  1. Unbound text box data type and "Delete" function
    By gaker10 in forum Programming
    Replies: 16
    Last Post: 06-13-2014, 10:46 AM
  2. Replies: 7
    Last Post: 08-14-2013, 03:57 PM
  3. Replies: 1
    Last Post: 04-23-2013, 08:35 AM
  4. Replies: 2
    Last Post: 11-04-2011, 02:45 AM
  5. Replies: 3
    Last Post: 04-10-2010, 10:22 AM

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