Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Combining Table Results | Nested Subqueries
course content

Зміст курсу

Intermediate SQL

Combining Table ResultsCombining Table Results

In this chapter, we'll practice with the UNION clause. We'll be working with these two tables:

employees:

employee_id first_name last_name department salary hire_date
1 John Doe Engineering 80000.00 2015-03-01T00:00:00Z
2 Jane Smith Engineering 90000.00 2017-08-15T00:00:00Z
3 Alice Johnson Marketing 75000.00 2016-11-10T00:00:00Z
4 Bob Brown Marketing 72000.00 2018-06-25T00:00:00Z
... ... ... ... ... ...
100 William Solis Sales 55000.00 2020-05-01T00:00:00Z

contractors:

contractor_id first_name last_name email
1 Alice Johnson alice.johnson@contractor.com
2 Bob Brown bob.brown@contractor.com
3 Charlie Davis charlie.davis@contractor.com
4 David Evans david.evans@contractor.com
... ... ... ...
50 Yvonne Zimmer yvonne.zimmer@contractor.com

Завдання

For practice, your task will be to combine the employees and contractors tables using the UNION clause.

After that, from the resulting table, you should retrieve only those IDs that are multiples of 2. Also, you need to retrieve the first_name and last_name columns. Use the syntax WHERE id % 2 = 0. For this task, you need to use subqueries in the FROM section just as shown in the example.

Good luck!

Note

As a result, you should have 3 columns: id (an alias for the ID from both tables), first_name, last_name.

Все було зрозуміло?

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

Зміст курсу

Intermediate SQL

Combining Table ResultsCombining Table Results

In this chapter, we'll practice with the UNION clause. We'll be working with these two tables:

employees:

employee_id first_name last_name department salary hire_date
1 John Doe Engineering 80000.00 2015-03-01T00:00:00Z
2 Jane Smith Engineering 90000.00 2017-08-15T00:00:00Z
3 Alice Johnson Marketing 75000.00 2016-11-10T00:00:00Z
4 Bob Brown Marketing 72000.00 2018-06-25T00:00:00Z
... ... ... ... ... ...
100 William Solis Sales 55000.00 2020-05-01T00:00:00Z

contractors:

contractor_id first_name last_name email
1 Alice Johnson alice.johnson@contractor.com
2 Bob Brown bob.brown@contractor.com
3 Charlie Davis charlie.davis@contractor.com
4 David Evans david.evans@contractor.com
... ... ... ...
50 Yvonne Zimmer yvonne.zimmer@contractor.com

Завдання

For practice, your task will be to combine the employees and contractors tables using the UNION clause.

After that, from the resulting table, you should retrieve only those IDs that are multiples of 2. Also, you need to retrieve the first_name and last_name columns. Use the syntax WHERE id % 2 = 0. For this task, you need to use subqueries in the FROM section just as shown in the example.

Good luck!

Note

As a result, you should have 3 columns: id (an alias for the ID from both tables), first_name, last_name.

Все було зрозуміло?

Секція 2. Розділ 6
toggle bottom row
some-alt