AI-102 · Question #127
You have a SQL query that combines customer data and order data. The query includes calculated columns. You need to create a database object that would allow other users to rerun the same SOL query. W
The correct answer is B. a view. To allow other users to repeatedly execute a specific SQL query that combines data and includes calculated columns, you should create a view.
Question
Options
- Aan Index
- Ba view
- Ca scalar function
- Da table
How the community answered
(36 responses)- A11% (4)
- B81% (29)
- C6% (2)
- D3% (1)
Why each option
To allow other users to repeatedly execute a specific SQL query that combines data and includes calculated columns, you should create a view.
An index is a performance optimization object used to speed up data retrieval, but it does not store or encapsulate a SQL query that returns data.
A view is a virtual table that encapsulates a SQL query, including joins and calculated columns; users can then query the view directly, which re-executes the underlying SQL query to present the result set.
A scalar function returns a single value and is used for specific calculations, not for encapsulating and rerunning a complete query that returns a result set.
A table is used to store raw data; it does not define or encapsulate a pre-defined query with combined data and calculated columns.
Concept tested: SQL database views
Source: https://learn.microsoft.com/en-us/sql/relational-databases/views/views?view=sql-server-ver16
Topics
Community Discussion
No community discussion yet for this question.