我正在显示学生记录的成绩。他们坐在较低的一年(AS ...),然后选择继续某些课程到高年级(A ...)。这意味着每个学生都有以下数据集:
+----------------------+-------+-----------+-----+
| Name | Grade | End | Code|
+----------------------+-------+-----------+-----+
| A Business | C | 06-Jul-12 | BUS |
| A English | B | 06-Jul-12 | ELL |
| A History | C | 06-Jul-12 | HIS |
| AS Business Studies | E | 08-Jul-11 | BUS |
| AS Critical Thinking | B | 08-Jul-11 | CRT | <-- lower year only
| AS English | D | 08-Jul-11 | ELL |
| AS History | F | 08-Jul-11 | HIS |
+----------------------+-------+-----------+-----+
对于每个学生记录,我只想显示A和AS级别的成绩。在上面的例子中,它将抑制AS批判性思维:
A Business | C
A English | B
A History | C
AS Business Studies | E
AS English | D
AS History | F
如果不编辑基础数据集,Crystal Reports是否可以抑制那些仅显示为AS等级的记录?例如:
If Code not present in records AND Name starts with AS
Suppress
Else
Display
答案 0 :(得分:2)
假设所有“A”值都出现在“AS”值之前,我会使用一个数组来存储到目前为止找到的代码。
首先,初始化数组,这可以在报告标题中,或者如果结果按学生分组,则在学生组标题中。
WhilePrintingRecords;
Global StringVar Array CodesFound;
Redim CodesFound[1];
CodesFound[1] := "";
//print nothing
"";
然后,更新详细信息中的列表
WhilePrintingRecords;
Global StringVar Array CodesFound;
If Left({table.Name},2) = "A "
Then (
If CodesFound[1] = ""
Then (
CodesFound[1] := {table.Code};
)
Else (
Redim Preserve CodesFound[UBound(CodesFound) + 1];
CodesFound[UBound(CodesFound)] := {table.Code};
);
);
//print nothing
"";
最后,在条件抑制部分:
WhilePrintingRecords;
Global StringVar Array CodesFound;
Local BooleanVar found := false;
Local NumberVar i;
If Left({table.name},2) = "AS"
Then (
For i := 1 to UBound(CodesFound) do (
If CodesFound[i] = {table.Code}
Then found := true;
);
//suppress if not found
Not(found);
)
Else
//Not an "AS", don't suppress
false;
答案 1 :(得分:1)
**编辑**
我对隐含问题的更好解决方案是在代码字段中将逻辑表加入到自身中:
-- Oracle syntax
WITH
V AS (
SELECT Name, Grade, End_Date, Code
FROM ...
)
SELECT *
FROM V
INNER JOIN V V2 ON V.Code=V2.Code
AND SUBSTR(V2.Name,1,2)='A '
如有必要:
将条件抑制公式添加到“详细信息”部分:
IsNull({table.Code}) AND Left({table.Name},2)="AS"