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

  • Home
  • SEARCH
  • 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 8508427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:09:29+00:00 2026-06-11T03:09:29+00:00

I have a table ANSWERS qId toggle_value which records an HTML radio button value

  • 0

I have a table

ANSWERS 
   qId
   toggle_value

which records an HTML radio button value {Yes, N/A, No, Resolved}

Now I want to count and summarize how many yeses, nos, nas and resolved grouped by question Id.

For simplicity I started to build each individual query.

SELECT qId, count(*) as yes_qty FROM ANSWERS WHERE TOGGLE_VALUE='Yes' GROUP BY qId;
SELECT qId, count(*) as na_qty FROM ANSWERS WHERE TOGGLE_VALUE='NA' GROUP BY qId;
SELECT qId, count(*) as no_qty FROM ANSWERS WHERE TOGGLE_VALUE='No' GROUP BY qId;
SELECT qId, count(*) as resolved_qty FROM ANSWERS WHERE TOGGLE_VALUE='Resolved' GROUP BY qId;

But I really want it in one query so I can iterate over the list and display something like this ( aggregating 14 Checklists with 3 questions)

Q      Yes      No     NA     Resolved
1       4       10     0        10
2      14        0     0         0
3       7        0     7         0

I don’t actually use strings for the toggle value but numbers 1=yes, 2=NA, etc… and was wondering if a better table design would have been

ANSWERS 
   qId
   yes_value
   no_value
   na_value
   resolved_value

I’d have to refactor a lot of other things if I changed the table deisgn so I was hoping to get a single query working.

  • 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-11T03:09:31+00:00Added an answer on June 11, 2026 at 3:09 am
    SELECT qId,
           SUM(CASE WHEN TOGGLE_VALUE='Yes' THEN 1 ELSE 0 END) AS YesQty,
           SUM(CASE WHEN TOGGLE_VALUE='No' THEN 1 ELSE 0 END) AS NoQty,
           SUM(CASE WHEN TOGGLE_VALUE='NA' THEN 1 ELSE 0 END) AS NAQty,
           SUM(CASE WHEN TOGGLE_VALUE='Resolved' THEN 1 ELSE 0 END) AS ResolvedQty
      FROM ANSWERS 
     GROUP BY qId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table in which I am inserting rows for employee but next time
I have table with 300 000 records (MyISAM). I get record from this table
I have a table of answers to questions: table questionAnswers: user VARCHAR question VARCHAR
I have a base table of Participants and Answers, with the following structure: ParticipantId,
I have table similar to the following: Year | Product | Value 2006 A
I have a table 'answers' with an indexed 'problem_id' integer column, a 'times_chosen' integer
Lets say I have a table with Groups of Questions GroupID | value --------+------
I have a problem in updating records to a derby db table with foreign
I have 3 tables from which I'm pulling data Table 1 : assignment_status primary_key
Hello everyone and thank you for your answers and comments. I have a table

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.