Subject | Re: [firebird-support] Duvida com Query de Seleção . |
---|---|
Author | Alexandre Benson Smith |
Post date | 2004-01-13T17:32:01Z |
At 12:52 13/01/2004 -0200, you wrote:
This is an international group, and any questions should be made in
English. If you wish to use a portuguese list take a look at
www.firebase.com.br Or if you wish send private e-mail to me in portuguese
and can try to help you. Helen, I don't want do be the moderator just try
to make an advice to my "native friends" :-).
Esta lista é internacional, e as perguntas e respostas devem ser feitas em
Ingles. Se voce tiver dificuldade tente usar as listas da comunidade
firebird em lingua portuguesa olhe no site www.firebase.com.br. Se preferir
mande um e-mail privado pra mim que posso tentar te ajudar.
When I need such a report, I use to do it with Crystal Reports, Crystal
will request the data from Firebird and format it the way you want. Take a
look on "crosstab reports" in the help. But this is off-topic here.
You could use the following SQL statment this will return the values you
want, but not in the "format" you want:
select
Nome, Sum(Valor) as Total, extract(year from Data) as Ano,
extract(month from Data) as Mes
from
Pedidos
where
Data between '2003-11-01' and '2003-12-31' and
Cliente between 'ABC' and 'XYZ'
group by
Nome, extract(year from Data), extract(month from Data)
this will return something like this
Cliente Total Ano Mes
ABC 100,00 2003 11
ABC 300,00 2003 12
XYZ 400,00 2003 11
XYZ 800,00 2003 12
...
Then you could format it in a cross-tab fashion on the client side.
One different aspect from what you want is that if a Client has no purchase
orders in some period this query will return no rows instead of value "0"
I prefer to return "raw" data from the server and make the cosmect part on
the client instead of make a lot of SP's or much complex queries, but this
is just MY preference.
HTH
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
----------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
[Non-text portions of this message have been removed]
>Bem, eu não sei exatamente qual é seu objetivo, porém se você tem umaHi,
>tabela "tbl" e deseja tirar as informações eu creio que você pode usar:
>
>select f1, f2, f3
>from tbl
>where fdata between dt1 and dt2 and
> fclicod between cl1 and cl2
>order by fclicod,fdata
>
>Assim você estará selecionando os campos f1,f2 e f3 de tbl, em um intervalo
>de data e cliente, ordenado por cliente e data, nesta ordem, ai você poderá
>fazer o que quiser com seu gerador de relatório.
>Se quiser retornar os valores já somados talves seja uma boa idéia usar
>stored procedure.
>
>Max
>
>At 13:10 13/01/04, you wrote:
> >Caros amigos estou com um problema, que ja pensei em
> >varias maneiras de soluciona-lo mas não consegui. meu
> >suspervisor me pedi um relatório onde este traria o
> >nome do clientes es separado por meses do periodo em
> >que eu escolher ele me traga o total de venda por
> >mesmo
> >mais ou menos assim :
> >periodo 01/10/2003 a 01/01/2004
> >clientes X a Y
> >
> >cliente 10/2003 11/2003 12/2003 01/2004
> >
> >xxxxxxxxxxx 1500,00 800,00 0,00 1200,00
> >yyyyyyyyyyy 0,00 500,00 1000,00 0,00
> >
> >tenho a tabela que me fornece todos este dados, mas
> >não sei como agrupar a soma das vendas pelos meses que
> >estão no intervalo de data solicitado..
> >Por favor me ajudem. desde já agradeço
This is an international group, and any questions should be made in
English. If you wish to use a portuguese list take a look at
www.firebase.com.br Or if you wish send private e-mail to me in portuguese
and can try to help you. Helen, I don't want do be the moderator just try
to make an advice to my "native friends" :-).
Esta lista é internacional, e as perguntas e respostas devem ser feitas em
Ingles. Se voce tiver dificuldade tente usar as listas da comunidade
firebird em lingua portuguesa olhe no site www.firebase.com.br. Se preferir
mande um e-mail privado pra mim que posso tentar te ajudar.
When I need such a report, I use to do it with Crystal Reports, Crystal
will request the data from Firebird and format it the way you want. Take a
look on "crosstab reports" in the help. But this is off-topic here.
You could use the following SQL statment this will return the values you
want, but not in the "format" you want:
select
Nome, Sum(Valor) as Total, extract(year from Data) as Ano,
extract(month from Data) as Mes
from
Pedidos
where
Data between '2003-11-01' and '2003-12-31' and
Cliente between 'ABC' and 'XYZ'
group by
Nome, extract(year from Data), extract(month from Data)
this will return something like this
Cliente Total Ano Mes
ABC 100,00 2003 11
ABC 300,00 2003 12
XYZ 400,00 2003 11
XYZ 800,00 2003 12
...
Then you could format it in a cross-tab fashion on the client side.
One different aspect from what you want is that if a Client has no purchase
orders in some period this query will return no rows instead of value "0"
I prefer to return "raw" data from the server and make the cosmect part on
the client instead of make a lot of SP's or much complex queries, but this
is just MY preference.
HTH
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
----------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
[Non-text portions of this message have been removed]