15.9k views
3 votes
Write a single SQL statement to produce each of the following.

a. For each customer order, list the order id, order date, order_source_id source description, and the first and last name of the customer.
b. For each customer order, list the order id, order date, meth_pmt, the first and last name of the customer placing the order.
c. For each line in shipment_line, display the shipment_id, inv_id, ship_quantity, date_expected and date_received.

1 Answer

1 vote

Answer:

a. SELECT order_id, order_date, order_source_id, source_description, first_name || last_name AS customer_name

FROM customer_order;

b. SELECT order_id, order_date, meth_pmt, first_name || last name AS customer_name

FROM customer_order;

c. SELECT shipment_id, inv_id, ship_quantity, date_expected, date_received

FROM shipment_line;

Step-by-step explanation:

When using SQL statements to display a certain amount of information, the SELECT syntax is used. It is written as;

SELECT X, Y, Z

FROM alphabets;

The SELECT statement is used to list the variables to be displayed which are usually separated by a coma.

The FROM indicates the table from which the variables should be extracted from.

The ; sign signifies the end of an SQL statement and that you want your query to be run

This "first_name || last_name AS customer_name" tells SQL to combine the first and last name of customers and display them as customer_name.

User Tom Lord
by
5.9k points