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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:46:51+00:00 2026-05-26T20:46:51+00:00

I have a table with some project data. One column contains Completion %. By

  • 0

I have a table with some project data. One column contains “Completion %”. By default the value is set to 0. What is the best way to structure the mySQL query and write a code to get the following 3 values:

  • total users (every row WHERE PROJECT = 5)
  • participants (WHERE PROJECT = 5 AND completion != 0)
  • average completion rate (average of the % of participants)

I don’t think I can do it all in a single query…

Thanks

  • 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-26T20:46:52+00:00Added an answer on May 26, 2026 at 8:46 pm
    SELECT project_id,
      COUNT(*) AS total_users,
      COUNT(IF(completion != 0, rowID, NULL)) AS participants,
      AVG(IF(completion != 0, completion, NULL)) AS average_completion_rate
    FROM Projects
    WHERE project_id = 5
    GROUP BY project_id;
    

    It would be helpful in the future if you run SHOW CREATE TABLE of your table and include it in your question.


    Re comment: So it sounds like your table is something like this:

    CREATE TABLE Projects (
      rowID         INT PRIMARY KEY,
      project_id    INT,
      completion    TINYINT
    );
    

    I have edited my suggested query above to match.

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

Sidebar

Related Questions

I have a table in SQL Server 2005 which contains some changelog data for
I have table with some fields that the value will be 1 0. This
I have some table structure: <tr class=row-2><tr> <tr class=row-3>..<tr> <tr class=row-4>..<tr> <tr class=row-5>..<tr> <tr
I have a table that contains some blob fields that I don't want to
I have an Excel table with some data that I would like to export
I already have some simple project with one migration script: # --- !Ups create
I have some table: table ASK with idask table PREFERENCES with idpref , fk_idask
I have a table containing some names and their associated ID, along with a
I have a table that saves some account limits like users. For most rows
I have a table that includes some student group name, lesson time, day names

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.