Я пытаюсь выполнить агрегацию, которая принимает наиболее распространенное значение группы, например:
with t1 as (
select
id
, colA
, colB
from some_Table
)
select
id
, count(*) as total
, max(colA) as maxColA
, most_common(colB) -- this is what I'm trying to achieve
from t1
group by id
Вот что я пытался сделать:
with t1 as (
select
id
, colA
, colB
from some_Table
)
select
id
, count(*) as total
, max(colA) as maxColA
, (select colB, count(colB) as counts from t1 group by colB order by counts desc limit 1) as most_freq_colB_per_id
from t1
group by id
Тем не менее, это говорит мне AnalysisException: Subqueries are not supported in the select list
.Как еще я могу это сделать?