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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:55:49+00:00 2026-05-31T07:55:49+00:00

I’m new to SQL and I am having trouble even starting this query. If

  • 0

I’m new to SQL and I am having trouble even starting this query.

If a student has a record in ‘2012’, list that record and all of their previous records.

A simplified data set:

ASSIGNMENTS

STUDENT_ID    BOOK_TITLE   TERM

001 MOBY DICK 2009 002 ULYSSES 2009 003 HAMLET 2009 004 1984 2009 005 HAMLET 2009 004 WAR & PEACE 2010 003 THE TRIAL 2010 004 MOBY DICK 2011 001 -NULL---- 2012 004 -NULL---- 2012

Results should be the record of those registered in a given term followed by that student’s previous records. The goal is for the user to look at currently registered students (NULL value in book title) and make sure they don’t assign a book the student has already read.

STUDENT_ID   BOOK_TITLE   TERM
001 -NULL---- 2012
001 MOBY DICK 2009
004 -NULL---- 2012
004 MOBY DICK 2011
004 WAR & PEACE 2010
004 1984 2009

Any pointers/starting directions would be greatly appreciated! I have tried messing around with 'with', multiple inner joins, but I am not getting anywhere. I keep thinking about if..then syntax that doesn't really work in SQL?

  • 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-31T07:55:50+00:00Added an answer on May 31, 2026 at 7:55 am
    SELECT STUDENT_ID, BOOK_TITLE, TERM
      FROM ASSIGNMENTS
      WHERE STUDENT_ID IN
       (SELECT DISTINCT STUDENT_ID FROM ASSIGNMENTS WHERE TERM = 2012)
      ORDER BY STUDENT_ID, TERM DESC
    

    To come up with this answer first I created a query that matched your expected result format. Then I added the where criteria for “only students currently registered”.

    If you want to parameterize it put @Term instead of 2012. You could also run it off null book titles using WHERE BOOK_TITLE IS NULL

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.