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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:23:02+00:00 2026-05-16T20:23:02+00:00

I have the following tables for a competition: User: Id Name Email EntryId Entry:

  • 0

I have the following tables for a competition:

User:

  • Id
  • Name
  • Email
  • EntryId

Entry:

  • Id
  • Age
  • Gender
  • State

GameResult:

  • Id
  • EntryId
  • Duration
  • Score

QuestionResult:

  • Id
  • EntryId
  • Correct
  • UsersAnswer

Each entry will have multiple games, and multiple questions. I need to perform a query that will find a list of the highest scores, and then also break down highest score by demographic, i.e. Age, Gender, State.

The calculations are as follows:

Each correct question will have a score value assigned, e.g. 10 points for each correct answer. Each game will have the score already defined in its column.

So, for an entry, the total score will be:

(Count(Qn.Correct) * QuestionScore) + SUM(G1.Score, G2.Score, Gn.Score)

Not sure where to start in figuring this query out.

  • 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-16T20:23:03+00:00Added an answer on May 16, 2026 at 8:23 pm

    note sure individual answer score would be relevant here since you already have final score on the GameResult table.

    select e.Age, max(gr.Score) as Score
    from Entry e
    inner join GameResult gr on(gr.EntryID=e.EntryID)
    group by e.Age
    

    then repeat the same thing for the gender and state.

    edit: ok, I am not sure I am following your high level design here, but whatever…
    You need to group your results by the entry ID first, and then by Age/Gender/State. An extra complexity level, but otherwise exactly the same task.

    with GameResultScore as (
    select EntryID, sum(Score) as Score
    from GameResult
    group by EntryID
    ),
    QuestionResultScore as (
    select EntryID, count(*) CorrectAnswers
    from QuestionResult
    where Correct=1
    group by EntryID
    )
    
    select e.Age, max(isnull(grs.Score,0)+isnull(qrs.CorrectAnswers,0) * QuestionScore) as Score
    from Entry e
    left join GameResultScore  grs on(grs.EntryID=e.EntryID)
    left join QuestionResultScore qrs on(qrs.EntryID=e.EntryID)
    group by e.Age
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables Pedal Brand:string Classification:string Model:string Variety Title:string name:string pedal_id:integer Example
I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation:
I have following two tables: Person {PersonId, FirstName, LastName,Age .... } Photo {PhotoId,PersonId, Size,
I have following tables: products - 4500 records Fields: id, sku, name, alias, price,
I have the following tables: Monster: Name Description EatsPeople Vampire Pale, afraid of light
I have following tables: users(id, name) posts (id, text, userId) comments (id, text, userId,
I have following tables 1) Products (productid, name, description, price) 2) Sales (salesid, productid,
I have the following tables: Post Id int User Id int Then I have
I have following two tables Table name: thread pk-> thread_id | thread_title | description
I have following tables. genre: genre_id name actors: actor_id name movies: movie_id actor_id genre_id

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.