beginner

SELECT Statements & Aliases

8 min readLast updated: 2026-07-05

Overview

Learn how to retrieve specific columns, calculate expressions, rename fields using aliases, and limit row size outputs.

Learning Objectives

  • Query columns from database tables.
  • Apply arithmetic expressions in queries.
  • Rename output columns using AS aliases.

Detailed Concept Explanation

The SELECT clause lists the columns or calculations you want to retrieve. The AS keyword creates aliases to rename columns for the output display, making long calculation names clean and readable.


Code Examples

SQL

sql
-- Select specific columns and calculate tax alias
SELECT 
    name, 
    salary, 
    salary * 0.15 AS state_tax 
FROM employees
LIMIT 10;
Execution Plan Diagram
SELECT columns list
Compute salary * 0.15
AS state_tax alias
LIMIT 10 rows

Best Practices

  • **Avoid SELECT ***: Always list columns explicitly instead of SELECT * to reduce database heap scan memory and network transfer costs.
  • Descriptive Aliases: Use meaningful aliases for computed fields to improve downstream report mappings.

Interview Perspective

Note

*Interview Question: Why is 'SELECT ' bad for query performance in production?

Using SELECT * forces the database engine to perform a full-row scan and read all columns from disk. It prevents index-only scans, increases memory utilization, and consumes unnecessary network bandwidth.


Interactive Challenges

Challenge 1: Rename columns (Beginner)

Write an SQL query to retrieve the column 'first_name' from 'users' table and alias it as 'customer_name'.


Summary

The SELECT clause retrieves columns and expressions, which can be aliased with AS and row-limited using LIMIT.