Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 2

L-58

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

3. How many clients do we have that have an ID less than 100?


SELECT COUNT(ID)
FROM Customer
WHERE ID <100

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

TMG WS 2024 Seite 1 von 2


8. Calculate the total stock value (Stock*Price) of the expiring book stock.
SELECT ROUND(SUM(Book.Stock*Book.Price),2) AS "Stock Value"
FROM Book
WHERE Expiring="y"

9. Calculate the average grade of the course 101.238.


SELECT AVG(grade)
FROM course_details
WHERE course_id LIKE "101.238"

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"

TMG WS 2024 Seite 2 von 2

You might also like