Knowee
Questions
Features
Study Tools

Use a UNION to create a list of all the employee's and customer's first names and last names ordered by the last name in descending order.

Question

Use a UNION to create a list of all the employee's and customer's first names and last names ordered by the last name in descending order.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, I can help with that. However, I need to know the structure of your tables to provide an accurate SQL query. Assuming you have two tables, employees and customers, and both of them have first_name and last_name columns, the SQL query would look like this:

SELECT first_name, last_name
FROM employees
UNION
SELECT first_name, last_name
FROM customers
ORDER BY last_name DESC;

Here's a step-by-step breakdown of the query:

  1. SELECT first_name, last_name FROM employees: This part of the query selects the first and last names of all employees.

  2. UNION: This keyword combines the results of two or more SELECT statements without returning any duplicate rows.

  3. SELECT first_name, last_name FROM customers: This part of the query selects the first and last names of all customers.

  4. ORDER BY last_name DESC;: This part of the query sorts the combined list of employees and customers by last name in descending order.

Please replace employees and customers with your actual table names, and first_name and last_name with your actual column names if they are different.

This problem has been solved

Similar Questions

Show unique first names from the patients table which only occurs once in the list.

Select all records from the Customers table, sort the result reversed alphabetically by the column City.

Write a program that would print the information (name, year of joining, salary, address) of threeemployees by creating a class named 'Employee

Create and print a linked list with four (4) elements. The first letter of your last name will be the basis of the required values for your linked list.

Write a MySQL statement to sort the students in descending order of the last name

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.