Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1- Show the first name and last name of customers. SELECT CustFirstName,CustLastName FROM customers; Don't forget to select the database SalesOrder before running the SELECT

1- Show the first name and last name of customers.

SELECT CustFirstName,CustLastName FROM customers;

Don't forget to select the database SalesOrder before running the SELECT statement. You can select the database by using the following statement.

USE SalesOrder;

Pay attention to the spelling of columns. Small typos will raise an error. For instance,

SELECT CsutFirstName,CustLastName FROM customers;

ERROR Code: 1054. Unknown column 'CsutFirstName' in 'field list'

The Error code 1054 indicates the column CsutFirstName does not exist. The resolution is fixing the typo, and the statement should be:

SELECT CustFirstName,CustLastName FROM customers;

Pay attention to the spelling of tables. Small typos will raise an error. For instance, Now consider the following SELECT statement.

SELECT CustFirstName,CustLastName FROM customres;

ERROR Code: 1146. Table 'customres' doesn't exist

The Error code 1146 indicates the table customres does not exist. The resolution is fixing the typo, and the statement should be:

SELECT CustFirstName,CustLastName FROM customers;

2- Show the last name and first name of customers.

SELECT CustLastName,CustFirstName FROM customers;

3- Show customerID and their city of customers .

SELECT CustomerID,CustCity FROM customers;

4- Show customer's states (no duplicated).

SELECT DISTINCT CustState FROM customers;

5- Show customer's City and states (no duplicated).

SELECT DISTINCT CustCity,CustState FROM customers;

6- Show customers' zipecode (no duplicated).

SELECT DISTINCT CustZipCode FROM customers ;

7- Show all details of customers.

SELECT * FROM customers ;

8- Show customers' zipecode (no duplicated).

SELECT DISTINCT CustZipCode FROM customers ;

9- Show all details of vendors.

SELECT * FROM vendors;

10- Show the name and price of all products, order them based on their prices, the most expensive one on the top.

SELECT ProductNumber,RetailPrice FROM Products ORDER By RetailPrice DESC;

Order by clause represents the result, it does not change the way data is stored in tables. Note that by default Order by is ascending.

11- Show first and last names of employees and order them based on their states, only show the first 5

SELECT EmpFirstName,EmpLastName FROM employees ORDER By EmpState LIMIT 5;

12- Show the top five expensive products.

SELECT * FROM products ORDER By RetailPrioe LIMIT 5;

This homework has only one question.

Answer the following questions. Make sure you use comments in your SQL file to clarify/show which SQL statement is the answer to which question. The questions are:

1- Write an SQL query to show the CustomerName and Country of Customers.

2- Write an SQL query to show all Countries (no duplicates), order them alphabetically.

3- Write an SQL query to show the first name of all employees ordered by their last name in alphabetic order.

4- Write an SQL query to show the detail of all shippers.

5- Write an SQL query to show the top five expensive products.

6 - Write an SQL query to show all details of suppliers, only show five of them.

7- Write an SQL query to show all details of Categories.

8- Write an SQL query to show all details of Orders, show the recent ones on the top.

9- Write an SQL query to show product names, their units, and their prices.

10 - Write an SQL query to show all details of orders (from OrderDetails table).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Name elements that make for "fine dining."

Answered: 1 week ago