PUG Code Output & Accessing to a SQL Database Questions – Description
INSTRUCTIONS
Write 10 SQL statements against the STUDENT schema. Your statements should run error-free and should be valid. Submit two separate files: one plain text file (.txt or .sql file) with your statements only (non-code should be properly commented); and the other document (doc/docx/pdf) include both your statements and your query results (copy and paste text or screen shots).
Q1. Show all students who has a registration date of 1/25/2007. Display salutation, first name inital, and full last name in all upper cases in one column labeld “Student List”. (HINT: use functions such as UPPER and SUBSTR)
Sample Result:
Student List
Mr. R SHI
Ms. H LOPEZ
Q2. Display the number of students who live on the 40th St in Brooklyn, NY. (HINT: use the COUNT function and join table STUDENT with ZIPCODE)
Q3. Show section information for all Programming related courses (description has “Programming”), excluding “Intro to Programming” or any Java related programming courses. Dispaly Course_No, course description, Section_No, section location, and section capacity. If a course has no section, then display “N/A” for section location and leave other section related columns blank. (HINT: left join COURSE and SECTION; use the NVL function)
Q4. Show the address information for all Flushing, NY students who live in an apartment (if address contains “#”). Display student first name, last name, street information (number and street name), and apartment number. (HINT: use string functions such as SUBSTR and INSTR)
Sample Result:
FIRST_NAME LAST_NAME STREET_INFORMATION APARTMENT_NUMBER
Mary Axch 144-70 41st Ave. #4T
Q5. For sections offered for Intro To Programming, calculate and display number of sections offered, total capacity, lowest capacity, highest capacity, and average capacity. (HINT: use functions such as COUNT, SUM, MIN, MAX, and AVG)
Q6. List all course sections that have a start date on or after 6/1/1999 and have not been enrolled by any student. Display section ID, course No, start_date_time. (HINT: use left join and TO_DATE function)
Q7. For all Programming related course sections taught by Anita Morris, calculate and list total number of sections and total capacity. (HINT: join INSTRUCTOR, SECTION, and COURSE)
Q8. List all students who took a course from Anita Morris and who enrolled 90 days or more before section start date. Display student first name, last name, enroll date, section start date, and instructor phone number. (HINT: join STUDENT, ENROLLMENT, SECTION, and INSTRUCTOR; use section.start_date_time – enrollment.enroll_date to calculate number of days in between)
q9. For all sections taught by Anita Morris, calculate the average of the Final grade (HINT: join INSTRUCTOR, SECTION, ENROLLMENT, and GRADE; use FI as grade_type_code)
q10. Find any student/instructor pairs so that the student has taken a course taught by the instructor and they live in the same zipcode. Display student first and last name, instructor first and last name, and their zipcode
Learning Resources
https://www.w3schools.com/sql/sql_join.asp
The post PUG Code Output & Accessing to a SQL Database Questions first appeared on .