1 / 3

1. A plain query

This document presents a series of SQL queries designed to retrieve data from the "Students" and "Inroll" tables within an academic database, specifically focusing on the Computer Science (CS) department. The first query selects the last and first names of students majoring in CS. The second query finds the maximum grade for courses taken by these students, while the third query retrieves specific student information based on nested conditions related to coursework. The queries demonstrate both straightforward and complex data retrieval techniques.

daquan-neal
Download Presentation

1. A plain query

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1. A plain query SELECT "LastName", "FirstName" FROM "Students" WHERE "Department" = 'CS'; Query Plan: Query plan text: "Seq Scan on "Students" (cost=0.00..12.88 rows=1 width=236)" " Filter: (("Department")::text = 'CS'::text)"

  2. 2 A little complex query select I."Cid",max("Grade") from "Inroll" as I, "Students" as S where S."Sid" = I."Sid" And S."Department" = 'CS' group by I."Cid"; Query Plan:

  3. 3. Nested Query select "LastName", "Firstname" from "Inroll" as I, "Students" as S where S."Sid" = I."Sid" and I."Cid" = 'CS2223' and I."Sid" in (select "Sid" from "Inroll" where "Cid" = 'CS4432'); Query Plan:

More Related