SECTION 1: Single-Table SQL Queries -- --******************************************* -- 1. Write a query to display customers’ last names, first names, and email addresses. -- Sort your results by last name and first name. -- 2. Use the concatenation operator || to concatenate the customers’ last and first names into one column. -- Leave a comma and a space between the last and first names. -- Your results should display in 1 column. -- Use a column alias to name the one column “Customer Full Name”. -- Sort your results by the column alias in descending order. -- 3. Using the concatenation operator || -- Write a query that displays the customers’ first name, last name, and email address in this sentence: -- -- The customer [FIRST_NAME] [LAST_NAME] can be reached at the email address [EMAIL]. -- -- [FIRST_NAME], [LAST_NAME], and [EMAIL] are placeholders for values from those columns. -- Sort your results by last name and first name.
-- SECTION 1: Single-Table SQL Queries
--
--*******************************************
-- 1. Write a query to display customers’ last names, first names, and email
addresses.
-- Sort your results by last name and first name.
-- 2. Use the concatenation operator || to concatenate the customers’ last and
first names into one column.
-- Leave a comma and a space between the last and first names.
-- Your results should display in 1 column.
-- Use a column alias to name the one column “Customer Full Name”.
-- Sort your results by the column alias in descending order.
-- 3. Using the concatenation operator ||
-- Write a query that displays the customers’ first name, last name, and email
address in this sentence:
--
-- The customer [FIRST_NAME] [LAST_NAME] can be reached at the email
address [EMAIL].
--
-- [FIRST_NAME], [LAST_NAME], and [EMAIL] are placeholders for values from
those columns.
-- Sort your results by last name and first name.
-- 4. Write a query that displays a list of employees.
-- Display these Employee data:
-- Hire Date
-- Last Name
-- First Name
-- Current Salary
-- Current Salary increased by 5% (using an expression)
-- Sort by hire date - most recent first - and then employee last name and
first name.
-- 5. Write a query to display a list of unique (no duplicates) customer IDs
that have placed orders.
-- Sort by Customer_ID.
-- 6. Write a query to display details (all columns) for employees that
-- Are managed by Kevin Mourgos
-- Have a salary less than or equal to $10000
-- Have a phone number that ends in 4
-- Sort the results by salary (descending) and then by the employees’ last and
first names.
-- 7. Using Boolean operators (AND, OR) and comparison operators (=, >, <, >=, <=,
!=), write a query to display details for employees
-- That work in the Sales or Marketing departments (DEPARTMENT_IDs 20 and
80)
-- AND have a salary greatee tham or equal to $5,000 and less than or
equal to $10,000.
-- Sort the results by salary (descending) and employees’ last names and first
names.
-- 8. Rewrite the query in the previous question using the operators IN and
BETWEEN.
-- 9. Using IN, write a query to display
-- The names and job IDs of the employees
-- In the sales and marketing departments (DEPARTMENT_IDs 20 and 80).
-- Sort the results by department and the employees’ last and first names.
-- 10. Rewrite the query in the previous question to find the employees in the
other departments by adding JUST ONE WORD to that query.
--**********************************************************
-- SECTION 2: Using JOINS
--**********************************************************
/*
1. Write a query using a join that displays
Department names (not Department_IDs)
Employees’ IDs, last & first names
Sort your results by department name and employee last and first name.
NOTE: INNER JOIN is OK here.
NOTE: I suggest you use table aliases.
*/
/*
2. Write a query using a join that displays
Department names (no DEPARTMENT_IDs).
Job titles (not Job_IDs)
Employees’ IDs, last & first names,
Sort your results by department name, job title, and employee last and first
name.
NOTE: INNER JOIN is OK here.
NOTE: I suggest you use table aliases.
*/
/*
3. Write a query using a self-join to display
Employees’ IDs and names along with
Their manager’s ID and name.
Use column aliases so that it is clear which columns are for the Manager and
which columns are for the Employee.
Display Manager data first.
Sort your results by the managers’ last & first names and then by the
employees’ last & first names.
NOTE: INNER JOIN is OK here.
NOTE: I suggest you use table aliases.
*/
/*
4. The company would like to identify
All of the customers that have never placed an order.
Write a query using a join that provides this information.
Your results should include all the customer details.
Sort your results by the customers’ last & first names.
NOTE: INNER JOIN will NOT work here.
NOTE: I suggest you use table aliases.
*/
/*
5. The company needs a list of every Customer and every Book.
In addition to
Customers who have purchased Books and the Books purchased,
This report should also include
Customers who have not purchased Books
Books that have not been purchased.
NOTE: This should NOT be a Cartesian Product.
The managers need to see:
Customer_Id
Last_Name
First_Name
ISBN
Book_Title
Book_Price
For those Books that have been purchased, they also need to see:
Order_Number
Order_Date
Unit_Price
Quantity
Sort your results by cistomer last and first name, book title, and order date
NOTE: INNER JOIN will NOT work here.
NOTE: I suggest you use table aliases.
![PK
FK
PK Country_Code
Country_Name
Region_ID
PK
FK
PK
U
PK Department ID
FK
PK
Legend
Tables provided
Tables you complete
FK Manager_ID
FK
Location_ID
FK
FK
Region ID
Region_Name
PK
FK
FK
Location ID
Street
City
State_Province
Postal Code
Country_ID
Department_Name
Customer ID
First_Name
Middle Name
Last Name
Email
Phone
Birth Date
Gender
Location_ID
Order Number
Order Date
Order_Total
Customer_ID
Sales Person ID
Order Item ID
Unit Price
Quantity
Order Number
ISBN
HOL_REGIONS
INTEGER
VARCHAR2(250)
HOL_COUNTRIES
CHAR(2)
VARCHAR2(250)
INTEGER
HOL_LOCATIONS
INTEGER
VARCHAR2(250)
VARCHAR2(250)
CHAR(2)
VARCHAR2(50)
INTEGER
HOL_DEPARTMENTS
INTEGER
VARCHAR2(250)
INTEGER
INTEGER
HOL_CUSTOMERS
INTEGER
VARCHAR2(250)
VARCHAR2(250)
VARCHAR2(250)
VARCHAR2(250)
VARCHAR2(50)
DATE
VARCHAR2(50)
INTEGER
HOL_ORDERS
INTEGER
DATE
NUMBER(18,2)
INTEGER
INTEGER
HOL_ORDER_ITEMS
INTEGER
NUMBER(12,2)
INTEGER
INTEGER
INTEGER
PK
FK
NN
U
PK Employee ID
First Name
Middle_Name
NN
PRIMARY KEY
FOREIGN KEY
NN Last Name
Email
Phone
NOT NULL
UNIQUE
Hire Date
Current_Salary
Commision_Pct
FK
FK
FK Department_ID
Bonus
Job ID
Manager_ID
PK Job ID
NN
FK
PK
NN
PK Job_History_ID
FK
Employee_ID
Start Date
End Date
Job_ID
Job Title
Max_Salary
Min_Salary
FK
FK Department_ID
PK ISBN
NN
Book Title
Book Description
Book Price
Book Reviews
User_Rating
Book_Category_ID
HOL_EMPLOYEES
INTEGER
VARCHAR2(250)
VARCHAR2(250)
VARCHAR2(250)
VARCHAR2(250)
VARCHAR2(50)
DATE
NUMBER(12,2)
NUMBER(2,2)
NUMBER(12,2)
Book_Category_ID
Book_Category_name
INTEGER
INTEGER
INTEGER
HOL_JOBS
INTEGER
VARCHAR2(250)
NUMBER(12,2)
NUMBER(12,2)
HOL_JOB_HISTORY
IDENTITY
INTEGER
DATE
DATE
INTEGER
INTEGER
HOL_BOOKS
INTEGER
VARCHAR2(250)
VARCHAR2(4000)
NUMBER(12,2)
INTEGER
NUMBER(4,2)
INTEGER
HOL_BOOK_CATEGORY
INTEGER
VARCHAR2(250)
Book_Category_Description VARCHAR2(4000)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff5687225-f4ce-4b08-8a49-c9e8248dc732%2Fec388455-0da2-4d5e-8609-f345bf1954b1%2F2pt7pme_processed.jpeg&w=3840&q=75)
![H
HOL_REGIONS
PK Region ID
HOL_JOBS
PK Job ID
HOL_CUSTOMERS
PK Customer ID
KFK Location_ID
++
++
H
To HOL_LOCATIONS
DBMS 130: HOL Small Company ERD
HOL_COUNTRIES
PK Country_ID
FK Region_ID
HOL_JOB_HISTORY
PK Job History_ID
FK Employee_ID
FK Job_ID
FK Department_ID
HOL_ORDERS
PK Order Number
KFK Customer_ID
|+
+H
HOL_LOCATIONS
PK Location ID
KFK Country_ID
HOL_EMPLOYEES
HPK Employee ID
FK Department_ID
FK Job_ID
HOL_ORDER_ITEMS
PK Order Item ID
FK ISBN
KFK|_Order_Number
+H
HOL_DEPARTMENTS
HPK Department ID
FK Location_ID
HOL_BOOKS
+ PK ISBN
FK Book_Category_ID
++
HOL_BOOK_CATEGORY
KPK Book_Category_ID](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff5687225-f4ce-4b08-8a49-c9e8248dc732%2Fec388455-0da2-4d5e-8609-f345bf1954b1%2Fhsodid_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Disclaimer:
“Since you have posted a question with multiple sub parts, we will provide the solution only to the first three sub parts as per our Q&A guidelines. Please repost the remaining sub parts separately.”
Introduction:
It is a standard programming language used to manage and manipulate relational databases. It is used to insert, update, and delete data, as well as retrieve data from databases in a structured and organized manner.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)