Fórum Relatório Financeiro por ano dividido por Mes #409576
21/11/2011
0
Tenho um banco de dados assim
Pagamento
Cliente, Dtpagamento,valor
dai qero que no relatorio apareca a ssim:
Cliente | Jan/10 | Fev/10 | mar/10 |etc......
_________________________________________________________________________
Francisco de amoras | R$ 12,20 | R$ 0,00 | R$ 12,20 |
Maria de Olaria | R$ 22,09 | R$ 1,11 | R$ 0,09 |
etc..
Gente como eu faço isso no delphi, por favor me ajudem....Se tiver um vídeo qe me mostre como fazer isso...
Aguardo
Kleber Silva
Curtir tópico
+ 0Posts
22/11/2011
Sérgio Andrade.
Diz para podermos pensar numa forma para resolver seu problema.
estou aguardando...
Gostei + 0
22/11/2011
Kleber Silva
QReport....Banco Firebird...
Gostei + 0
23/11/2011
Kleber Silva
Gostei + 0
24/11/2011
Emerson Nascimento
se o numero de meses a ser listado for variável, e melhor fazer no Delphi.
Gostei + 0
25/11/2011
Emerson Nascimento
Gostei + 0
25/11/2011
Kleber Silva
Nao, nao consegui, porfavor me mostre como fazer...
Gostei + 0
25/11/2011
Leandro
exe:
select nomecli, sum(janeiro) as janeiro, sum(fevereiro) as fevereiro
from(
select nomecli,
case when extract(month from datarecebimento) = 1 then sum(valorrecebido) end as janeiro,
case when extract(month from datarecebimento) = 2 then sum(valorrecebido) end as fevereiro,
from
--sua_tabela
where
--filtros
group by nomecli,datarecebimento
as selecao
group by nomecli
essa sintax do sql é do postgres acredito que funcione no FB com alguns ajustes
q coisa posta ai
abraços.
Gostei + 0
26/11/2011
Leandro
Gostei + 0
28/11/2011
Kleber Silva
Olha, meu banco ta assim:
Cliente
Id,Nome
Caixa
Data,Valor,Cliente
Porfavor, ajusta o script para mim nesse formato..
Obrigado..
Gostei + 0
30/11/2011
Emerson Nascimento
select
cx.cliente, cl.nome,
sum(case when extract(month from cx.data) = 1 then cx.valor else 0 end) as janeiro,
sum(case when extract(month from cx.data) = 2 then cx.valor else 0 end) as fevereiro,
sum(case when extract(month from cx.data) = 3 then cx.valor else 0 end) as marco,
sum(case when extract(month from cx.data) = 4 then cx.valor else 0 end) as abril,
sum(case when extract(month from cx.data) = 5 then cx.valor else 0 end) as maio,
sum(case when extract(month from cx.data) = 6 then cx.valor else 0 end) as junho,
sum(case when extract(month from cx.data) = 7 then cx.valor else 0 end) as julho,
sum(case when extract(month from cx.data) = 8 then cx.valor else 0 end) as agosto,
sum(case when extract(month from cx.data) = 9 then cx.valor else 0 end) as setembro,
sum(case when extract(month from cx.data) = 10 then cx.valor else 0 end) as outubro,
sum(case when extract(month from cx.data) = 11 then cx.valor else 0 end) as novembro,
sum(case when extract(month from cx.data) = 12 then cx.valor else 0 end) as dezembro
from
caixa cx
inner join
cliente cl on cl.id = cx.cliente
where
cx.data between 15.04.2011 and 31.07.2011
group by
cx.cliente, cl.nome
Gostei + 0
30/11/2011
Mauricio Neves.
A solução mais prática seria vc criar um clientdataset, por nele os campos do jeito que vc precisa e popular ele via sqlquery, o clientdaset é daqueles não ligado ao banco de dados.
Se tiver dúvidas posta ai.
Maurício das Neves
Gostei + 0
30/11/2011
Kleber Silva
cx.cliente,
cx.data,
cx.valor,
cl.id,
cl.nome,
sum(case when extract(month from cx.data) = 1 then cx.valor else 0 end) as janeiro,
sum(case when extract(month from cx.data) = 2 then cx.valor else 0 end) as fevereiro,
sum(case when extract(month from cx.data) = 3 then cx.valor else 0 end) as marco,
sum(case when extract(month from cx.data) = 4 then cx.valor else 0 end) as abril,
sum(case when extract(month from cx.data) = 5 then cx.valor else 0 end) as maio,
sum(case when extract(month from cx.data) = 6 then cx.valor else 0 end) as junho,
sum(case when extract(month from cx.data) = 7 then cx.valor else 0 end) as julho,
sum(case when extract(month from cx.data) = 8 then cx.valor else 0 end) as agosto,
sum(case when extract(month from cx.data) = 9 then cx.valor else 0 end) as setembro,
sum(case when extract(month from cx.data) = 10 then cx.valor else 0 end) as outubro,
sum(case when extract(month from cx.data) = 11 then cx.valor else 0 end) as novembro,
sum(case when extract(month from cx.data) = 12 then cx.valor else 0 end) as dezembro
from
caixa cx inner join cliente cl on cl.id = cx.cliente
where
cx.data between 01-01-2011 and 30-12-2011
group by
cx.cliente
order by
cx.data
Usei assim, e acontece esse erro...
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause).
o qe faço???
Gostei + 0
13/12/2011
Kleber Silva
cx.cliente,
cx.data,
cx.valor,
cl.id,
cl.nome,
sum(case when extract(month from cx.data) = 1 then cx.valor else 0 end) as janeiro,
sum(case when extract(month from cx.data) = 2 then cx.valor else 0 end) as fevereiro,
sum(case when extract(month from cx.data) = 3 then cx.valor else 0 end) as marco,
sum(case when extract(month from cx.data) = 4 then cx.valor else 0 end) as abril,
sum(case when extract(month from cx.data) = 5 then cx.valor else 0 end) as maio,
sum(case when extract(month from cx.data) = 6 then cx.valor else 0 end) as junho,
sum(case when extract(month from cx.data) = 7 then cx.valor else 0 end) as julho,
sum(case when extract(month from cx.data) = 8 then cx.valor else 0 end) as agosto,
sum(case when extract(month from cx.data) = 9 then cx.valor else 0 end) as setembro,
sum(case when extract(month from cx.data) = 10 then cx.valor else 0 end) as outubro,
sum(case when extract(month from cx.data) = 11 then cx.valor else 0 end) as novembro,
sum(case when extract(month from cx.data) = 12 then cx.valor else 0 end) as dezembro
from
caixa cx inner join cliente cl on cl.id = cx.cliente
where
cx.data between 01-01-2011 and 30-12-2011
group by
cx.cliente
order by
cx.data
Usei assim, e acontece esse erro...
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause).
o qe faço???
alguem pode me ajudar...
Gostei + 0
19/12/2011
Kleber Silva
era besteira minha....
Obrigado pelo codigo, funcionou legal...
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)