Do You Want to Learn SQL?

Take our free eight day course, where I'll teach you in simple to understand English all you need to get started learning SQL.

For test exercise we’ll use the PizzaDB. You can find link to the database script on GIT.

You don’t need to have a database installed to do these exercise, just use the prompts below.

In these exercise we’ll write some queries using either the Product or Employee tables.

Exercise #1

What is the average price of a product by product type?

You can use the product table.  Display the ProductType and AveragePrice

/* Answer */
select ProductType, avg(Price) AveragePrice
from Product
group by ProductType

Hint: Use the AVG function to calculate the average.

Show the answer to see the query I wrote: Notice that I group by ProductType and the Price is an argument to the avg function.

Exercise #2

How may employees are there in the Employee table?

/* Answer */
select count(*)
from Employee

Hint: You can don’t need to use GROUP BY to answer this question.