Ravindra BagaleCourses & study guides Track your progress

3. SELECT Basics: Read Rows Without Changing Data

3.3 How to Select Specific Columns and Change Column Order

Why. Reports need specific columns in a useful order.

What. List column names after SELECT, separated by commas. Order in the list = order in the result.

How. SELECT city, amount_inr, order_date FROM orders;

Steps

  1. Write SELECT with three columns you care about.
  2. Change their order and run again.
  3. Notice the grid headers move.

Examples

Example 1 · dataset: raja_coffee

SELECT city, amount_inr, order_date
FROM orders
LIMIT 5;

Output

cityamount_inrorder_date
Pune840.02026-09-02
Mumbai720.02026-09-03
Goa890.02026-09-05
Pune1050.02026-09-06
Kolhapur620.02026-09-07

Meaning. Only three columns, city first.

Ravindra Bagale's Tip

Name columns on purpose — future you will thank present you.