1

我正在显示学生记录的成绩。他们坐在低年级(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
4

2 回答 2

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;
于 2013-01-09T21:44:56.610 回答
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"
于 2013-01-09T18:39:48.680 回答