nerdexam
CompTIA

DA0-002 · Question #49

A table contains several rows of cellular numbers with call timestamps, call durations, called numbers, and carriers of the called number. Which of the following allows a data analyst to sort the…

The correct answer is C. SELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BY. To sort cellular numbers by carrier and include total call durations, the SQL query must SELECT the cellular number, carrier, and SUM of call duration, then GROUP BY both the cellular number and carrier, and finally ORDER BY the carrier.

Data Analysis

Question

A table contains several rows of cellular numbers with call timestamps, call durations, called numbers, and carriers of the called number. Which of the following allows a data analyst to sort the cellular numbers based on the carriers of the called numbers and include the total call durations?

Options

  • ASELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BY
  • BSELECT cellular_number, SUM(call_duration) FROM calls GROUP BY call_duration ORDERBY
  • CSELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BY
  • DSELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BY

How the community answered

(20 responses)
  • A
    5% (1)
  • B
    10% (2)
  • C
    80% (16)
  • D
    5% (1)

Why each option

To sort cellular numbers by carrier and include total call durations, the SQL query must `SELECT` the cellular number, carrier, and `SUM` of call duration, then `GROUP BY` both the cellular number and carrier, and finally `ORDER BY` the carrier.

ASELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BY

This choice is incomplete as it lacks the `GROUP BY` columns and `ORDER BY` clause in the provided snippet, making it syntactically incorrect for the desired aggregation and sorting.

BSELECT cellular_number, SUM(call_duration) FROM calls GROUP BY call_duration ORDERBY

This query attempts to `GROUP BY call_duration`, which is incorrect for summarizing by cellular number and carrier, and the `ORDER BY` clause is also incomplete.

CSELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BYCorrect

To aggregate `SUM(call_duration)` for each `cellular_number` and `called_number_carrier`, both non-aggregated columns must be included in the `GROUP BY` clause. The `ORDER BY called_number_carrier` clause then sorts the results as requested.

DSELECT cellular_number, called_number_carrier, SUM(call_duration) FROM calls GROUP BY

This choice is incomplete as it lacks the `GROUP BY` columns and `ORDER BY` clause in the provided snippet, making it syntactically incorrect for the desired aggregation and sorting.

Concept tested: SQL GROUP BY and ORDER BY clauses

Source: https://learn.microsoft.com/en-us/sql/t-sql/queries/select-group-by-transact-sql

Topics

#SQL#Aggregate Functions#GROUP BY Clause#Data Querying

Community Discussion

No community discussion yet for this question.

Full DA0-002 Practice