Results 1 to 5 of 5
  1. #1
    sam81 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    7

    Question regarding eliminating a value for one column but keeping the value for a different column

    Hello everyone, first post here. I have a problem that has been consuming me. I'm fairly new to Access so I have a grasp of running basic queries but this issue has me stuck.

    I have column for a set of five values (let's say: A,B,C,D,E) and a column for months. Let's say the months span from January through June. Each of these six months can have any of these five values (A,B,C,D,E).

    I'd like to run a query where I would like to include the value 'E' for the month of June only, but exclude the value 'E' for all other months. The query needs to have all other remaining months and values.

    I did this initially by running two separate queries; one where I just ran a query for June and the value 'E' and then another query where I excluded the value 'E' and ran with all other months/values (I did this by using <> "E" next to criteria under the values column in query design). This works but the problem is that it isn't efficient as there are two queries that are different lengths (different number of rows).



    Any ideas?

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    I think you need a Cartesian query - two tables (or queries) which are not linked. Something like

    Code:
    SELECT *
    FROM tbl1, tbl2
    WHERE (tbl1.month='june' and tbl2.value='E') OR (tbl1.month<>'june')
    if it is one table then

    Code:
    SELECT *
    FROM tbl1
    WHERE (tbl1.month='june' and tbl1.value='E') OR (tbl1.month<>'june')
    if neither of these are what you are looking for, please post some sample data of your months and values plus what you what as a result

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Maybe:

    SELECT * FROM table WHERE ([value] = "E" AND [month] = "June") OR ([value] <> "E" AND [month]<>"June");
    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.

  4. #4
    sam81 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    7
    Quote Originally Posted by June7 View Post
    Maybe:

    SELECT * FROM table WHERE ([value] = "E" AND [month] = "June") OR ([value] <> "E" AND [month]<>"June");
    Where would this line go? Into the Criteria? The entire line? Sorry I'm still new to Access.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That is an entire SQL statement. Can type into the SQL View window of query builder (use your table and field names) or use the query designer to build.
    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.

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

Similar Threads

  1. Replies: 8
    Last Post: 07-29-2014, 12:35 PM
  2. Replies: 16
    Last Post: 07-22-2014, 08:05 AM
  3. Replies: 4
    Last Post: 04-22-2014, 08:23 AM
  4. Keeping Column Captions when exporting expoting pivot table
    By UofAHogs in forum Import/Export Data
    Replies: 1
    Last Post: 06-04-2012, 12:46 AM
  5. Replies: 1
    Last Post: 04-15-2010, 02:07 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