Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum Fields in a table
Message
De
12/09/2011 12:05:14
Moacyr Zalcman
Independent Consultant
São Paulo, Brésil
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Sum Fields in a table
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Desktop
Divers
Thread ID:
01523260
Message ID:
01523260
Vues:
86
Hi, people

I have a table named nf with a field dataemissao( date) and a field nfnum and indexed by these fields, and a table named nfitens with foreign Key nfnum from nf table, and two fields vcofins and vpis( numeric values). I need the sum of these fields in a period of time. It's not surprise that the performance of the query that sums these( vPIS and vCOFINS) decrease with the period of time increase.
I can put the sum of vpis and vcofins for every nfnum in the nf table and the problem is solved. But is there any other idea to speed the query?
 SELECT 
 	SUM( Nfitens.vCOFINS) as VCOFINS,
 	SUM( Nfitens.vPIS) as VPIS
 	FROM 
     nf Nf inner join Nfitens on nf.nfnum=nfitens.nfnum
	 WHERE nf.dataemissao  BETWEEN  ?tddatefrom and ?tddateto
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform