Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Index problem
Message
From
29/10/2006 04:12:30
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Index problem
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01165351
Message ID:
01165351
Views:
50
Hi all
I created index for year+month and if there is no value for month 1, I get the month 10 value.
Please take a look on the following code, you get value for 01/2004 from 10/2004:
create cursor saled (theyear i, themonth i,units i)

for i=3 to 12
ii=i+18
iii=ii*ii
insert into saled values (2004,i,iii)
endfor

for i=1 to 12
ii=i+45
iii=ii*ii
insert into saled values (2005,i,iii)
endfor


for i=1 to 12
ii=i+72
iii=ii*ii
insert into saled values (2006,i,iii)
endfor


select saled 
index on alltrim(str(theyear))+alltrim(str(themonth))tag ymd
set order to tag ymd in saled 

select distinct themonth from saled  into cursor yearsm readwrite  nofilter
alter table yearsm add column sl2004 i
alter table yearsm add column sl2005 i
alter table yearsm add column sl2006 i


select yearsm
scan
	cthemonth=alltrim(str(yearsm.themonth))
	cyearm='2004'+cthemonth
	select saled 
	if seek (cyearm,'saled','ymd')=.f.
		loop
	endif
	replace yearsm.sl2004 with saled .units in yearsm
endscan



select yearsm
scan
	cthemonth=alltrim(str(yearsm.themonth))
	cyearm='2005'+cthemonth
	select saled 
	if seek (cyearm,'saled','ymd')=.f.
		loop
	endif
	replace yearsm.sl2005 with saled .units in yearsm
endscan


select yearsm
scan
	cthemonth=alltrim(str(yearsm.themonth))
	cyearm='2006'+cthemonth
	select saled 
	if seek (cyearm,'saled','ymd')=.f.
		loop
	endif
	replace yearsm.sl2006 with saled .units in yearsm
endscan



select yearsm
brow
Thank you
Chaim
Next
Reply
Map
View

Click here to load this message in the networking platform