Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How I can count signs in records ?
Message
 
 
To
20/12/2002 13:39:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00734971
Message ID:
00734973
Views:
14
I think SCAN will do. Try
CRETAE CURSOR crsSum ( ;
	cName C(12), iYear I, ;
	iHOcount I, iILcount I	)
SCATTER MEMVAR NAME oRec
SELECT mytable
SCAN
	oRec.cName = cName
	oRec.iYear = iYear
	oRec.iHOcount = 0
	oRec.iILcount = 0
	FOR i=3 TO FCOUNT()
		lcVal = EVALUATE(FILED(i))
		DO CASE
		CASE lcVal = "HO"
			oRec.iHOcount = oRec.iHOcount + 1
		CASE lcVal = "IL"
			oRec.iILcount = oRec.iILcount + 1
		ENDCASE
		SELECT crsSum 
		APPEND BLANK 
		GATHER NAME oRec
	ENDFOR
ENDSCAN
>Hallo all VFP-Professionals,
>
>I've got this table:
>*+------+-----+-----+-----+-----+..+-----+-----+..+-----+
>*|cName_|iYear|t0101|t0102|t0103|..|t0131|t0201|..|t0631|
>*|c(12)_|i____|c(2)_|c(2)_|c(2)_|..|c(2)_|c(2)_|..|c(2)_|
>*+------+-----+-----+-----+-----+..+-----+-----+..+-----+
>*|Daisy_|_2003|___HO|___HO|___HO|..
>*|Donald|_2003|___HO|_____|
>*|Mini__|_2003|___IL|___IL|
>*|Mickey|_2003|___HO|___HO|
>*|..
>
>I look for a SQL- or xBASE-Code solution. I want to count the numbers of signs (HO=holiday,IL=ill,..) in the record. To get this table or cursor as answer:
>
>|Name__|Year|Holiday|_Ill__|
>+------+----+-------+------|
>|Daisy_|2003|______3|_____0|
>|Donald|2003|______1|_____0|
>|Mini__|2003|______0|_____2|
>|Mickey|2003|______2|_____0|
>
>Many thanks for help from germany.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform