SOL-C01 · Question #20
A data analyst needs to create a view named that aggregates sales data by month. The base table sales_transactions' contains columns 'transaction_id' , 'transaction_date' , and 'sales_amount' . The an
The correct answer is B. Option B. The actual option text wasn't included in the question, but here's the explanation based on the concepts being tested: Why B is correct: The correct statement must combine three elements: creating a view that uses DATE_TRUNC (or equivalent like EXTRACT/TO_CHAR) to group by month,
Question
A data analyst needs to create a view named that aggregates sales data by month. The base table sales_transactions' contains columns 'transaction_id' , 'transaction_date' , and 'sales_amount' . The analyst wants to ensure that only users with the 'ANALYST' role can query this view. Which of the following SQL statements correctly creates the view and grants the necessary privileges?
Exhibit
Options
- AOption A
- BOption B
- COption C
- DOption D
- EOption E
How the community answered
(33 responses)- A18% (6)
- B67% (22)
- C6% (2)
- D6% (2)
- E3% (1)
Explanation
The actual option text wasn't included in the question, but here's the explanation based on the concepts being tested:
Why B is correct: The correct statement must combine three elements: creating a view that uses DATE_TRUNC (or equivalent like EXTRACT/TO_CHAR) to group by month, a SUM(sales_amount) aggregation with a GROUP BY on the truncated date, and a GRANT SELECT ON monthly_sales_view TO ANALYST statement to restrict access to the ANALYST role.
Why distractors are wrong: Common mistakes in the other options likely include: granting privileges to PUBLIC instead of the specific ANALYST role (too permissive), using GRANT ALL PRIVILEGES instead of just SELECT (over-grants), omitting the GROUP BY clause while using an aggregate function (invalid SQL), or aggregating by the raw transaction_date column instead of truncating to month (doesn't meet the "by month" requirement).
Memory tip: Think of it as two separate steps - CREATE VIEW (shape the data correctly with GROUP BY month) then GRANT SELECT (lock the door to the right role). The principle of least privilege means granting only SELECT, only to ANALYST, not ALL and not PUBLIC.
Note: Since the actual SQL for each option wasn't provided, if you can share the option text, I can give you a precise line-by-line breakdown of exactly where each wrong answer fails.
Topics
Community Discussion
No community discussion yet for this question.
