O'Reilly logo

Tera-Tom on Teradata SQL V12-V13 by Tera-Tom Coffing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17 – Reporting Totals and Subtotals

Totals and Subtotals

Earlier, we discovered the ability to execute aggregates to find totals and subtotals using the GROUP BY. However, an individual row’s detail column data is available when using aggregates. The actual values are not seen, only the answer.

Teradata has the capability to generate the total and subtotals and at the same time display the detail data from the rows that goes into creating the totals. In this chapter, we explore the use of the WITH and WITH...BY functions to provide both totals and subtotals.

The following table is used for the SQL examples in this chapter:

Employee Table - contains 9 employees

Figure 17-1

Totals (WITH)

Compliance – Teradata Extension ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required