Worksheet 2. DML-Aggregate Functions
Worksheet 2. DML-Aggregate Functions
The table below stores the inventory of a pet shop. Study the purpose of each column
then answer the questions that follow. Answer completely by writing both the query and
the result, unless the instruction says otherwise. Enjoy!
● In your database, create a table named stocks using the following schema.
● Insert the following records in the created table and write atleast one INSERT
Query below.
INSERT INTO
_________________________________________________________________
____________________________________________________________________________
____________________________________________________________________________
____________________________________________________________________________
STOCKS
ID CATEGORY BREED GENDER IN_STOCK PRICE
1 Rabbit Holland Lop M 10 600
2 Rabbit Holland Lop F 17 800
3 Dog Chow-chow M 2 15000
4 Dog Chow-chow F 2 25000
5 Rabbit Angora M 10 1500
6 Rabbit Angora F 7 1800
7 Guinea Peruvian M 5 550
8 Guinea Peruvian F 10 1500
Answer the following questions by applying the aggregate functions discussed in the
modile. Write your query statement on the spaces provided and the corresponding
output that will answer the questions below. You may screenshot the result and paste in
the spaces provide.
1. How many animals does this pet shop have?
Query Syntax:
SELECT
FROM
Result:
FROM
WHERE
Result:
FROM
WHERE
GROUP BY
Result:
4. How many breeds of each animal does this pet shop have?
Query Syntax:
SELECT
FROM
GROUP BY
Result:
5. Let us suppose that this pet shop is giving 25% discount for purchasing pair of any
animal. Write a query that will show the matrix below:
CATEGORY BREED PricePerPair Discount
Dog Chow-chow 40000 10000
Guinea Pig Peruvian 2050 512.50
Rabbit Angora 3300 825
Rabbit Holland Lop 1400 350
SELECT
FROM
GROUP BY
● Export the database and include it the submission. Save this file in PDF
using the format “Worksheet2-2-YourLastnameFirstname-Section.pdf”