如何计算正在进行的 openge 4gl 字段的唯一记录数?

How to count number of unique records of a field in progress openedge 4gl?

我的客户 table 的字段年龄为 。我怎样才能计算出有多少个不同的年龄?

您可以在 ABL 中使用 FOR 循环、BREAK BY 和计数器来完成。 在 ABL 中也有内置的聚合函数 (ACCUM),但它们在野外很少见...

DEFINE VARIABLE i AS INTEGER     NO-UNDO.

FOR EACH record NO-LOCK BREAK BY record.age:
    IF LAST-OF(record.age) THEN DO:
        i = i + 1.
    END.
END.
MESSAGE "There are " i " unique ages" VIEW-AS ALERT-BOX.

或由残废内置SQL:

SELECT COUNT(DISTINCT age) FROM record.

它会有点像这样: 在以下代码中将 City 替换为 age,将 employee 替换为 customer。

def var i as int no-undo.

for each employee break by city:
   if first-of (city) and  last-of(city)
   then do:

      i = i + 1.
   end.
end.

显示"The count of unique records" i 与帧a.