Professional Documents
Culture Documents
L-58 Students Solution
L-58 Students Solution
Information:
You can find the database under sql.idb.edu.
Tasks:
1. Count how many authors there are in our database. Each author should only be
issued once.
SELECT COUNT(DISTINCT Author)
FROM Book
2. We are interested in the average price for all books. Round the result to two dec-
imal places.
SELECT ROUND(AVG(Price),2)
FROM Book
4. Count all first names from customers where the first name equals Ingrid.
SELECT COUNT(First_Name)
FROM Customer
WHERE First_Name ="Ingrid"
5. What is the maximum stock of books whose price is greater than 100?
SELECT MAX(Stock)
FROM Book
WHERE Price > 100
6. Count how many students come from St. Polten (zip from 3100 to 3108).
SELECT COUNT(student_id)
FROM stud
7. Please indicate the highest, the lowest and the average price of a book. Make
sure that the labeling makes sense.
SELECT MAX(Book.Price) AS "highest price", MIN(Book.Price) AS "lowest price",
AVG(Book.Price) AS "average price"
FROM Book
10. How many course registrations are there in the 2014 summer semester?
SELECT COUNT(registration_date) "Number of registrations"
FROM course_details
WHERE semester_id="2014S"