O'Reilly logo

Netezza SQL by Mike Larkins, 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 8 – OLAP Functions

"Always remember that you are unique just like everyone else."

Anonymous

A Better Choice – The ANSI Version of CSUM

image

This ANSI version of CSUM is SUM() Over. Right now, the syntax wants to see the sum of the Daily_Sales after it is first sorted by Sale_Date. Rows Unbounded Preceding makes this a CSUM. The ANSI Syntax seems difficult, but only at first.

The ANSI Version of CSUM – The Sort Explained

SELECTProduct_ID , Sale_Date, Daily_Sales,

SUM(Daily_Sales) OVER (ORDER BY  Sale_Date

ROWS UNBOUNDED PRECEDING)    AS SUMOVER

FROMSales_Table WHERE Product_ID BETWEEN 1000 and 2000 ;

The first thing the above query does before ...

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