PrepAway - Latest Free Exam Questions & Answers

Which Transact-SQL statement should you run?

Note: This question is part of a series of questions that use the same or similar answer choices. An
answer choice may be correct for more than one question in the series. Each question is independent
of the other questions in this series. Information and details provided in a question apply only to that
question.
You create a table by running the following Transact-SQL statement:

You are developing a report that displays customer information. The report must contain a grand total column.
You need to write a query that returns the data for the report.
Which Transact-SQL statement should you run?

PrepAway - Latest Free Exam Questions & Answers

A.

B.

C.

D.

E.

F.

G.

H.

Explanation:
Calculate aggregate column through AVG function and GROUP BY clause.

8 Comments on “Which Transact-SQL statement should you run?

  1. eder says:

    LA RESPUESTA QUE MAS SE APROXIMA ES THE —>LETTER A
    SELECT CustomerID,AnnualRevenue,address,FirstName,LastName
    FROM Q28.customers
    GROUP BY GROUPING SETS(
    (FirstName,LastName),(address),(CustomerID,AnnualRevenue),(CUSTOMERID)
    )

    PERO LA RESPUESTA CORRECTA SERIA:
    SELECT customerID,SUM(ANNUALREVENUE)
    FROM Q28.Customers
    GROUP BY GROUPING SETS(customerID,())




    1



    0
  2. mohamadalibrahim1 says:

    the correct Answer is A, because to get grand you must use Grouping SET.

    GROUP BY ()
    Specifies the empty group which generates **the grand** total. This is useful as one of the elements of a GROUPING SET. For example, this statement gives the total sales for each country and then gives the grand-total for all countries.

    SELECT Country, SUM(Sales) AS TotalSales
    FROM Sales
    GROUP BY GROUPING SETS ( Country, () );




    3



    0

Leave a Reply