Very Easy

Specify column order I

Consider the following table ecommerce_users which contains a list of all the registered users of an ecommerce website.

+-------------------+------------+-----------+-----------------------------------+-----+--------+----------------+
| ecommerce_user_id | first_name | last_name | email                             | age | gender | country        |
+-------------------+------------+-----------+-----------------------------------+-----+--------+----------------+
| 1                 | Max        | Jenkins   | [email protected]          | 34  | M      | United Kingdom |
| 2                 | Lucy       | Hennaway  | [email protected] | 28  | F      | United Kingdom |
| 3                 | Rob        | Jones     | [email protected]           | 30  | M      | United Kingdom |
| ...               | ...        | ...       | ...                               | ... | ...    | ...            |
+-------------------+------------+-----------+-----------------------------------+-----+--------+----------------+

Write a query that returns the email and first_name columns from this table, in that specific order.

EXPECTED OUTPUT
+-----------------------------------+------------+
| email                             | first_name |
+-----------------------------------+------------+
| [email protected]          | Max        |
| [email protected] | Lucy       |
| [email protected]           | Rob        |
| ...                               | ...        |
+-----------------------------------+------------+

Remember, the order of the columns in your SELECT clause determines the order in which they appear in the results. For example, writing:

SELECT col1, col2 FROM table1

will produce a table in which col1 appears first, followed by col2.

If you swap the order of the columns, however:

SELECT col2, col1 FROM table1

you'll get a table in which col2 appears first, followed by col1.

SELECT email, first_name FROM ecommerce_users

  • This field is required.