|
CSCI A114 / INFO I111
Lecture Notes Twelve
First semester 2001-2002
|
Queries.
In class today we will solve the problem posed last time.
We will also work on the following problem.
Assume the following database:
Justify it.
Think of some examples of data that could go in it.
Then write the following queries:
- List the names of all courses, their
department, and the number of credits for each.
- List the names, home towns, and home states
of all students.
- List all values in the
COURSES table.
- List all values in the
TEACHERS table.
- List the course name, department, and number of credits
for all three credit courses.
- List the names and salaries of teachers earning more than
$30,000.
- Who are all the male students.
- List the names and addresses of all female students from Chicago.
- Which Math courses have 3 or more credits?
- List the name, sex, city, and state for all students who are either from
Connecticut or from a city called Erie.
- List the names, cities, states and zip codes of all students whose zip codes
are between 20000 and 29999 or who live in a city called Erie.
- List the names and states of all students who are not from Illinois.
- List the names and salaries of teachers who make between $30,000 and $35,000.
- List the names, cities, states and zip codes of students whose zip codes are
NOT between 20000 and 29999.
- List the name and sex of every student whose name begins with 'Jo'.
- List the names and home states of all students from states that begin with the
letter 'C';
- List the names and phone numbers of all teachers whose phone numbers do NOT begin
with 257.
- List the names and departments of all Math and English courses.
- List the names, cities, and states of all students who are NOT from California or Illinois.
- List the entire contents of any records in the
ENROLLS table with a
NULL value for grade.
- List the names, cities, states, and zip codes for all students whose zip codes are not
NULL.
- Give an alphabetical list of teachers and their phone numbers.
- Give an alphabetical list of teachers and their phone numbers.
- Give a list of teachers and their phone numbers in reverse alphabetical order.
- List the names, cities, and states of all students ordered first by state, then by
city within that state.
- List all three credit courses alphabetically by department.
- What would each teacher's salary be if he or she received a 5.5% cost of
living increase and a $1,500 merit increase?
- What is the largest salary paid to a teacher?
- What is the lowest grade earned by a student?
- What is the total of all teacher salaries?
- What is the total salary for all teachers tearning over $30,000?
- What is the average of all teacher salaries?
- How many students are there?
- How many teachers earn over $30,000?
- How many different states do students come from?
- List the number of students enrolled in each course?
- List the number of courses taken by each student.
- List the average grade and number of courses taken by each student.
- Assuming a fee of $450.00 per course, determine each student's total tuition bill.
- List the average grade and number of students for each section of each course.
- List the average grade and number of courses taken by students with an average grade
of more than 2.5.
- List the average grade and number of students for each section with more than four students.
- List all teacher names along with all the values for teacher number and course number
contained in the
SECTIONS table.
- Which teachers teach which course? (List the teachers by name).
- What is the maximum
enrollment in each section of each course?
- List the grades received by each student.
- Which students from California or Illinois got 'A's or 'B's?
- Assuming that tuition is $450.00 per course, what is Larry Bird's total tuition bill?
(Larry Bird is a student).
- List the teacher for and number of students in each section. Order this list of
courses by number of students, from largest to smallest.
- List the names and grades of all students enrolled in section 1333 of A114.
- For each department, list its courses and sections together with the number of
students in each.
- List the names of all teachers, along with the names and numbers of the courses
taught by each.
- In which courses did any female student get an A? (List both the courses and the
students by name).
- List the names of all teachers and their departments, ordered alphabetically by department.
- List each student's grade for each course. Order the list alphabetically by course name,
then, for each course, by student name.
- Which courses are the students from Pennsylvania, California, and Connecticut taking?
- List alphabetically the names and grades of all male students enrolled in M119.
- How many students are in Dr. Engle's English class?
- Produce a list of the names and addresses of Dr. Horn's students. Order the list
alphabetically by student name.
- Produce a roster for each course by teacher, listing the courses and sections
they teach along with the names of all students enrolled in each.
- What is the total number of students taught by each teacher?
- List in descending order the total number of credits awarded for each course.
- How many students of each sex are enrolled in A201?
Through queries like these we are going to learn SQL.
We'll cover them slowly, and completely, and the final will contain SQL queries like these.
Last updated: October 4,
2001 by Adrian German for A114/I111