Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Service in Groups
Message
 
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:
01348681
Views:
17
>>Dear Experts
>>
>>Some company wants to maintain Employees' Service duration in 5 years groups as
>>
>>
>>CREATE cursor Years (cname c(15),arrival D(8), Depart d(8))
>>INSERT INTO Years VALUES ('A',{^1945-07-01},{^1965-07-01}) 	&& 20 year
>>INSERT INTO Years VALUES ('B',{^1975-07-01},{^1977-07-01})	&& 2 year
>>INSERT INTO Years VALUES ('C',{^1975-07-01},{^1977-07-01})	&& 2 year
>>INSERT INTO Years VALUES ('D',{^1970-07-01},{^1991-07-01})	&& 21 year
>>INSERT INTO Years VALUES ('E',{^1981-07-01},{^1986-07-01})	&& 5 year
>>INSERT INTO Years VALUES ('F',{^1981-07-01},{^1986-07-01})	&& 5 year
>>INSERT INTO Years VALUES ('G',{^1987-07-01},{^1997-07-01})	&& 10 year
>>INSERT INTO Years VALUES ('H',{^1998-07-01},{^2009-07-01})	&& 11 year
>>INSERT INTO Years VALUES ('H',{^1940-07-01},{^1975-07-01})	&& 35 year
>>
>>I want to get following results
>>
>>var1=4  && duration is between 1 to 5 year
>>var2=1	&& duration is between 6 to 10 year
>>var3=1	&& duration is between 11 to 15 years
>>var4=1	&& duration is between 16 to 20 years
>>var5=1	&& duration is between 21 to 25 years
>>var6=0	&& duration is between 26 to 30 years
>>var7=1	&& duration is between 31 to 35 years
>>
>>and so on. Every group consists on 5 years
>>
>>Please help
>
>
>select sum(iif(between(Duration,1,5), 000000000)) as Var1, 
>sum(iif(between(Duration,6,10), 000000000)) as Var2, etc. 
>from  (select year(EndDate) - year(StartDate) as Duration from curYears) Dur
Year(Date1) - Year(date2) as Age is very approximate calculation, but I guess it will be sufficient for your purposes.
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