The functions count the number of runs that meet a specific criterion in the past records of a horse, jockey and stable respectively. The counts will be broken down by an expression value and returned as a character string.
Syntax
HrCountBy('lCountIf','eBreakdownExpr',nRaces,'fCondition',cDefaultValue,cIncluding)
JrCountBy('lCountIf','eBreakdownExpr',nRaces,'fCondition',cDefaultValue,cIncluding)
SrCountBy('lCountIf','eBreakdownExpr',nRaces,'fCondition',cDefaultValue,cIncluding)
Enhanced Syntax
Arguments 'lCountIf' and 'eBreakdownExpr' support enhanced syntax, which will be explained in the lower half of this page. By using the enhanced syntax you may:
•  carry out multiple statistics in a single pass of past record scanning 
•  customize the format of return string 
•  change the order of breakdown groups 
•  define a summary session in the return string 
•  define a string to separate statistical results 
Argument 
Description 
Example 

'lCountIf' 

'HrFP( )=1' 

'eBreakdownExpr' 
An expression by which results will be broken down. Omitting this argument tells the function do the statistics over all legitimate records. 
'HrDistance( )' 

nRaces 

6 

'fCondition' 

'For HrFP( )=1 While HrDate( )>Date(1999,9,1)' 

cDefaultValue 
Default value returned when no race satisfying the specified condition can be found. The data type of this value must be identical to that of normal return value. 

cIncluding 
When applying the function to past records, by default, races in the underlying meeting are not included. You may use this argument to change the scope. See the following page for details: The cIncluding Argument. 
'R' 
Returns
Character (The length of the returned character string depends on the breakdown expression. It is recommended to set the column data type to Multiline Text, so that the number of characters returned can be of any length.)
Examples
HrCountBy( ,'HrDistance( )')
The above function counts the number of races of each horse broken down by distance.
HrCountBy('HrFp( )=1','HrDistance( )')
The above function counts the number of winning races of each horse broken down by distance.
HrCountBy( ,'HrDistance( )', ,'For HrFp( )=1')
The above function counts the number of races in which the horse wins. The result is then broken down by distance.
The following picture shows the difference among the examples above:
•  In the first 2 examples, no filtering condition (4th argument) is passed into the MCL function. Therefore all races will be processed. 
•  In the 1st example all races, no matter winning or losing, will be counted. In the 2nd example, only records with HrFp( )=1 will be counted. All distances will be returned in the resulting string. 
•  In the third example, only the races satisfying the filtering condition ('For HrFp( )=1') will be processed. Therefore all losing races (HrFp( )=1 is not true) will neither be processed nor found in the returned string. 
Enhanced Syntax 1: Multiple Statistical Items in Argument 'lCountIf'
'..<<lCountIf1>>..<<lCountIf2>>...'
You may put more than one statistical item in the 'lCountIf' argument. Each is quoted by a pair of '<<' and '>>'. You may insert any number of characters outside the quotes.
Example
HrCountBy('<<HrFp( )=1>> wins in <<HrFp( )>> starts' ,'HrDistance( )')
The 'lCountIf' argument of this example contains 2 statistical items:
1.  <<HrFp( )=1>> counts number of wins (i.e., HrFp( )=1) in each distance group 
2.  <<HrFp( )>> counts number of valid starts, i.e., HrFp( ) is not null. 
If a horse has 5 1000m starts, 9 1200m starts and 3 1400m starts and among these starts it won in 1 1000m start, 2 1200m starts, the function will return the following string:
"1000(1 wins in 5 starts) 1200(2 wins in 9 starts) 1400(0 wins in 3 starts)"
Enhanced Syntax 2: A Summary Header Section in Argument 'lCountIf'
The 'lCountIf' argument can be divided into 2 sections using the separator ''. The section before the '' is a summary section. The statistical items in this section are applied to all starts which satisfy the condition specified by the 'fCondition' argument.
'..<<lOverallCountIf1>>..<<lOverallCountIf2>>.....<<lDetailCountIf1>>..<<lDetailCountIf2>>...'
Section 
Position 
Function 
Summary Section ..<<lOverallCountIf1>>..<<lOverallCountIf2>>... 
Left of  
Statistical items are for all records rather than individual breakdown groups 
Detail Section ..<<lDetailCountIf1>>..<<lDetailCountIf2>>... 
Right of  
Statistical items are for individual breakdown groups 
You may put a single character "~" in the summary section. The functions will copy the statistics items and text around the items into the summary section. The word "All" will be printed at the position for breakdown values.
Examples
HrCountBy('Totally <<HrFp( )=1>> wins in <<HrFp( )>> races: <<HrFp( )=1>> wins in <<HrFp( )>> starts' ,'HrDistance( )')
If a horse has 5 1000m starts, 9 1200m starts and 3 1400m starts and among these starts it won in 1 1000m start and 2 1200m starts, the function will return the following string:
"Totally 3 wins in 17 races: 1000(1 wins in 5 starts) 1200(2 wins in 9 starts) 1400(0 wins in 3 starts)"
HrCountBy('~<<HrFp( )=1>> wins in <<HrFp( )>> starts' ,'HrDistance( )')
Provided that you are applying the function to the same horse and races as those in the prior example, you will get the following return string:
"All(3 wins in 17 starts) 1000(1 wins in 5 starts) 1200(2 wins in 9 starts) 1400(0 wins in 3 starts)"
Enhanced Syntax 3: Statistical Function Modifiers
You may precede a statistical item with one of the following modifiers:
Modifier 
Function 
CNT: 
Counts records in which the value of the expression after "CNT:" is either true or not Null. 
CNTF: 
Similar to modifier "CNT:" except that if the statistics result of item is 0, the result of the related breakdown group will be removed. 
CNT%: 
Percentage of records counted (the expression after CNT% returns either true or not Null) in the breakdown group. 
CNTF%: 
Similar to CNT% except that if the statistics result of item is 0, the result of the related breakdown group will be removed. 
SUM: 
Calculate the sum the values of the expression following the modifier over each breakdown group. Null value will be skipped. 
AVE: 
Calculate the average the values of the expression following the modifier over each breakdown group. Null value will be skipped. 
MAX: 
Find the maximum value of the expression following the modifier over each breakdown group. Null value will be skipped. 
MIN: 
Find the minimum value of the expression following the modifier over each breakdown group. Null value will be skipped. 
ANY: 
Return an expression value of an arbitrary record in each breakdown group 
Example
HrCountBy('Wins:<<Cnt:HrFp( )=1>>,Best:<<Min:HrFp( )>>','HrDraw( )')
Or
HrCountBy('Wins:<<HrFp( )=1>>,Best:<<Min:HrFp( )>>','HrDraw( )')
The formulae above return the following 2 statictics of each draw position group:
1.  Number of wins <<Cnt:HrFp( )=1>>. Since "Cnt" is the default behaviour of HrCountBy( ), the modifier "Cnt:" is optional. Therefore, results of the above two functions are identical. 
2.  Best finishing position <<Min:HrFp( )>> 
Below is an example of the return string of the above functions:
"1(Wins:0,Best:3) 2(Wins:1,Best:1) 6(Wins:0,Best:12) 10(Wins:2,Best:1) "
HrCountBy('Wins:<<Cntf:HrFp( )=1>>,Best:<<Min:HrFp( )>>','HrDraw( )')
The statistics done in this example is basically identical to what is done in the functions of the previous example. The difference is if the count of the first statistical item <<Cntf:HrFp( )=1>> is 0, the breakdown group will be removed. If we apply the above function to exactly the same horse and race as prior example, the string returned will be as follows (please compare with prior example):
"2(Wins:1,Best:1) 10(Wins:2,Best:1) "
Enhanced Syntax 4: Customize Format of Group Caption in Argument 'eBreakdownExpr'
By default, statistical result of each breakdown group is enclosed by a pair of brackets, which is preceded by the value of the breakdown expression, i.e.: xxxx(...), where "xxxx" is the value returned by eBreakdownExpr and "...." is the result returned by the "lCountIf" argument. Following the rules to replace this default format:
1.  Enclose the breakdown expression with the quotes "<<" and ">>", which will act as a placeholder for the breakdown value. 
2.  Enter the text that you want to replace the default caption outside the quotes. 
3.  Once you have use the "<<" and ">>" quotes, the default brackets will no longer appear. 
Example
HrCountBy('Wins:<<HrFp( )=1>>,Best:<<Min:HrFp( )>> ','Draw#<<HrDraw( )>>:')
The return value of the function will be similar to the following:
"Draw#1:Wins:0,Best:3 Draw#2:Wins:1,Best:1 Draw#6:Wins:0,Best:12 Draw#10:Wins:2,Best:1 "
Please note that there are 2 spaces at the end of the first argument so that groups will not be too close to each other.
Enhanced Syntax 5: Embedding an Sorting Expression in Argument 'eBreakdownExpr'
You may define an expression for sorting breakdown groups and put it at the very beginning of the 'eBreakdownExpr' argument. The expression must be quoted by the brackets "{ }" and begins with "ASC:" or "DESC:" (for ascending and descending sorts). You may embed statistics items inside the sort expression. These statistics items must be enclosed by "<< >>". The format of the items is similar to a normal statistics item as described in the prior sections.
Examples
HrCountBy('HrFp( )=1','{Desc:<<Cnt:HrFp( )=1>>}HrDistance( )')
Returns "1400(6) 1200(4) 1000(1) 1600(0)"
HrCountBy('HrFp( )=1','HrDistance( )')
Returns "1000(1) 1200(4) 1400(6) 1600(0)"
The functions above carry out the same statistics. However, an expression for sorting is specified in the first function, which makes the groups being arranged in descending order of the win counts.
Enhanced Syntax 6: New String to Replace the Default Separator between 2 Statistical Result Items
You may define a new string to replace the default separator (space) between 2 statistical result items. Put a "" to the right of the breakdown expression followed by the string you want to replace the default separator. The following examples shows the syntax. You may include any number of expressions in your new separator. All expressions must be quoted with "<<" and ">>".
Examples
HrCountBy('HrFp( )=1','HrDistance( ) / ')
The function returns "1000(1) / 1200(4) / 1400(6) / 1600(0)". The new separator " / " is defined at the right of "".
HrCountBy('HrFp( )=1','HrDistance( )<<Chr(13)>>')
New line character Chr(13) is defined as the new separator. It separates statistical items into new lines. Please note that Chr(13) is an expression and must be enclosed with "<<" and ">>". The function returns the following 4 lines.
1000(1)
1200(4)
1400(6)
1600(0)
See also
HrCount( ), JrCount( ), SrCount( )  HrCountNZ( ), JrCountNZ( ), SrCountNZ( )  HrAverageBy( ), JrAverageBy( ), SrAverageBy( )  HrSumBy( ), JrSumBy( ), SrSumBy( )
Page url: http://www.racematenet.com/english/help/index.html?hrcountby.htm