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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:58:10+00:00 2026-06-14T02:58:10+00:00

I need create a query to find the names of drivers whose exam scores

  • 0

I need create a query to find the names of drivers whose exam scores get lower when they take more exams. So I have the following tables:

branch(branch_id, branch_name, branch_addr, branch_city, branch_phone);
driver(driver_ssn, driver_name, driver_addr, driver_city, driver_birthdate, driver_phone);
license(license_no, driver_ssn, license_type, license_class, license_expiry, issue_date, branch_id);
exam(driver_ssn, branch_id, exam_date, exam_type, exam_score);

**the exam_date is a date

So I am using the tables driver and exam. I would like to somehow check that the exam_date>anotherDate while at the same time checking that exam_score

*EDIT

This is what I came up with but I feel like some of the syntax is illegal. I keep getting a syntax error.

s.executeQuery("SELECT driver_name " +
"FROM driver " +
"WHERE driver.driver_ssn IN " +
"(SELECT e1.driver_ssn" +
"FROM exam e1" +
"WHERE e1.exam_score < " +
"(SELECT e2.exam_score FROM exam e2)" +
"AND e1.exam_date > " +
"(SELECT e2.exam_date FROM exam e2)");

EDIT! I got it working! Thanks for your input everyone!

SELECT driver.driver_name 
FROM driver
WHERE driver.driver_ssn IN
    (SELECT e1.driver_ssn 
    FROM exam e1, exam e2, driver d 
    WHERE e1.exam_score < e2.exam_score
    AND e1.exam_date > e2.exam_date 
    AND e1.driver_ssn=e2.driver_ssn)
  • 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-14T02:58:12+00:00Added an answer on June 14, 2026 at 2:58 am

    SELECT returns a set and you cannot compare a single value against a set. You can try something along these lines. This is similar to yours and doesn’t handle three exam case :-

    SELECT driver_name 
      FROM driver
      JOIN exam e1 ON driver_ssn
      JOIN exam e2 ON driver_ssn
     WHERE e1.exam_score < e2.exam_score
       AND e1.exam_date > e2.exam_date
    

    The query selects all pairs of exams taken by a driver in which the score is less and the date big

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

Sidebar

Related Questions

i need to change my query from native-query to ( named-query or create-query )
I'm used to create query with createQuery() instead of queryBuilder, but I need to
I have a query being created using OLEDB from access and need to get
I need create clone repository. but I do not know where can I get
I need to create a table result (and find out if it IS possible
I have a need to create a LINQ query that returns results based on
I have a query where I need to get post + every tag that
We have a list containing names of countries. We need to find names of
I have been thinking about a complicated view/query I need to create but I
I am new to SQL and databases.. I need to create an SQL query

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.