Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filter Records
Message
From
07/02/2013 00:38:40
 
 
To
06/02/2013 08:24:12
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01565243
Message ID:
01565363
Views:
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform