hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Meri-Tuulia Rautavuori <merituulia.rautavu...@songhi.com>
Subject Re: Cumulative sum with Hive
Date Wed, 15 Oct 2014 06:28:55 GMT
Hei,

Thank you very much! Cool!

I make it work like this:

SELECT r.day, r.a, SUM(r.a) OVER part_month AS cumulative_a
FROM
(
SELECT day, month, COUNT (DISTINCT (a))
FROM table
WHERE month='xxxxxx'
GROUP BY day, month
)r
WINDOW part_month as (PARTITION BY r.month order by r.day)

Greetings from Finland!
M-T

On Tue, Oct 14, 2014 at 4:48 PM, João Alves <joao@5dlab.com> wrote:

> Hey,
>
> You could try something like
>
> SELECT sum(a) OVER (PARTITION BY dummy ROWS UNBOUNDED PRECEDING) FROM
> (SELECT a, “dummy” AS dummy FROM table) AS aux;
>
> The smaller solution of :
>
> SELECT sum(A) OVER (PARTITION BY “dummy” ROWS UNBOUNDED PRECEDING) FROM
> table;
>
> For me gets stuck without presenting any results.
>
> You can explore more possibilities with analytical and windowing functions
> here:
> https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics
>
>
> Best,
> João Alves
>
> On 14 Oct 2014, at 14:47, Meri-Tuulia Rautavuori <
> merituulia.rautavuori@songhi.com> wrote:
>
> Hi,
>
> Could you please help me how to calculate cumulative sum with Hive? Like
> RSUM in Oracle?
>
> Thanks.
>
> --
> Best Regards,
>
> *Meri-Tuulia Rautavuori*
> *Business Analyst*
>
> SongHi Entertainment Ltd
> *Särkiniementie 5 C 7*
> *00210 Helsinki*
> +358 45 271 2171
>
> *merituulia.rautavuori@songhi.com <merituulia.rautavuori@songhi.com>*
>
> http://www.songhi.com - Tune in and Play
>
> This transmission is confidential and intended solely for the person or
> organisation to whom it is addressed. It may contain privileged and
> confidential information. If you are not the intended recipient, you should
> not copy, distribute, reproduce, publish or disclose the information, take
> any action in reliance on it or use it for your own benefit. If you have
> received this transmission in error, please notify us immediately by E-mail *merituulia.rautavuori@soghi.com
> <merituulia.rautavuori@soghi.com>*
>
> SongHi Entertainment Ltd has all publishing and copyrights 2013.
>
>
>


-- 
Best Regards,

*Meri-Tuulia Rautavuori*
*Business Analyst*

SongHi Entertainment Ltd
*Särkiniementie 5 C 7*
*00210 Helsinki*
+358 45 271 2171

*merituulia.rautavuori@songhi.com <merituulia.rautavuori@songhi.com>*

http://www.songhi.com - Tune in and Play

This transmission is confidential and intended solely for the person or
organisation to whom it is addressed. It may contain privileged and
confidential information. If you are not the intended recipient, you should
not copy, distribute, reproduce, publish or disclose the information, take
any action in reliance on it or use it for your own benefit. If you have
received this transmission in error, please notify us immediately by
E-mail *merituulia.rautavuori@soghi.com
<merituulia.rautavuori@soghi.com>*

SongHi Entertainment Ltd has all publishing and copyrights 2013.

Mime
View raw message