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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:57:00+00:00 2026-05-30T13:57:00+00:00

I am developing a simple Quiz Engine similar to that one in the ASP.NET

  • 0

I am developing a simple Quiz Engine similar to that one in the ASP.NET website. I have the following database design:

  • User: Username, Name, DivisionCode… etc

  • Division: SapCode, Division.

  • Quiz: QuizID, Title, IsSent, Description.

  • UserQuiz: UserQuizID, QuizID, DateTimeComplete, Score, Username

What I want now is to show an indicator in the Result page of each quiz that will show to the user the number of participants in the Employee’s Division who got 100 from the first time of taking the quiz. (so if the user takes the quiz again, his second try will not be considered in this query). So how to do that (How to show the number of participants who got 100 from the first time only)?

    My Query which is not correct is:

    SELECT     dbo.Divisions.DivisionShortcut, COUNT(dbo.UserQuiz.Username) AS [Number of Participants]
FROM         dbo.Divisions INNER JOIN
                      dbo.employee ON dbo.Divisions.SapCode = dbo.employee.DivisionCode INNER JOIN
                      dbo.UserQuiz ON dbo.employee.Username = dbo.UserQuiz.Username INNER JOIN
                      dbo.Quiz ON dbo.UserQuiz.QuizID = dbo.Quiz.QuizID
WHERE     (dbo.UserQuiz.QuizID = @QuizID)
GROUP BY dbo.Divisions.DivisionShortcut, dbo.UserQuiz.Score
HAVING      (dbo.UserQuiz.Score = 100)

And the desired output should be like this:
enter image description here

EDIT:
I am struggling now in being able to determine the QuizID:

;with OrderedAttempts as (
     select Username,Score,QuizID,
       ROW_NUMBER() OVER (PARTITION BY Username,QuizID ORDER BY DateTimeComplete) as rn
     from UserQuiz
     WHERE     (dbo.UserQuiz.QuizID = @QuizID)
), FirstAttempts as (
     select Username,Score,QuizID from OrderedAttempts where rn = 1
)
select
    d.DivisionName,
    COUNT(fa.Score)
from 
    Divisions d
        left join
    Employee e
        left join
    FirstAttempts fa
        on
            e.Username = fa.Username
        on
            d.SapCode = e.DivisionCode
group by
    d.DivisionName
  • 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-30T13:57:01+00:00Added an answer on May 30, 2026 at 1:57 pm

    Simplest part of the query is find everyone who scored 100 on their first try:

    ;with OrderedAttempts as (
         select UserName,Score,QuizID,
           ROW_NUMBER() OVER (PARTITION BY UserName,QuizID ORDER BY DateTimeCompleted) as rn
         from UserQuiz
    ), FirstAttempts as (
         select UserName,Score,QuizID from OrderedAttempts where rn = 1
    )
    select
        d.DivisionName,
        COUNT(fa.Score)
    from
        Division d
            left join
        User u
            left join
        FirstAttempts fa
            on
                u.UserName = fa.UserName
            on
                d.SapCode = u.DivisionCode
    group by
        d.DivisionName
    

    Hopefully, from there, you can build up the rest of your query.

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

Sidebar

Related Questions

I've been developing a simple website using asp.net MVC and I'm starting to add
Hi I am developing a simple application based upon ASP.NET MVC. I have altered
Im developing a simple application that have a line like this: string[] values =
I'm developing a simple application that animates an image as the user moves a
I am developing a simple web apps that allowed user to key in information
I'm developing simple image sharing site to train my ruby-on-rails-fu. I have following resources
Can anyone recommend a good Java game engine for developing simple tile-based games? I'm
i'm developing a simple C# Editor for one of my university courses and I
I have 6 months experience with Android, developing simple UI-based applications. Now I want
I'm developing simple MVC app in Cocoa/Objective-C. I have a strange issue (or misunderstanding)

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.