0PricingLogin
SQL Interview Prep · Lesson

Projecting Columns and Aliasing Pitfalls

Why you cannot reference a SELECT alias in WHERE, and how interviewers test alias scope.

Projection: Choosing Your Columns

Picking which columns a query returns is called projection — that's what you do every time you write SELECT. Name them explicitly in real code; save SELECT * for quick exploring.

SELECT id, first_name, email
FROM employees;

Why Interviewers Dislike SELECT *

Why do interviewers dislike SELECT * in app code? It's fragile (column order can shift), wastes bandwidth, hurts index use, and hides what you actually need. Name your columns. 👍

All lessons in this course

  1. Projecting Columns and Aliasing Pitfalls
  2. Computed Columns and Expression Precedence
  3. DISTINCT vs GROUP BY for Uniqueness
  4. CASE Expressions in SELECT
← Back to SQL Interview Prep