Very Easy

Rename columns II

Consider the following table ecommerce_orders, which contains a list of all orders processed by an ecommerce website.

+----------+-----------+------------+--------------+-------------+-------------------+
| order_id | status    | created_at | delivered_at | returned_at | ecommerce_user_id |
+----------+-----------+------------+--------------+-------------+-------------------+
| 1        | Cancelled | Sept. 2... | None         | None        | 1                 |
| 2        | Complete  | Sept. 2... | Sept. 23,... | None        | 1                 |
| 3        | Complete  | Aug. 8t... | Aug. 12th... | None        | 2                 |
| ...      | ...       | ...        | ...          | ...         | ...               |
+----------+-----------+------------+--------------+-------------+-------------------+

Write a query that returns the order_id and status columns from this table. In your query’s result, the status column should be renamed to order_status.

EXPECTED OUTPUT
+----------+-----------------+
| order_id | order_status    |
+----------+-----------------+
| 1        | Cancelled       |
| 2        | Complete        |
| 3        | Complete        |
| ...      | ...             |
+----------+-----------------+

Use

SELECT col1 AS new_col_name 
FROM table1

to give col1 the name new_col_name in your query's result.

SELECT order_id, status AS order_status FROM ecommerce_orders

  • This field is required.