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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:36:13+00:00 2026-06-18T10:36:13+00:00

I am trying to retrieve simple statistics for database completeness. I would like to

  • 0

I am trying to retrieve simple statistics for database completeness. I would like to know how many fields out of total number of fields have been filled in per record, considering that fields not entered have “null” in them or “”.

Here is how the existing code looks like :

<% if @products %>

  <% total_attribute_count = Product.columns.size %>

  <% @products do |product| -%>
    <p><%= platform.name %></p>
    <p>I would like to have here a number of attributes filled in, so I could calculate a percentage based on total_attribute_count</p> 
  <% end -%>

<% end %>
  • 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-06-18T10:36:15+00:00Added an answer on June 18, 2026 at 10:36 am

    You can try following

    #Following line will gives you total number of columns in the table
    a = Product.column_names.length  
    #Following line will gives you total number of columns which are filled
    b = Product.column_names.map{|a| product.send(a)}.compact.length
    #Following line gives you total number of columns which are nil or null
    a - b
    To calculate % you can do following
    (b.to_f*100/a.to_f)
    

    Ref column_names

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

Sidebar

Related Questions

I'm trying to figure out a 'simple' dictionary/database with Python, which will retrieve a
I'm trying to create a simple widget to retrieve a users feeds, I have
I am trying to retrieve some rows from the database using simple SELECT statement
I'm trying to retrieve folders name from a zip file. I wrote this simple
I'm trying to write a simple curl program to retrieve the web page in
I'm trying to create a simple example to understand how to store then retrieve
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I'm writing a simple app in HTML and Javascript. I'm trying to retrieve my
I'm have a very annoying issue with a textarea when trying to retrieve its
I have build a very very simple database schema as **Tickets**: TicketId (PK) AreaId

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.