# Calculating Fields - Exercise

Calculating Fields - Exercise

# Calculating Fields

Duration: 10 to 20 minutes.

In this exercise, you will practice writing `SELECT` statements with calculated fields.

1. Create a report that shows the unit price, quantity, discount, and the calculated total price using these three fields.
• Note for SQL Server users only: You will be using the `Order Details` table. Because this table name has a space in it, you will need to put it in double quotes in the `FROM` clause (e.g, `FROM "Order Details"`).
2. Write a `SELECT` statement that outputs the following.

## Solution:

```/******************************
SQL Server Solutions
******************************/
SELECT UnitPrice, Quantity, Discount, UnitPrice * Quantity * (1-Discount) AS TotalPrice
FROM "Order Details";

SELECT FirstName + ' ' + LastName + ' can be reached at x' + Extension + '.' AS ContactInfo
FROM Employees;

/******************************
Oracle Solutions
******************************/
SELECT UnitPrice, Quantity, Discount, UnitPrice * Quantity * (1-Discount) AS TotalPrice
FROM Order_Details;

SELECT FirstName || ' ' || LastName || ' can be reached at x' || Extension || '.' AS ContactInfo
FROM Employees;

/******************************
MySQL Solutions
******************************/
SELECT UnitPrice, Quantity, Discount, UnitPrice * Quantity * (1-Discount) AS TotalPrice
FROM Order_Details;

SELECT CONCAT(FirstName, ' ', LastName, ' can be reached at x', Extension, '.') AS ContactInfo
FROM Employees;```