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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

-- 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)
Transcribed Image Text: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)
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
Transcribed Image Text: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
Expert Solution
Step 1

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

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
SQL Query
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education