Sie sind auf Seite 1von 3

1. Create a query that returns the average cost for all courses. (Round to two places).

SELECT ROUND(AVG(cost),2) FROM course;

2. Create a query that returns the total number of Students that registered during February 2007. Alias the column as "February_Registrations". SELECT COUNT(registration_date) AS February_Registrations FROM student WHERE TO_CHAR(registration_date, 'MON YYYY') = 'FEB 2007';

3. Create a query that returns the average, highest and lowest final exam scores for Section 147. SELECT ROUND(AVG(numeric_grade),2) AS Average, MAX(numeric_grade) As Highest, MIN(numeric_grade) As Lowest FROM grade WHERE grade_type_code = 'FI' and section_id = 147

4. List the city, state and number of zipcodes for all cities with more than two zipcodes. Arrange by state and city. SELECT city, state, COUNT(zip) AS Zipcodes FROM zipcode GROUP BY city, state HAVING COUNT(zip) > 2 ORDER BY state, city;

5.Provide a list of Sections and the number of students enrolled in each section for students who enrolled on 2/21/2007. Sort from highest to lowest on the number of students enrolled.

SELECT section_id, COUNT(enroll_date) As Enrolled FROM enrollment GROUP BY section_id, enroll_date HAVING TO_CHAR(enroll_date, 'MM/DD/YYYY') = '02/21/2007' ORDER BY Enrolled DESC, section_id DESC;

6. Create a query listing the student ID, Section ID and Average Grade for all students in Section 86. Sort your list on the student ID and display all of the average grades with 4 decimal places. SELECT student_id, section_id, ROUND(AVG(numeric_grade),4) As Average_Grade FROM grade GROUP BY student_id, section_id HAVING section_id = 86 ORDER BY student_id;

7. Create a query to determine the number of sections that student ID 250 is enrolled in. Your output should contain the student ID and the number of sections enrolled. SELECT student_id, COUNT(section_id) As Sections FROM enrollment GROUP BY student_id HAVING student_id = 250

8.List the section ID and lowest quiz score for all sections where the low score is greater than a B (greater than 80). Arrange by section id.

SELECT section_id, MIN(numeric_grade)

FROM grade GROUP BY section_id, grade_type_code HAVING grade_type_code = 'QZ' AND MIN(numeric_grade) > 80 ORDER BY section_id;

9. List the names of Employers having more than 5 student employees. Your output should contain the employer name and the number of student employees. Arrange the output on the number of employees from lowest to highest.

SELECT employer, COUNT(student_id) As Student_Employees FROM student GROUP BY employer HAVING COUNT(student_id) > 5 ORDER BY Student_Employees;

10. List the section ID, number of participation grades and lowest participation grade for all sections with more than 15 participation grades. SELECT section_id, COUNT(numeric_grade) AS Participation_Grade, MIN(numeric_grade) AS Lowest_Grade FROM grade GROUP BY section_id, grade_type_code HAVING grade_type_code = 'PA' AND COUNT(grade_type_code) > 15 ORDER BY section_id;

Das könnte Ihnen auch gefallen