You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by dyuti a <ha...@gmail.com> on 2012/10/23 14:11:51 UTC

To calculate % in hive query

 Hi,

with the below query i can able to get the approved transaction for per
client on per day basis.

//Query :

select q1.client_id,q1.receive_day,count(q1.client_id) as cnt
from(
        select * from sale where response=00
       )q1
group by q1client_id,q1.receive_day;


I want to get the approval %, i.e., The approval_per is
100*(count(client_id)/response). count(client_id) is number of clients for
the approved transaction.

response is count of whole response including all the values (approved and
not approved) . I can get the response by " select count(response) from
sale " , but how to make it here for calculating % in the same query is the
problem am facing now. I tried out some options as it didn't work , reached
user group.

so my expected output format is
client_id,receive_day,count(client_id),approval_per.


Any of your help are really appreciated, also it will help me to move
further.


Thanks & Regards,
dti