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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:27:13+00:00 2026-06-12T18:27:13+00:00

To make a big sql structure simple: I am having next structure: id level

  • 0

To make a big sql structure simple: I am having next structure:

id    level    answercorrect    points
1     1        0                0
2     1        1                60
3     1        1                80
4     1        1                77
5     1        1                92
6     1        0                0
7     2        0                0
8     2        0                0
9     2        0                0
10    2        1                80
11    2        0                0
12    2        0                0

I now want to display two things:

1) how many levels were completed (this is min. half of the questions correct)

2) the level where you scored the most points.

Now I can go and manually do a query for each level, then compare them and then output them.

SELECT (*) FROM QUESTIONS WHERE LEVEL = level AND ANSWERCORRECT = 1

But Is there a way to do this quicker? It just seems like a to big bunch of code to accomplish that on my way..?

  • 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-12T18:27:15+00:00Added an answer on June 12, 2026 at 6:27 pm

    This will show you each level, with a count of answers, and a count of correct answers.

    select level, 
        count(*) as totalquestions, 
        sum (answercorrect) as correctanswers,
        sum (points) as totalpoints
    from yourtable
    group by level
    having sum (answercorrect) >= (count(*)/2)
    order by sum (points) desc
    

    Or

    select level,  
        count(*) as totalquestions,  
        sum (answercorrect) as correctanswers, 
        sum (points) as totalpoints,
        case when sum (answercorrect) >= (count(*)/2) then 1 else 0 end as completed
    from yourtable 
    group by level 
    order by sum (points) desc 
    

    It seems superfluous to store points and correctness, if points = 0 implies incorrect and points>0 implies correct?

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

Sidebar

Related Questions

how big (binary(xy)) should I make my table column in SQL database if I
I want to make a big selection box , <ul> <li> <div class=sbox> <img
I've written a big sql script that creates a CSV file. I want to
I have FirstName and LastName columns in sql.. I want to make First Name's
Is it possible to make one big array from a query like: select array_append(ARRAY[0],
Please stop me before I make a big mistake :) - I'm trying to
I plan to make an pretty big application on Facebook. Would it be a
I have big system that make my system crash hard. When I boot up,
I'm trying to make a spec file (rpm) for a insanely big software. The
I am programming for a big project, so I cooperate with others. To make

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.