Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aliases | Selecting
SQL Basics
course content

Зміст курсу

SQL Basics

SQL Basics

1. Selecting
2. Filtering
3. Aggregating
4. Sorting
5. Grouping
6. Practicing

bookAliases

The outputs of the last two tasks were single columns with single values. If you noticed, this column had a name count, which is not, to be honest representative. Seems like it's only a matter of taste. But in the future, when you will work with multiple tables, will join one table to another, the same names will be a huge problem. Even from the point of interpreting the data.

In SQL you can easily declare a new name to a column by using AS statement. For example,

12
SELECT COUNT(DISTINCT(country)) AS "number of countries" FROM visitors
copy

This query will return a single value in the single column named number of countries, which is much readable than count.

Please note, that the aliases you use must be placed within double-quotes. Using single quotes will result in SQL error!

Завдання
test

Swipe to show code editor

Extract unique types of fuel consumed by cars (column fueltype) and name this column as "Fuel type".

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 8
toggle bottom row

bookAliases

The outputs of the last two tasks were single columns with single values. If you noticed, this column had a name count, which is not, to be honest representative. Seems like it's only a matter of taste. But in the future, when you will work with multiple tables, will join one table to another, the same names will be a huge problem. Even from the point of interpreting the data.

In SQL you can easily declare a new name to a column by using AS statement. For example,

12
SELECT COUNT(DISTINCT(country)) AS "number of countries" FROM visitors
copy

This query will return a single value in the single column named number of countries, which is much readable than count.

Please note, that the aliases you use must be placed within double-quotes. Using single quotes will result in SQL error!

Завдання
test

Swipe to show code editor

Extract unique types of fuel consumed by cars (column fueltype) and name this column as "Fuel type".

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 8
toggle bottom row

bookAliases

The outputs of the last two tasks were single columns with single values. If you noticed, this column had a name count, which is not, to be honest representative. Seems like it's only a matter of taste. But in the future, when you will work with multiple tables, will join one table to another, the same names will be a huge problem. Even from the point of interpreting the data.

In SQL you can easily declare a new name to a column by using AS statement. For example,

12
SELECT COUNT(DISTINCT(country)) AS "number of countries" FROM visitors
copy

This query will return a single value in the single column named number of countries, which is much readable than count.

Please note, that the aliases you use must be placed within double-quotes. Using single quotes will result in SQL error!

Завдання
test

Swipe to show code editor

Extract unique types of fuel consumed by cars (column fueltype) and name this column as "Fuel type".

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

The outputs of the last two tasks were single columns with single values. If you noticed, this column had a name count, which is not, to be honest representative. Seems like it's only a matter of taste. But in the future, when you will work with multiple tables, will join one table to another, the same names will be a huge problem. Even from the point of interpreting the data.

In SQL you can easily declare a new name to a column by using AS statement. For example,

12
SELECT COUNT(DISTINCT(country)) AS "number of countries" FROM visitors
copy

This query will return a single value in the single column named number of countries, which is much readable than count.

Please note, that the aliases you use must be placed within double-quotes. Using single quotes will result in SQL error!

Завдання
test

Swipe to show code editor

Extract unique types of fuel consumed by cars (column fueltype) and name this column as "Fuel type".

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 1. Розділ 8
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt