Skip to content

1.3 — Selecting Specific Columns

What You'll Learn

  • How to display only the columns you want from a table
  • The syntax for selecting specific columns in SQL
  • How this compares to showing/hiding columns in Excel

From Excel to SQL: Focusing on What Matters

In Excel, you might hide columns you don’t need, or copy only certain columns to a new sheet for your analysis.

In SQL, you can do the same by listing the columns you want to see in your SELECT statement.

Example Table

SaleDateProductAmount
2024-05-01Apples120
2024-05-01Oranges80
2024-05-01Banananull

Suppose you only want to see the Product and Amount columns.

SQL Example

sql
SELECT Product, Amount FROM sales;
  • This tells the database to show only the Product and Amount columns from the sales table.
  • The order of columns in your query determines the order in your results.

Using Column Aliases

Sometimes you want to rename a column in your results to make it clearer or more readable—just like renaming a column header in Excel.

You can do this in SQL using the AS keyword:

sql
SELECT Product AS Item, Amount AS Total FROM sales;
  • AS gives a column a new name in the output.
  • The original column name in the table stays the same.

This is helpful for reports or when you want to use more business-friendly names.

Key Points

  • List the columns you want after SELECT, separated by commas.
  • Use AS to rename columns in your results (column alias).
  • This is just like choosing which columns to show and how to label them in Excel.
  • You can select as many or as few columns as you need.

Next Steps

In the next module, you’ll learn how to filter your data—just like using filters in Excel to see only the rows you care about.