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 5838437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:28:04+00:00 2026-05-22T11:28:04+00:00

How to get information how many rows in a table have particular number of

  • 0

How to get information how many rows in a table have particular number of nulls in it?
I want to get something like this:

Number of nulls | Number of rows
        0       |      10
        1       |       4
        2       |      11

Motivation:
I need this for data mining purposes. If for example I have an observation that has in almost all columns null value then I need to get rid of this observation, but there can be also a situation where many observations have small value of nulls which is acceptable.

  • 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-22T11:28:05+00:00Added an answer on May 22, 2026 at 11:28 am

    With just SQL, you’ll have to resort to unpleasant code, something like:

    SELECT CASE WHEN column1 IS NULL THEN 1 ELSE 0 END
           + CASE WHEN column2 IS NULL THEN 1 ELSE 0 END
           + ... AS num_nulls,
           COUNT(*) as num_rows
    FROM table 
    GROUP BY num_nulls;
    

    Also note that not all SQL dialects support referencing a calculated column by alas in the GROUP BY clause, so you might end up with a much uglier query. Needless to say, you’ll also have to make a different query for each table. You could of course generate the query using some INFORMATION_SCHEMA voodoo…

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

Sidebar

Related Questions

I have a table with many rows. I want to have an on hover
I want to find out how many rows are in a table. The database
I'm trying to get information like OS version, hard disk space, disk space available,
I need to get information about applied CSS styles in HTML page. I used
I have a table containing persons information (one row per person) and another table
I have an EMPLOYEE table in a SQL Server 2008 database which stores information
I whant to do something like this: SELECT s.name, COUNT(r.request_log_id) AS NumberOfRequests FROM station
I have two tables users registered_members I want to confirm values from user table
I'm new to PHP/MySQL and super-new to CodeIgniter.. I have information in many MySQL
Ive got a table with a many rows, currently no fields are unique. I've

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.