Question

Write an SQL query using the university schema to find the ID of each student who has never taken a course at the university.University Schema student takes ID ID пате course_id sec id semester уеar grade dept_name tot_cred section course |department

SQL question, you can right-click the picture and select open in a new tab for a better-looking experience.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the SQL query to list all student id who have not taken any course in university.

Left join is sued here between table student and takes. This will result all student id from the student table and corresponding course_id of students. Students who have not taken any course will be shown as null course_id. Then the filter is used in WHERE clause which will result in only those student id with course_id as null.

Query-


SELECT s.ID, t.course_id
FROM student AS s
LEFT JOIN takes AS t
ON t.ID = s.ID
WHERE course_id IS NULL;

Add a comment
Answer #2

SELECT Student.ID

FROM Student OUTER JOIN Course ON Student.ID != Course.ID;


Add a comment
Know the answer?
Add Answer to:
SQL question, you can right-click the picture and select open in a new tab for a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assume that the takes relation has not yet been defined. Give an SQL statement that adds...

    Assume that the takes relation has not yet been defined. Give an SQL statement that adds the takes relation to the database. Assume that: •Id is an integer •course_id is a string of up to10 characters. •sec_id should be a non-negative integer. •the semester is a one-character field, equal to either ‘F’ or ‘S’, and the •year is an integer. •grade can be null, but if not, it should be a letter in the string ‘ABCDF’. Your statement must ensure...

  • Database concepts Find the names and ids of the students who have taken at most one...

    Database concepts Find the names and ids of the students who have taken at most one course in the Spring 2010 semester. Notice, at most one means one or zero. So, the answer should include students who did not take any course during that semester The data: create table classroom     (building       varchar(15),      room_number        varchar(7),      capacity       numeric(4,0),      primary key (building, room_number)     ); create table department     (dept_name      varchar(20),      building       varchar(15),      budget      numeric(12,2) check (budget > 0),      primary key (dept_name)     ); create...

  • This is database system concept. 1.Find the ids of instructors who are also students using a...

    This is database system concept. 1.Find the ids of instructors who are also students using a set operation. Assume that a person is identified by her or his id. So, if the same id appears in both instructor and student, then that person is both an instructor and a student. Remember: set operation means union, intersect or set difference. 2.Find the ids of instructors who are also students using the set membership operator. 3.Find the ids of instructors who are...

  • Consider the Schema diagram for a university database a. Find the IDs of all students who...

    Consider the Schema diagram for a university database a. Find the IDs of all students who have taken all of the CMPSC courses. Use the division operation. b. Do the same operation as in problem a, using only fundamental operations. student takes ID course id sec id semester 1er 4112 dept_name tot cred grade advisor section course_id sec id semester year building TOOM_10 time_slof_id course course id title dept name credits department dept name building budget time slot time slot...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT