Results 1 to 6 of 6
  1. #1
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86

    Remove 0 values but keep NULL values in SQL designer

    Hi

    I have a query and with one of the fields I want to exclude 0 values but keep NULL. I have a WHERE clause to exclude 0 but it also removes NULL and that is not the behaviour I want.

    Here is my query, the WHERE clause is in red.


    Code:
    SELECT
        qryPlan.warehouse,
        qryPlan.area,
        qryPlan.bay,
        Round([SumOfbin_width_mm]/[bay_width_mm]*100,1) AS [Capacity %],
        qrySumOfBinSize.SumOfbin_width_mm,
        qryPlan.bay_width_mm,
        qryPlan.bay_depth_mm,
        qryPlan.bay_height_mm,
        qryPlan.bin,
        qryPlan.bin_width_mm,
        qryPlan.priority,
        qryPlan.bin_type,
        qryPlan.product,
        qryPlan.dimension,
        qryPlan.long_description,
        qryPlan.catalogue_number,
        qryPlan.bin_number,
        qryPlan.physical_qty,
        qryPlan.PTZ_replen_min,
        qryPlan.PTZ_replen_max,
        qryPlan.PTZ_fullpallqty,
        qryPlan.comment
    FROM
        qryPlan LEFT JOIN qrySumOfBinSize ON qryPlan.bay = qrySumOfBinSize.bay
    WHERE
        (((qryPlan.bin_width_mm)<>0))
    ORDER BY
        qryPlan.warehouse, qryPlan.area, qryPlan.bay, qryPlan.bin, qryPlan.priority, qryPlan.product;
    Is there a way i can achieve this?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Try:

    WHERE Nz(bin_width,99999)<>0
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Might be more efficient:

    WHERE qryPlan.bin_width_mm <> 0 OR qryPlan.bin_width_mm Is Null
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Yep, probably.
    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.

  5. #5
    anthgav is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    86
    Thanks guys, both work.

  6. #6
    Athar Khan is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    63
    I had the same issue, but now solved. Thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 04-17-2017, 01:40 PM
  2. Replies: 7
    Last Post: 12-04-2013, 01:55 PM
  3. Query to Sum Values and Remove Duplicates
    By noobaccessuser in forum Queries
    Replies: 1
    Last Post: 12-06-2012, 07:12 PM
  4. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  5. Remove Quotes within Data Values
    By kfschaefer in forum Programming
    Replies: 0
    Last Post: 02-26-2009, 01:15 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