StoredProcedure

Firebird

30/08/2003

Pessoal tenho o seguinte select:
select
CS.IDSETOR,
CS.IDSETORROTA,
CS.IDSETORSUBROTA,
CS.IDSETORUNIDADE,
NF.VALORTOTALDANOTA,
sum(NF.valortotaldanota)
from CADASTRO C
inner join
CADASTROSETORCLIENTE CS
on(CS.IDCADASTRO=C.IDCADASTRO)
inner join
NOTASFISCAIS NF
on(NF.IDCADASTRO=C.IDCADASTRO)
where
cadastro.idempresafilial = 101 and
extract(year from NF.dataemissaodanota) between 2001 and 2002
group by
CS.IDSETOR,
CS.IDSETORROTA,
CS.IDSETORSUBROTA,
CS.IDSETORUNIDADE,
NF.VALORTOTALDANOTA

Eu preciso fazer uma Stored Procedure para q ele me apresente os dados assim.

Descrição da Rota Ano JAN FEV MAR ABR MAI JUN
001-SETO SUL 1999 1845 1530 1928 1672 2081 1849
2000 2253 2486 3120 1983 2734 2272
-----------------------------------------------------------------------------------
002-SETOR CENTO 1999 356 356 297 323 428 572

Os meses vão até DEZ mas coloquei só até Junho para exemplificar
Ou seja eu vou informar:
Empresa Filial
Ano Inicial e Ano Final
E ai ele deve me retorar algo como descrito acima o total de cada mes.
Estou tentando fazer uma Stored Procedure mas como não tenho expericencia com isso estou tomando um banho qualquer ajunda será bem vinda.
[list=][/list][list=][/list]


Raziel

Raziel

Curtidas 0
POSTAR