Combinando Resultados de Tabelas
Swipe to start coding
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.
Note
As a result, you should have 3 columns:
id(an alias for the ID from both tables),first_name,last_name.
Brief Instructions
- Retrieve the
id,first_name, andlast_namecolumns. - In the
FROMclause, write two inner queries joined by theUNIONclause. - In the first inner query, select
employee_id,first_name, andlast_namefrom theemployeestable.- Assign the alias
idtoemployee_id.
- Assign the alias
- In the second inner query, select
contractor_id,first_name, andlast_namefrom thecontractorstable.- Assign the alias
idtocontractor_id.
- Assign the alias
- Assign the alias
combinedto both inner queries. - Finally, use a
WHEREclause with the conditionid % 2 = 0.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Incrível!
Completion taxa melhorada para 4
Combinando Resultados de Tabelas
Deslize para mostrar o menu
Swipe to start coding
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.
Note
As a result, you should have 3 columns:
id(an alias for the ID from both tables),first_name,last_name.
Brief Instructions
- Retrieve the
id,first_name, andlast_namecolumns. - In the
FROMclause, write two inner queries joined by theUNIONclause. - In the first inner query, select
employee_id,first_name, andlast_namefrom theemployeestable.- Assign the alias
idtoemployee_id.
- Assign the alias
- In the second inner query, select
contractor_id,first_name, andlast_namefrom thecontractorstable.- Assign the alias
idtocontractor_id.
- Assign the alias
- Assign the alias
combinedto both inner queries. - Finally, use a
WHEREclause with the conditionid % 2 = 0.
Solução
Obrigado pelo seu feedback!
single