Question

This is a database with two tables relating to students at a school. Each student has...

This is a database with two tables relating to students at a school. Each student has a unique ID. There is a backlog table that maintains a record of active backlogs for each student.

Write a query my oracle sql to print the names of the students who have at least one active backlog. The names should be printed in ascending order.The results should be in the following format: NAME

Note: There could be students with the same name but they would have different IDs.

Schema

Student Table

Name Type Description
ID INteger This is the student's ID. Also Primary key
Name String This is the name of the student

Backlog Table

Name Type Description
Student_id Integer This is the student's ID
subject_ID String This is the subject ID.

no complicated answer explanation, just working query.

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

Let’s consider below sample data for tables:

Student:

ID

Name

1

Adam

2

Denial

3

Recklis

4

Adam

Backlog:

Student_ID

Subject_ID

1

DBMS

1

CSO

2

DBMS

4

DBMS

Required Query: Please find below the query to find the required data:

select s.Name as 'NAME' from Backlog b left join Student s on b.Student_ID = s.ID group by s.ID

Result: It will show the below data:

**As per instructions, a student can have same Name, thus the query will return same name based on ID

NAME

Adam

Adam

Denial

Query Description: The query will join two tables based on Student -> ID and Backlog -> Student_ID.

Query will traverse all records in Backlog table and find the corresponding Name in Student -> Name column.

Group by ID is used as there can be many columns which will have same student ID i.e. ID 1 has 2 backlogs and result will show Adam twice for ID 1. Group By ID will remove the duplicates for same student and return only single record for all students.

Order By s.Name will sort the names in ascending order.

Add a comment
Know the answer?
Add Answer to:
This is a database with two tables relating to students at a school. Each student has...
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
  • Consider the database schema of college database. Students have a major department and take classes where...

    Consider the database schema of college database. Students have a major department and take classes where faculty can be met. Student (cwid int, name, text, age int, majorDept text) Department (name text, chair text) Faculty (name text, deptName text) Enrollment (facName text, studID int) Note that the underlined attributes are primary keys. studID, chair, deptName of Faculty, facName and majorDept of Student are foreign keys to cwid, name of Faculty, name of Department, name of Faculty and also name of...

  • Suppose that there are three relationships in a database: Student relationship: S(SNO, SNAME, AGE, GENDER, DEPT)...

    Suppose that there are three relationships in a database: Student relationship: S(SNO, SNAME, AGE, GENDER, DEPT) Enroll relationship: SC(SNO, CNO, GRADE) Course relationship: C(CNO, CNAME) Here, the abbreviation and their full name correspond as: SNO Student Id number DEPT Student department SNAME Student name CNO Course number AGE Student age GRADE Course grade for certain student GENDER Student gender CNAME Course name Query the following in T-SQL format: Query the id number of the students who at least enrolled C2...

  • 5. Consider database system with two tables at different two sites as follow: Site 1 Student...

    5. Consider database system with two tables at different two sites as follow: Site 1 Student Table Student-ID Student -NAME Address 200 Records, each record 50 bytes Student-ID = 10 bytes, Student -NAME 20 bytes, Address 20 bytes Site 2 Course Table Course - ID Course -Name Student-ID 40 records, each record 50 bytes Course -ID 20 bytes, Course -NAME 30 bytes Consider the queryQ For each Student, retrieve student-NAME and Course -Name for all students who study courses Suppose...

  • A state-wide land tax assessment database has two tables: LandParcel that stores a set of land...

    A state-wide land tax assessment database has two tables: LandParcel that stores a set of land parcels, and ZoningTypes that stores a set of zoning codes and zoning types. The LandParcel table has 5 columns: ParcelNumb as text indicating each parcel's unique number defined by the State, Zoning as an integer number indicating the numerical code of a zoning type and each land parcel belongs to one zoning type, Owner First Name and Owner Last Name as text indicating the...

  • 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...

  • May I ask the SQL code as follows? The relational database moviedb has the following database...

    May I ask the SQL code as follows? The relational database moviedb has the following database schema: Movie(title, production year, country, run time, major genre) primary key : {title, production year} Person(id, first name, last name, year born) primary key : {id} Award(award name, institution, country) primary key : {award name} Restriction Category(description, country) primary key : {description, country} Director(id, title, production year) primary key : {title, production year} foreign keys : [title, production year] ⊆ Movie[title, production year] [id]...

  • Consider the below schema of the university database (keys are in bold and underline): Students(stuID: Integer,...

    Consider the below schema of the university database (keys are in bold and underline): Students(stuID: Integer, stuName: String, gender: String, age: Integer, gpa: Float) Departments(deptName: String, numPhDs: Integer) ProfessorWorks(profID: Integer, profName: String, deptName: String) CoursesOffer(cNo: String, cTitle: String, deptName: String) Majors(deptName:  String, stuID: Integer, degreeProgram: String; attendYear: String, attendSemester: String) Sections(cNo: String, academicYear: String, semester: String, sectNo: Integer, profID: Integer) Enrolls(stuID: Integer, cNo: String, academicYear: String, semester: String, sectNo: Integer, grade: String) Write the following queries in Relational algebra. Print...

  • Need help writing SQL statements. The questions involved use the following database Student SID – Integer...

    Need help writing SQL statements. The questions involved use the following database Student SID – Integer – Primary Key SName - String Address - String Classes ClassID – Integer – Primary Key ClassName - String Credits - Integer Grades SID – Integer – Primary Key CID – Integer – Primary Key Grade - Integer Q1 – Write a script that creates a view to show all the students and all the classes they took and the grades they got in...

  • rider_student Column Data Type Description student_id integer the primary key first_name varchar(25) student first name last_name...

    rider_student Column Data Type Description student_id integer the primary key first_name varchar(25) student first name last_name varchar(25) student last name major_id integer the ID of the student's major; a foreign key for the major_id in the rider_major table rider_major Column Data Type Description major_id integer the primary key major_name varchar(50) student first name major_description varchar(100) student last name Use the Tables above to answer the questions. Questions: 1. Write a SQL statement to add a student record to the rider_student...

  • 3. Suppose the University has two types of academics: students and lecturers. Both of these have...

    3. Suppose the University has two types of academics: students and lecturers. Both of these have names and ids, but students attend lectures while lecturers give them class Studentí private: string name; string id; public: Student(string name, string id); string getName O; string getIDO; void attendLecture (); class Lecturer< private: string name; string id; publiC: Lecturer (string name, string id); string getName (); string getIDO; void giveLecture(); ti (a) Write the header for a class called Academic and update the...

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