Exercise 8: Write Aggregation Queries in SQL

Exercise 6.4.6 from the textbook. Write the following queries, based on the database schema

Product(maker, model, type) 
Laptop(model, speed, ram, hd, screen, price)
PC(model, speed, ram, hd, price) 
Printer(model, color, type, price)

of Exercise 2.4.1, and evaluate your queries using the data of that exercise .

  1. Find the average speed of PC’s.

  2. Find the average speed of laptops costing over $1000.

  3. Find the average price of PC’s made by manufacturer “A”.

  4. Find the average price of PC’s and laptops made by manufacturer “D”.

  5. Find, for each different speed, the average price of a PC.

  6. Find, for each manufacturer, the average screen size of its laptops.

  7. Find the manufaturers that make at least three different models of PC.

  8. Find for each manufacturer who sells PC’s the maximum price of a PC.

  9. Find, for each speed of PC above 2.0, the average price.

  10. Find the average hard disk size of a PC for all those manufacturers that make printers.