Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show the names of non-participants in the last sending quiz in each division?
    primarykey
    data
    text
    <p>I am developing an intranet web application that provides the users with short quizzes. The quizzes will be sent to the users via emails. I have the following database design:</p> <blockquote> <p>Employee Table: Username, Name, Job, DivisionID</p> <p>Division Table: DivisionID, DivisionName</p> <p>Quiz Table: QuizID, Title, Description, IsSent</p> <p>UserQuiz Table: UserQuizID, Score, DateTimeComplete, QuizID, Username</p> </blockquote> <p><em><strong>NOTE: The first attribute in each table is the primary key.</em></strong></p> <p>And for your information, IsSent is a flag used to determine which quiz is sent to the users and which one is not.</p> <p><strong>What I want and need now is:</strong> I need to come up with a query that shows the names of the non-participants in the last sending quiz. It means if there is more than one quiz that is sent to the users, this query should display the names of non-participants in the last sending quiz. The query also should display the DivisionName, too.</p> <p>I came up with the following query but it shows the non-participants in all quizzes in the database. So how to modify it? or how to get what is required above?</p> <pre><code>SELECT TOP (100) PERCENT Q.Title, D.DivisionShortcut, E.Name FROM dbo.Quiz AS Q CROSS JOIN dbo.employee AS E LEFT OUTER JOIN dbo.Divisions AS D ON E.DivisionCode = D.SapCode WHERE (NOT EXISTS (SELECT UserQuizID, QuizID, DateTimeComplete, Score, Username FROM dbo.UserQuiz AS UQ WHERE (Username = E.Username) AND (QuizID = Q.QuizID))) ORDER BY Q.Title, D.DivisionShortcut </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload