Effective SQL: 61 Specific Ways to Write Better SQL (Effective Software Development Series) by John L. Viescas & Douglas J. Steele & Ben G. Clothier

Effective SQL: 61 Specific Ways to Write Better SQL (Effective Software Development Series) by John L. Viescas & Douglas J. Steele & Ben G. Clothier

Author:John L. Viescas & Douglas J. Steele & Ben G. Clothier
Language: eng
Format: mobi, pdf
Publisher: Pearson Education
Published: 2017-01-08T23:00:00+00:00


Table 5.2 Aggregated inventory with ROLLUP data

We obtain a total quantity for each color and the overall quantity. However, we do not have any data on the total quantity by dimension, not considering color, because the ROLLUP works from right to left. To get that additional data, we can use CUBE instead. Listing 5.5 demonstrates the statement to obtain the results shown in Table 5.3.

Listing 5.5 CUBE sample query

Click here to view code image

SELECT Color, Dimension, SUM(Quantity)

FROM Inventory

GROUP BY CUBE (Color, Dimension);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.