Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

673
Visualizações
Postgres - ERROR: aggregate functions are not allowed in GROUP BY Position: 305

Having a little trouble with a query provided by Periscope. Can you help point me in the right direction?

Error is - ERROR: aggregate functions are not allowed in GROUP BY Position: 305

with monthly_activity as (
  select distinct
    date_trunc('month', created_at) as month,
    user_id
  from oauth_refresh_tokens
), 
first_activity as (
  select user_id, date(min(created_at)) as month
  from oauth_refresh_tokens
  group by 2
)
select
  this_month.month,
  count(distinct user_id)
from monthly_activity this_month
left join monthly_activity last_month
  on this_month.user_id = last_month.user_id
  and this_month.month = last_month.month + interval '1 month'
join first_activity
  on this_month.user_id = first_activity.user_id
  and first_activity.month != this_month.month
where last_month.user_id is null
group by 1
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda