Summing
Summing and counting are key ways of aggregating data, regardless of whether you are using a database, manipulating a spreadsheet, or using a programming language such as Python or R. Let's see how to do it in T-SQL using the grid table from Chapter 1.
You'll start by obtaining overall sums, focusing specifically on the 'MRO' region.

Latihan ini adalah bagian dari kursus
Introduction to SQL Server
Petunjuk latihan
- Obtain a grand total of the
demand_loss_mwcolumn by using theSUMfunction, and alias the result asMRO_demand_loss. - Only retrieve rows
WHEREdemand_loss_mwis notNULLandnerc_regionis'MRO'.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
-- Sum the demand_loss_mw column
SELECT
___(demand_loss_mw) AS ___
FROM
grid
WHERE
-- demand_loss_mw should not contain NULL values
___ ___ ___ ___
-- and nerc_region should be 'MRO';
___ ___ = '___';