Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filter Records
Message
De
07/02/2013 03:24:18
 
 
À
07/02/2013 00:38:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01565243
Message ID:
01565368
Vues:
50
>Dear Mr.Gregory
>
>Following is the code which I am using to filter records of a particular city from tmpSi, I hope you will understand what I want if you go through this.
>
>
>vCity = Thisform.ContCriteria.cboCity.DisplayValue
>
>Select simain.sino, ;
>	simain.invdate, ;
>	simain.pcode, ;
>	simain.location, ;
>	sisub.icode, ;
>	sisub.qntymaj, ;
>	sisub.qntymin, ;
>	sisub.ratemaj, ;
>	sisub.ratemin ;
>	FROM simain, sisub ;
>	WHERE simain.sino = sisub.sino AND ;
>	simain.pcode # 'CP011' ;
>	Into Cursor tmpsi ;
>	ORDER By simain.sino Readwrite
>Alter Table tmpsi Add Column City c(52) Null
>INDEX on pcode+location TAG ploc ADDITIVE 
>
>Select srmain.srno, ;
>	srmain.srdate, ;
>	srmain.pcode, ;
>	srmain.location, ;
>	srsub.icode, ;
>	srsub.qntymaj, ;
>	srsub.qntymin, ;
>	srsub.ratemaj, ;
>	srsub.ratemin ;
>	FROM srmain, srsub ;
>	WHERE srmain.srno = srsub.srno AND ;
>	srmain.pcode # 'CP011' ;
>	Into Cursor tmpsr ;
>	ORDER By srmain.srno Readwrite
>Alter Table tmpsr Add Column City c(52) Null
>INDEX on pcode+location TAG ploc ADDITIVE 
>
>Select tmpsi
>Go Top
>Scan While ! Eof()
>	mpcode = pcode
>	mloca  = location
>	Select location
>	Set Order To ploc
>	Seek mpcode+mloca In location
>	mCity = City
>	Select tmpsi
>	Replace City With mCity
>Endscan
>
>Select tmpsr
>Go Top
>Scan While ! Eof()
>	mpcode = pcode
>	mloca  = location
>	Select location
>	Set Order To ploc
>	Seek mpcode+mloca In location
>	mCity = City
>	Select tmpsr
>	Replace City With mCity
>Endscan
>
>Select Year(invdate) As Yur, ;
>	cMONTH(invdate) As Munth, ;
>	city as City,;
>	SUM(qntymaj) As Cartons, ;
>	SUM(qntymin) As Units, ;
>	Sum(Iif(qntymin*ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As amount, ;
>	Cast(0 As N(2,0)) As sno ;
>	FROM tmpsi Where Year(invdate) Between myear1 And myear2 AND city = vCity ;
>	GROUP By 1,2,3 ;
>	ORDER By 1,2,3 Into Cursor siData Readwrite NOFILTER
>Index On Yur Tag Yur
>
>Select Year(srdate) As Yur, ;
>	cMONTH(srdate) As Munth, ;
>	city as City,;
>	SUM(qntymaj) As Cartons, ;
>	SUM(qntymin) As Units, ;
>	Sum(Iif(qntymin*ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As amount, ;
>	Cast(0 As N(2,0)) As sno ;
>	FROM tmpsr Where Year(srdate) Between myear1 And myear2 AND city = vCity ;
>	GROUP By 1,2,3 ;
>	ORDER By 1,2,3 Into Cursor srData Readwrite NOFILTER
>Index On Yur Tag Yur
>
>
>tmpSi = Sales table and similarly,
>tmpSr = Sales Return table
>
>I then subtract both the fields to get the net sales.
>
>Although I am getting the result but it is taking too much time to display.
>
>Is there any alternate to get the required result?
>
>Thanks
>
>Saif


i will only cover tmpsi. - tmpsr is similar. You don't need the scan loop, you can get City with a join
Select simain.sino, ;
	simain.invdate, ;
	simain.pcode, ;
	simain.location, ;
	location.City, ;         && added
	sisub.icode, ;
	sisub.qntymaj, ;
	sisub.qntymin, ;
	sisub.ratemaj, ;
	sisub.ratemin ;
	FROM simain, sisub ;
	    left join locaction on ( location.pcode + location.location= simain.pcode + simain.location) ;  && added
	WHERE simain.sino = sisub.sino AND ;
	simain.pcode # 'CP011' ;
	Into Cursor tmpsi Readwrite ;
	ORDER By simain.sino 
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform