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.
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