如果计数超过 5,如何只显示结果

How to only show results if count if more than 5

是否可以只显示同一个cust-num出现3次以上的结果

我试过使用变量 ( count = count + 1.)。但它计算了所有的结果。

      icount = kcount + 1.
   display
cust-name cust-num state count

Cust Num Name   State   Count
1001     Apple  NH  1
1001     Apple  NH  2
1001     Apple  NH  3
1002     Orange BD  6
1002     Orange BD  7
1002     Orange BD  8
1002     Orange BD  9

Expected            

Cust Num    Name    State   Count
1001            Apple   NH  1
1002            Orange  BD  2

好的,首先你可能需要这样的 temp-table:

DEFINE TEMP-TABLE ttCust LIKE customer
    FIELD count AS INTEGER.

然后,删除您发布的代码并添加:

FIND FIRST ttCust WHERE ttCust.cust-num = customer.cust-num NO-ERROR.
IF NOT AVAILABLE ttCust then DO:
   CREATE ttCust.
   BUFFER-COPY customer TO ttCust. /* Copies the whole record to your temp-table */
END.
ASSIGN ttCust.count = ttCust.count + 1.

在您的常规 FOR EACH 客户结束后,添加:

FOR EACH ttCust where ttCust.count >= 3:
    DISPLAY ttCust.cust-num ttCust.name ttCust.state ttCust.count.
END.

希望对您有所帮助。