Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Service in Groups
Message
 
 
To
18/09/2008 13:37:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01348676
Message ID:
01348937
Views:
12
>It does not matter, I shall wait for solution

Hi Tariq,

I was thinking a bit about your problem. Here is how I can approach it.
Select ceiling(year(EndDate) - year(StartDate)/5) as Period, 
count(*) as NumEmployees from curYears group by 1 order by 1 
into curToProcess readwrite
index on Period tag Period
go bottom in curToProcess
local lnMaxPeriod as Integer, lcCommand as String

lnMaxPeriod = curToProcess.Period && Maximum number of periods

** Now do we want to create field for every periods, even if we don't have them? Let's assume yes.

lcCommand = "create cursor curFinal  ("

for lnI =1 to m.lnMaxPeriod + 1
      lcCommand = m.lcCommand + "var" + transform(m.lnI) + " I " + (iif(m.lnI <=m.lnMaxPeriod, ", ", ")")
next

execsript (m.lcCommand) && or &lcCommand - create the curFinal cursor

append blank in curFinal
scatter memvar

for lnI =0 to m.lnMaxPeriod 
   if seek(m.lnI, 'curToProcess')
       store  curToProcess.NumEmployees to ("m.var" + transform(m.lnI +1))
   endif
next

gather memvar  
** Now we have our curFinal with one line of all number of employees per period of service.
This is from the top of my head - not tested.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform