Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
SQL Union | SQL Joining Tables
Data Manipulation using SQL
course content

Зміст курсу

Data Manipulation using SQL

Data Manipulation using SQL

1. Database and Nested Queries
2. SQL Joining Tables
3. SQL Tasks

bookSQL Union

UNION is an operator that concatenates results of different SQL queries:

1234567
--do not run this query SELECT columns FROM table1 UNION SELECT columns FROM table2 UNION ... SELECT columns FROM tableN
copy

There is also an operator UNION ALL, and the difference is that UNION returns distinct values, unlike UNION ALL.

Requirements for using UNION operators:

  • number of columns in SELECT should be the same
  • data types and order of columns should be the same

Завдання

You want to get some info about songs from three decades: 1970s, 1980s, and 1990s. Find the prices of the cheapest and the most expensive songs for each decade in separate queries. You're free to use JOIN, BETWEEN, or any other operators, but you should do three separate queries and concatenate them with UNION.

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

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

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

Секція 2. Розділ 5
toggle bottom row

bookSQL Union

UNION is an operator that concatenates results of different SQL queries:

1234567
--do not run this query SELECT columns FROM table1 UNION SELECT columns FROM table2 UNION ... SELECT columns FROM tableN
copy

There is also an operator UNION ALL, and the difference is that UNION returns distinct values, unlike UNION ALL.

Requirements for using UNION operators:

  • number of columns in SELECT should be the same
  • data types and order of columns should be the same

Завдання

You want to get some info about songs from three decades: 1970s, 1980s, and 1990s. Find the prices of the cheapest and the most expensive songs for each decade in separate queries. You're free to use JOIN, BETWEEN, or any other operators, but you should do three separate queries and concatenate them with UNION.

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

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

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

Секція 2. Розділ 5
toggle bottom row

bookSQL Union

UNION is an operator that concatenates results of different SQL queries:

1234567
--do not run this query SELECT columns FROM table1 UNION SELECT columns FROM table2 UNION ... SELECT columns FROM tableN
copy

There is also an operator UNION ALL, and the difference is that UNION returns distinct values, unlike UNION ALL.

Requirements for using UNION operators:

  • number of columns in SELECT should be the same
  • data types and order of columns should be the same

Завдання

You want to get some info about songs from three decades: 1970s, 1980s, and 1990s. Find the prices of the cheapest and the most expensive songs for each decade in separate queries. You're free to use JOIN, BETWEEN, or any other operators, but you should do three separate queries and concatenate them with UNION.

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

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

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

UNION is an operator that concatenates results of different SQL queries:

1234567
--do not run this query SELECT columns FROM table1 UNION SELECT columns FROM table2 UNION ... SELECT columns FROM tableN
copy

There is also an operator UNION ALL, and the difference is that UNION returns distinct values, unlike UNION ALL.

Requirements for using UNION operators:

  • number of columns in SELECT should be the same
  • data types and order of columns should be the same

Завдання

You want to get some info about songs from three decades: 1970s, 1980s, and 1990s. Find the prices of the cheapest and the most expensive songs for each decade in separate queries. You're free to use JOIN, BETWEEN, or any other operators, but you should do three separate queries and concatenate them with UNION.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 5
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt