--
-- ### Evaluation of distinct operator with subselect ( fix for unknown order attribute with 2.53.4 ) 
--

drop if exists table t1;
create table t1 ( a int, b string(10));

drop if exists table t2;
create table t2 ( a int, b string(10));

insert into t1 values ( 1, 'XXX');
insert into t1 values ( 2, 'ff');
insert into t1 values ( 3, 'XXX');
insert into t1 values ( 3, 'XXX');
insert into t1 values ( 3, 'XXX');


insert into t2 values ( 1, 'XXX');
insert into t2 values ( 1, 'ff');
insert into t2 values ( 2, 'XXX');

select
distinct
a as a,
  ( select count(*) from t2 where t2.a = t1.a ) as ainb,
  a | b as x
from t1;
