Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6057415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:29:09+00:00 2026-05-23T08:29:09+00:00

Follow this, it’s really obvious and simple. For some reason, the results differ between

  • 0

Follow this, it’s really obvious and simple. For some reason, the results differ between queries and approach angles on data subsets. Keep in mind that the field, correct_addr is a char(1) field with allowable nulls.

select distinct correct_addr, count(*) from id_rec group by correct_addr;

correct_addr       (count(*))
                         2477
N                          80
Y                       84013

3 row(s) retrieved.

Ok, so correct_addr contains 3 distinct values: “N”,”Y”, and either “” or ” ” or NULL

So now, I try this:

select count(*) from id_rec where correct_addr <> 'N';

      (count(*))
           84013

What happened to the 2477 records that have that blank value?

Another try from a different angle:

select count(*) from id_rec where correct_addr in (null,'',' ','Y');

      (count(*))
           84013

Same thing happens….

So what is going on here? Why doesn’t the sql engine (?) recognize the blank value in the last 2 sql statements? It discovers it fine in the first query with the grouping, but nowhere else.

Does anyone have any ideas as to why this type of thing happens?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:29:10+00:00Added an answer on May 23, 2026 at 8:29 am

    NULLs require special handling in SQL.

    Try

    select count(*) 
    from id_rec 
    where correct_addr <> 'N' 
        or correct_addr is null; 
    

    See here for an explanation of handling NULLs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I follow this rule but some of my colleagues disagree with it and argue
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
I follow this article to update data to gae localhost server from MySQL. This
I'm trying to follow this approach to create a datasource for embedded glassfish. The
I am trying to follow this tutorial http://damianm.com/tech/nhibernate-mvc-and-ninject/ but I am running into some
I follow this tutorial to learn some REST services and AJAX calls: http://www.mkyong.com/webservices/jax-rs/integrate-jackson-with-resteasy/ I
I'm trying to follow this simple examples given in the google web store API
I am trying to follow this tutorial on how to connect to a database
I am trying to follow this example (from p137 of Rob Pickering's Foundations of
I tried to follow this but the default modelbinder let my array null on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.