Question: MYSQL DATABASE: 1) Using a simple equijoin (joined using the WHERE clause) or INNER JOIN syntax, write a SQL statement to return customer name (cust_name)

MYSQL DATABASE:

1) Using a simple equijoin (joined using the WHERE clause) or INNER JOIN syntax, write a SQL statement to return customer name (cust_name) from the Customers table and related order numbers (order_num) from the Orders table, sorting the result by customer name and then by order number.

2)lets make the previous exercise more useful. In addition to returning the customer name and order number, add a third column named OrderTotal containing the total price of each order. There are two ways to do this, you can create the OrderTotal column using a subquery on the OrderItems table, or you can join the OrderItems table to the existing tables and use an aggregate function. Heres a hint, watch out for where you need to use fully qualified column names.

orders table:

order_num int(11) PK
order_date datetime
cust_id char(10)

customers table:

Columns:

cust_id char(10) PK
cust_name char(50)
cust_address char(50)
cust_city char(50)
cust_state char(5)
cust_zip char(10)
cust_country char(50)
cust_contact char(50)
cust_email

char(255)

orders item table:

order_num int(11) PK
order_item int(11) PK
prod_id char(10)
quantity int(11)
item_price decimal(8,2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!