Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create a view named customer_addresses that shows the shipping and billing ad

ID: 3695166 • Letter: 1

Question

1. Create a view named customer_addresses that shows the shipping and billing addresses for each customer. This view should return these columns from the Customers table: customer_id, email_address, last_name and first_name. This view should return these columns from the Addresses table: bill_line1, bill_line2, bill_city, bill_state, bill_zip, ship_line1, ship_line2, ship_city, ship_state, and ship_zip. The rows in this view should be sorted by the last_name and then first_name columns. Note: Have to match the billing address and shipping address code to the line address in the address table. Customers schema: customer_id. email_Address billing_address_id, shipping_address_id, fist_name, last_name Addresses table: address_id, customer_id, line1, line2, city, state, zip code

Explanation / Answer

CREATE VIEW CUSTOMER_ADDRESSES AS SELECT cust.customer_id, cust.last_name, cust.first_name, cust.email_address bill.line1 as bill_line1, bill.line2 as bill_line2, bill.city as bill_city, bill.state as bill_state, bill.zip as bill_zip, ship.line1 as ship_line1, ship.line2 as ship_line2, ship.city as ship_city, ship.state as ship_state, ship.zip as ship_zip FROM customers cust, addresses bill, addresses ship WHERE cust.shipping_address_id = ship.address_id and cust.billing_address_id = bill.address_id