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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:16:50+00:00 2026-06-18T02:16:50+00:00

I have a database of assessment outcomes, with fields identifying the pupil, grade, the

  • 0

I have a database of assessment outcomes, with fields identifying the pupil, grade, the year and term. The query below finds me pupils who have an assessment for a specific subject at some start and end point:

SELECT
  a1.PupilId
FROM assessment as a1
  JOIN assessment as a2
    USING (PupilId)
WHERE a1.GradeID in('1A','1B','1C')
    AND a2.GradeID in('5A','5B','5C')
    AND a1.NCYear = '1'
    AND a1.Term = '6'
    AND a2.NCYear = '2'
    AND a2.Term = '6'
    AND a1.Subject = '31'
    AND a2.Subject = '31'
    AND a1.Type = 'assessment'
    AND a2.Type = 'assessment'

This works fine, but now I want to find pupils who have the starting grade (i.e. NCYear=’1′ and Term=’6′) but don’t have an entry for the end grade. I’ve played around with NOT EXISTS, but can’t get it to work.

To clarify, here’s the assessment table:

id | Subject | PupilId | NCYear | Term | GradeID | Type
--------------------------------------------------------
1  | 31      | 1       | 1      | 6    | 1A      | assessment
2  | 31      | 1       | 2      | 6    | 5A      | assessment
3  | 31      | 2       | 1      | 6    | 1A      | assessment

The SQL query above should return PupilID 1. I need the query which will return PupilID 2, the start assessment is there but no end one.

Any suggestions?

  • 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-18T02:16:52+00:00Added an answer on June 18, 2026 at 2:16 am

    You need to use an OUTER JOIN:

    SELECT
      a1.PupilId
    FROM assessment as a1
      OUTER JOIN assessment as a2
        ON a2.PupilId = a2.PupilId AND a2.NCYear = '2' AND a2.GradeID in('5A','5B','5C') AND a2.Term = '6' AND a2.Subject = '31' AND a2.Type = 'assessment'        
    WHERE a1.GradeID in('1A','1B','1C')
        AND a1.NCYear = '1'
        AND a1.Term = '6'
        AND a1.Subject = '31'
        AND a1.Type = 'assessment'
        AND a2.PupilId IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have database table with few text fields which i use to filter data
I have database called Auth, there are fields: id, auth, is_active, created_at, updated_at i
I have database with following fields: id , q_id , text , session etc.
I have mapped several java classes like Customer, Assessment, Rating, ... to a database
i have database query: datareader.execQuery(select * from table); However sometimes database takes too long
I have database dbadmin , table - tbl_empreimburse with fields-emp_id,rem_amount,rem_date . I want to
I have database with multiple tables in Microsoft SQL Server with schema in tables
i have database with two values id and val so i want to ask
I have database application, I want to allow the user to restore the deleted
I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How

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.