I'm trying to create a table using these commands:
SELECT
data_req,
count(servico) as qtdeServico,
count(metodo) as qtdeMetodo,
consumerid,
metodo,
status_metodo,
servico,
sum(tempo_req)
INTO
consolidado
FROM
requisicoes AS r
WHERE
r.data_req > SELECT MAX(c.data_req) FROM consolidado c
GROUP BY
data_req, consumerid, metodo, status_metodo, servico;
Unfortunately I'm getting an error at the select clause inside where. I'm using postgres.
Any suggestions? Thanks in advance.
consolidadowhile also selecting from that same table. Sample data and desired results are really helpful.