create table t1 ( c1 int , c2 int , c3 int ) ; 
insert into t1 values ( 1 , 3 , 1 ) ;
insert into t1 values ( 2 , 1 , 1 ) ;
insert into t1 values ( 3 , 0 , 1 ) ;
insert into t1 values ( 4 , 0 , 1 ) ;
insert into t1 values ( 5 , 0 , 1 ) ;
insert into t1 values ( 6 , 0 , 1 ) ;

select "ok   " , count(*) cnt , count(*) / (( select count(*) from t1 b where b.c3 = a.c3 ) / 100 ) "%" from t1 a where c1 < 5 group by c3 ;

create view v1 as select "error" , count(*) cnt , count(*) / (( select count(*) from t1 b where b.c3 = a.c3 ) / 100 ) "%" from t1 a where c1 < 5 group by c3 ;

select * from v1 ;


system echo "### ### ###   additional hints, alterations of select"

create view v2 as
select "error case"                      , count(*) cnt , count(*) / (( select count(*)   from t1 b where b.c3 = a.c3 ) / 100 ) "%" from t1 a where c1 < 5 group by c3 
union
select "error case 2.count --> constant" , count(*) cnt , count(*) / (( select distinct 6 from t1 b where b.c3 = a.c3 ) / 100 ) "%" from t1 a where c1 < 5 group by c3
union
select "1.count --> constant"            , count(*) cnt , 4        / (( select count(*)   from t1 b where b.c3 = a.c3 ) / 100 ) "%" from t1 a where c1 < 5 group by c3 
union
select "evaluation order"                , count(*) cnt , count(*) /  ( select count(*)   from t1 b where b.c3 = a.c3 ) * 100   "%" from t1 a where c1 < 5 group by c3
union
select "reference"                       , count(*) cnt , count(*) / (( select count(*)   from t1 b where b.c3 = 1    ) / 100 ) "%" from t1 a where c1 < 5 group by c3
;

select * from v2 ;

