Olá, tudo bem?
A query a baixo me retorna alguns dados, para que seja feita uma limpeza
futuramente.
Vejam que eu tenho o campo account_id e também size.
Eu quero saber o total para cada account_id.
Por exemplo:
> account_id size file_name st_ino
> ---------- ---------- ------------------- --------
> 877 153657 1435064095573.jpg 40037534
> 877 54584 invoice_1927133.pdf 56545392
> 877 91801 6844667.pdf 20779330
TOTAL: 153657 + 54584 + 91801 = 300042
Como posso incluir esse total na minha query? Em outra coluna e agrupar por
account_id?
Obrigado!
CREATE TABLE results ASWITH
accounts AS (
SELECT id
FROM clients
WHERE NOT (
(price = 0)
)
ORDER BY 1 LIMIT 30
) SELECT
r.parts[4]::INT AS account_id,
size,
r.parts[array_upper(r.parts, 1)] AS file,
full_pathFROM (
SELECT
string_to_array(full_path, '/') AS parts,
size,
i.st_ino,
full_path
FROM data.segments s
JOIN data.inodes i ON (i.st_ino = s.st_ino_target)
WHERE data.f_get_account_from_full_path(s.full_path) IN (SELECT *
FROM accounts)
AND i.size > 0) r;
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral