# Introduction to Databases | Week 3

Course Name: Introduction to Databases

#### These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Knowledge Check: Operators

The following quiz makes use of the chinook database. This is a sample database for a fictitious digital media store. It is widely used for demonstration purposes in database courses. The database includes 11 tables of fictitious data including artists, albums, media tracks, invoices, and customers.
The chinook database is deployed on the Coursera platform. The “invoices” table contains a column called “Total” that shows the total amount to be paid by each customer. Some of the “Total” column values is shown below:

Q1. Add a 0.25 cent service fee to each value in the Total column. Complete the task using a SQL SELECT statement that includes a suitable operator. The output of your statement should be as follows:

``SELECT total + 0.25 FROM invoices;``

Q2. Apply a discount to your customers’ totals by deducting 0.15 cent from each value in the Total column. Complete the task using a SQL SELECT statement that includes a suitable operator. The output of your statement should be as follows:

``SELECT total - 0.15 FROM invoices;``

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q3. Double the value of each record in the Total column. Complete the task using a SQL SELECT statement that includes the multiplication operator “*”. The output of your statement should be as follows:

``SELECT total * 2 FROM invoices;``

Q4. Deduct 50% from each value in the Total column by dividing the total column by 2. Complete the task using a SQL SELECT statement that includes the division operator “/”. The output of your statement should be as follows:

``SELECT total / 2 FROM invoices;``

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q5. Use the modulus operator “%” to get the remainder of the total column value divided by 2.

``SELECT total % 2 FROM invoices;``

Self-review: ORDER BY and WHERE

Q1. The ORDER BY keyword in SQL sorts the records of a table column in descending order by default.

• True
• False

Q2. The output result of the following SQL statement is the data of all customers from Germany, as * in this context means “all columns”.
SELECT *
FROM customers
WHERE Country = “Germany”;

• False
• True

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q3. Choose the SQL statement that shows a list of all customers who live in India organized alphabetically from A to Z within a database table named “customers”.

``````SELECT *
FROM customers
WHERE country = "India"
ORDER BY FirstName DESC;``````
``````SELECT *
FROM customers
WHERE country = "India"
ORDER BY FirstName ASC;``````

``````SELECT *
FROM customers
WHERE country = "India"
ORDER BY FirstName ASC;``````

Q4. Identify the effect of the following SQL statement on the “Staff” table:
SELECT *
FROM staff
ORDER BY Country, StaffName;

• Displays the results ordered by country first then staff name.
• Orders the result by country and ignores the staff name.

Answer: Displays the results ordered by country first then staff name.

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Module quiz: SQL operators and sorting and filtering data

Q1. Which of the following SQL statements adds a \$2.00 service fee to the total price in a table called “Orders”, that lists the price of orders customers placed with a store?

• SELECT total + 2 FROM the Orders TABLE;
• SELECT total + 2 FROM Orders TABLE;
• SELECT total + 2 FROM Orders;

Answer: SELECT total + 2 FROM Orders;

Q2. What does the following SQL statement do?
SELECT total / 2 FROM Orders;

• It returns the value of total price column in the second row.
• It returns the result of total price divided by 2 for each cell in the total price column

Answer: It returns the result of total price divided by 2 for each cell in the total price column

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q3. The following SQL statement returns 2 percent of the total price:
SELECT total % 2 FROM Orders;

• False
• True

Q4. Which of the following SQL statements returns 50% of the total price? Choose all correct answers.

• SELECT total / 2 FROM Orders;
• SELECT total / 50% FROM Orders;
• SELECT total * 0.5 FROM Orders;
• SELECT total * 50 FROM Orders;

Answer: SELECT total / 2 FROM Orders;
SELECT total * 0.5 FROM Orders;

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q5. Select the right SQL statement to display the values of the total prices that are greater than \$140.

• SELECT total FROM Orders WHERE total >= 140;
• SELECT total FROM Orders WHERE total < 140;
• SELECT total FROM Orders WHERE total > 140;

Answer: SELECT total FROM Orders WHERE total > 140;

Q6. Does the following SQL statements sort the result-set of the total prices in ascending or descending order?
SELECT * FROM Orders ORDER BY total;

• Descending
• Ascending

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q7. The following SQL statement filters data based on ____
SELECT * FROM customers WHERE Country = “Germany”;

• ‘Country’ column with ‘Germany’ value
• ‘Germany’ column with ‘country’ value

Answer: ‘Country’ column with ‘Germany’ value

Q8. In SQL you can sort records in descending order using the DESCENDING keyword.

• True
• False

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera

Q9. The output of the following SQL query within the Orders table is: UK, UK, UK, France, France, Finland
SELECT DISTINCT Country FROM Orders;

• False
• True

Q10. What does the following SQL statement do?
SELECT * FROM Orders ORDER BY country, total;

• Orders the result by country first then total price.
• Orders the result by country and ignores the total price.

Answer: Orders the result by country first then total price.

These are answers of Introduction to Databases Week 3 Quiz Answers Coursera