x
select groupid,count(value) as x
from test_distinct_count
group by rollup (groupid);
This query gives output like :
What i need is to display the value 5 for all the groupids in a column say Total. Something like this :
how can this be achieved using Hana Sql.
Advertisement
Answer
Am from sql server background hope sum() over() will exist in Hana, try the below solution
create table #temp(groupid int,value int)
insert into #temp values(1,1)
insert into #temp values(1,1)
insert into #temp values(1,1)
insert into #temp values(2,2)
insert into #temp values(2,2)
select
a.*,sum(x) over()/2 as Total
from (
select groupid,count(value) as x
from #temp
group by rollup (groupid)
)a