You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@kylin.apache.org by "liubo@fcyun.com" <li...@fcyun.com> on 2017/10/31 03:48:43 UTC

how to write count(if logic) or sum(if logic) sqls?

Hi all,
Here's my requirement: I need count the number of  deals  which  it's deal_money greater than 5.00.          Any ideals, thanks very much~





liubo@fcyun.com

Re: how to write count(if logic) or sum(if logic) sqls?

Posted by ShaoFeng Shi <sh...@apache.org>.
Hi Liubo,

As a workaround, you can create a new Hive view, on which coverting this
"case when" to a new column, and then define a cube over this view.

For example:

create view v_abc as select c1, c2, ... (case when final_money >=5 then 1
else 0 end ) as cn from t_abc;

In the cube, define a measure "SUM(CN)". When Cube is build, run query
"select sum(cn) from v_abc".

For more practices, you can refer to some articles like
http://blog.csdn.net/yu616568/article/details/50548967

2017-10-31 11:48 GMT+08:00 liubo@fcyun.com <li...@fcyun.com>:

> Hi all,
> Here's my requirement: I need count the number of  deals  which  it's
> deal_money greater than 5.00.          Any ideals, thanks very much~
>
>
>
> ------------------------------
> liubo@fcyun.com
>



-- 
Best regards,

Shaofeng Shi 史少锋