1. Active BacklogsThere is a database with two tables relating to students at a school. Each student has aunique ID. There is a backlog table that maintains a record of active backlogs for each studentWrite a query to print the names of the students who have at least one active backlog. Thenames should be printed in ascending order. The result should be in the following format:NAMENote: There may be students with the same name but with different IDs.Schema
Answers
Answered by
28
Consider there are two tables STUDENT and BACKLOGS. The first table contains the name and unique student id of the student. The second table contains student id and backlog.
- SELECT DISTINCT student.ID, student.NAME FROM backlog INNER JOIN student ON student.ID = backlog.STUDENT_ID ORDER BY student. NAME ASC
- Distinct is for uniqueness.
- Inner join combines records from different tables.
- Order by segregates as per the given constraints.
- ASC is to write in ascending order.
Similar questions