Aliasing

Introduction to SQL with AI

Jasmin Ludolf

Senior Data Science Content Developer

Confusing field names

$$

  • Difficult to understand
  • Inconsistent formatting

$$

  • prod_nm instead of product_name
  • Customer ID or cust Id

$$

SELECT prod_nm
FROM products;
|prod_nm|
|-------|
|Laptop |
|Desktop|
...
Introduction to SQL with AI

Alias

$$

  • A custom label for a field in our results
  • Does not change the database

$$

SELECT field_name AS alias
FROM table_name;
Introduction to SQL with AI

Alias

Prompt: Show me the customer names as first_name

SELECT name AS first_name
FROM customers;
|first_name|
|----------|
|Madison   |
|Giovanni  |
|Olivia    |
|Brady     |
...
Introduction to SQL with AI

Field naming

$$

  • Lowercase
  • Underscores
  • Singular
  • Different to tables and other fields

Field naming

Introduction to SQL with AI

Table naming

$$

  • Lowercase
  • Underscore
  • Plural

Table naming

Introduction to SQL with AI

Aliasing with AI

Prompt: Show me the customer names as first_name

SELECT name AS first_name
FROM customers;
|first_name|
|----------|
|Madison   |
|Giovanni  |
|Olivia    |
|Brady     |
...
Introduction to SQL with AI

Let's practice!

Introduction to SQL with AI

Preparing Video For Download...