Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL in Oracle. Write, exicute and print a query to list student names and grades

ID: 3871099 • Letter: S

Question

SQL in Oracle.

Write, exicute and print a query to list student names and grades (just two attributes) using the table alias feature. Restrict the list to students that have either an A or B in courses with ACCT prefixes only.

Here is how to complete this problem:

Get the statement to work as a COUNT of a join of the three tables, stdnt, grdrpt, and sctn. Use table aliases in the join condition (remember to use the /*comments*/). Note that a join of n tables requires (n-1) join conditions, so here you have to have two join conditions - one to join the stdnt and grdrpt tables, and one to join the grdrpt and sctn tables.

Next, modify the query and put the accounting (ACCT) condition in the WHERE clause.

Finally, modify the query and add the frade constraints. The number of rows should decrease. Note that if you have WHERE x and y or z, parenthies are optional, but the criteria will be interpretated according to precedence rules.

Explanation / Answer

Hi,

As the table structure is not shared, so I am making a small assumption that we have a common column called 'S_ID' in both tables namely stdnt, grdrpt. Similarly, assume we have a common column SEC_ID which is present in both stdnt and sctn table.
Also, assume course_name column is available in grdrpt table.

Query-

SELECT S.NAME, GRD.GRADE FROM
STDNT S
JOIN GRDRPT GRD
ON S.S_ID=GRD.S_ID
JOIN SCTN SC
ON S.SEC_ID=SC.SEC_ID
WHERE GRD.COURSE_NAME LIKE 'ACCT%'
AND GRADE IN('A','B');