September 25, 2008, 02:24 PM
Joan Williamson-KellyCount Distinct
Here's a nice equivalent to Oracle
"count(distinct fieldname || fieldname)"
for when you need to know how many unique combinations of two fields are in a dataset.
It concatenates the values of the two fields in a DEFINE, then uses SUM CNT.DST to get the count of distinct combinations. Note that the result is defined as I/9, else it returns ***** as a value.
DEFINE FILE EXAMPLETABLE
CONCAT_FIELDS/A70 = FIELD1 || FIELD2;
END
TABLE FILE EXAMPLETABLE
SUM CNT.DST.CONCAT_FIELDS/I9
END
Sorry - I didn't figure this out for CAR, but am sure it could be done there. I'm putting this entry in for next time I need it and can't remember/find what I did!
Thanks to an entry in the IBI TechSupport for the basic idea, which I extended to use a concatenated DEFINE.
Cheers!
September 25, 2008, 03:21 PM
j.grossBut use weak catenation:
CONCAT_FIELDS/A70 = FIELD1 | FIELD2;
lest rows like
field1 field2
====== ======
A BC
AB C
be confounded.