| From: | Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com> |
|---|---|
| To: | pgsql(dot)sql(at)googlegroups(dot)com |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: what's wrong in this procedure? |
| Date: | 2011-03-01 07:56:34 |
| Message-ID: | AD4D4ED1-BC32-4799-A987-CAF2A3CA5663@enterprisedb.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Feb 25, 2011, at 11:16 PM, Camaleon wrote:
> This error is returned Erro de SQL:
>
> ERROR: column "Aguardando Pagto" does not exist at character 352 >>>
>
>
> create or replace function get_historico() RETURNS SETOF twiste.type_cur__historico AS '
>
> SELECT o.data_fim, sum(t.num_itens * t.valor) AS total, count(t.*) AS transacoes
> FROM ofertas o
> JOIN transacao t ON o.ofertas_id = t.ofertas_id
> JOIN municipio m ON o.municipio_id = m.municipio_id
> WHERE o.data_fim <= now() AND t.status IN("Aguardando Pagto", "Em análise", "Aprovado", "Completo")
> GROUP BY o.data_fim;
> '
> language 'sql';
try Following:
create or replace function get_historico() RETURNS SETOF twiste.type_cur__historico AS $$
SELECT o.data_fim, sum(t.num_itens * t.valor) AS total, count(t.*) AS transacoes
FROM ofertas o
JOIN transacao t ON o.ofertas_id = t.ofertas_id
JOIN municipio m ON o.municipio_id = m.municipio_id
WHERE o.data_fim <= now() AND t.status IN('Aguardando Pagto', 'Em análise', 'Aprovado', 'Completo')
GROUP BY o.data_fim;
$$
language 'sql';
Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
vibhor(dot)kumar(at)enterprisedb(dot)com
Blog:http://vibhork.blogspot.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | S G | 2011-03-01 19:47:12 | distinguishing identical columns after joins |
| Previous Message | Rob Sargent | 2011-02-25 21:39:44 | Re: what's wrong in this procedure? |