1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Rounding an aggregated column in DuckDB

Discussão em 'Outras Linguagens' iniciado por Stack, Novembro 8, 2024 às 07:12.

  1. Stack

    Stack Membro Participativo

    I'm looking at integrating DuckDB into one of my data pipelines, but as I'm new to SQL as a whole I'm working my way through the "DuckDB in Action" book by Needham, Hunger and Simons.

    Up to this point everything has worked fine, but I've reached an example where the book gives the query

    PIVOT v_power_per_day
    ON year(day)
    USING round(sum(kWh)) AS total, max(kWh) AS best_day;


    and shows what the output should look like (a pivot table with five columns, with the "total" columns rounded to 1dp). However, when I attempt to run the same query in the database, I get the following:

    Catalog Error: round is not an aggregate function

    Is this a mistake in the book or is there something wrong with my DuckDB installation? And if it is indeed a typo, how would you go about rounding a column produced by an aggregate function?

    Continue reading...

Compartilhe esta Página