DA0-002 practice question 15 of 25
[Data Acquisition and Preparation]A data analyst needs to create a combined report that includes information from the following two tables: Managers…
Full set: 111 questions[Data Acquisition and Preparation]
A data analyst needs to create a combined report that includes information from the following two tables: Managers table ID First_name Last_name Job_title 1001 John Doe Manager 1002 Jane Roe Director Non-managers table ID First_name Last_name Job_title 1003 Robert Roe Business Analyst 1004 Jane Doe Sales Representative 1005 John Roe Operations Analyst Which of the following query methods should the analyst use for this task?
The UNION operator in SQL is used to combine the result sets of two or more SELECT statements into a single result set. It appends the rows from one table to another. For this operation to work, the tables must have the same number of columns, and the corresponding columns must have compatible data types. In this scenario, both the Managers and Non-managers tables share an identical structure, making UNION the correct method to create a single, consolidated report of all employees by stacking the rows from both tables vertically.
A. Group: This is used with aggregate functions (e.g., COUNT, SUM) to summarize data into groups, not to combine tables.
B. Join: This combines tables horizontally based on a related column, merging columns from multiple tables into a single row.
D. Nested: This refers to a subquery (a query within another query) and describes a query's structure, not the specific operation for combining these tables.
1. Microsoft SQL Server Documentation. (2023). UNION (Transact-SQL). Microsoft Docs. In the "Arguments" section, it is stated that UNION "Specifies that multiple result sets are to be combined and returned as a single result set." The basic example shows combining two tables with identical column structures.
2. PostgreSQL 16 Documentation. (2023). 7.4. Combining Queries. In this section, the documentation states, "The UNION operator computes the set union of the rows returned by the involved SELECT statements... The two SELECT statements that represent the direct operands of the UNION must produce the same number of columns, and corresponding columns must be of compatible data types."
3. Ullman, J. D., & Widom, J. (n.d.). CS145 Introduction to Databases Course Notes: More SQL. Stanford University. In the section on "Union, Intersection, and Difference of Relations," the notes specify that UNION is the standard set-union operator for SQL, requiring the tables to be "union-compatible," which the tables in the question are.
Keep practicing
Take the free DA0-002 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DA0-002 practice questions
- Question 1[Data Analysis]A data analyst learns that a report detailing employee sales is reflecting…
- Question 2[Data Analysis]A data analyst is evaluating all conditions in a query. Which of the follo…
- Question 3[Data Analysis]A data analyst creates a report that identifies the middle 50% of the coll…
- Question 4[Data Governance]Which of the following explains the purpose of UAT?
- Question 5[Data Analysis]A product goes viral on social media, creating high demand. Distribution c…
- Question 6[Data Analysis]A data analyst team needs to segment customers based on customer spending …
