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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:52:29+00:00 2026-06-17T00:52:29+00:00

I have a question about an SQL I want to perform but got no

  • 0

I have a question about an SQL I want to perform but got no idea on how to write it. Below are the tables with so dummy data:

Module:

ModuleId (PK auto) ModuleNo   ModuleName
1                  CHI2523    Business

Course:

CourseId (PK auto)  CourseName
1                    Business and Computing
2                    ICT
3                    Sports

Course_Module:

CourseId (PK) ModuleId (PK)
1             1 
2             1

Session:

SessionId (PK auto)  SessionName  ModuleId (FK)
3                    DFRER        1

Student:

StudentId (PK auto)  StudentAlias StudentForename  StudentSurname  CourseId (FK)
1                    u03824       Bill             Murphy          1
2                    u38492       Conrad           Jones           2
3                    u48383       Jane             Peters          1
4                    u34322       Morgan           Gray            2
5                    u39292       Bilal            Tuddy           3

Student_Session:

SessionId (PK)  StudentId (PK)
3               1
3               2

What I want the query to be able to find is all of the remaining students that are not currently taking the selected assessment but who are legible to take the assessment.

So to be able to do this we have to:

  • Look at what the selected session is by looking up SessionId in Session Table

  • See which module that SessionId belongs to by seeing the ModuleId in Session Table.

  • See which courses that ModuleId is in by looking up Course_Module table

  • Look up each student’s course by looking at CourseId in student table that matches with the CourseId‘s from the Course_Module Table

  • Display all students who belongs to the Course where the module is in, but only dislay students who are not currently in the session (or in other words not in the Session Table taking the selected SessionId.

So if the SessionId chosen is 3, then the students it should output are:

StudentId (PK auto)  StudentAlias StudentForename  StudentSurname  CourseId (FK)
3                    u48383       Jane             Peters          1
4                    u34322       Morgan           Gray            2

This is because:

  • SessionId 3 belongs to ModuleId 1

  • ModuleId belongs to CourseId 1 and 2

  • Looking up CourseId 1 and 2 there are 4 students who take that course

  • But 2 of those students are already taking SessionId 3 when looking at Student_Session Table, so only display the other 2 students as they are currently not taking the session

My question is how is the query suppose to be written to be able to achieve the example mentioned above? I have made a start on the query but need someone’s help to enhance it so it meets with the repuirements of the example above:

SELECT s.StudentId, StudentAlias, StudentForename, StudentSurname
FROM Session s 
INNER JOIN Module m ON m.ModuleId = s.ModuleId
INNER JOIN Course_Module cm ON cm.ModuleId = m.ModuleId
INNER JOIN Student s ON cm.CourseId = s.CourseId
INNER JOIN Student_Session ss ON s.StudentId = ss.StudentId
WHERE s.SessionId = 3
ORDER BY StudentAlias;

I don’t know how to check to see which students are/are not legible and then selecting only those students who are legible for taking assessment but who are not currently taking part in assessment

  • 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-17T00:52:31+00:00Added an answer on June 17, 2026 at 12:52 am
    SELECT  e.*
    FROM    Session a
            INNER JOIN Module b
                ON a.ModuleID = b.ModuleID
            INNER JOIN Course_Module c
                ON b.ModuleID = c.ModuleID
            INNER JOIN Course d
                ON c.CourseID = d.CourseID
            INNER JOIN Student e
                ON d.CourseID = e.CourseID
            LEFT JOIN Student_Session f
                ON f.sessionID = a.SessionID AND
                    f.studentID = e.studentID
    WHERE   a.SessionID = 3 AND
            f.studentID IS NULL
    ORDER   BY e.STUDENTALIAS
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about retrieving data using SQL i want to get count(comments_id)
I want to make one question about oracle/sql query. I have some data like
Hello everybody Well my question is about sql commands... If I have 2 tables
I have a question about updating table through t-sql. The client may want to
I have a question about the fastest way to perform a SQL Server query
I want to ask a question about the SQL. I have the following table.
I have a question about a SQL query I am trying to write. I
I have asked a question about how to retrieve data from different tables in
I have a question about SQL Server indexes. I'm not a DBA and assume
i have a general question about how sql server evaluates the joins.The query is

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.