|
From: Booth Martin Silly question about the UNIQUE keyword in a logical file. I have a physical file keyed on account number. Included in the file is a field for the name. I want a logical file of unique names. There will be many duplicate names, but I only need any one of them. It seems to me that I want a logical keyed on name, only, since I don't care about having duplicates. How to do this? UNIQUE is not the answer. It works if I use Unique and key on name & account. But that gives me a lot of duplicate names. It works but looks messy. Am I missing something obvious?
Not really obvious, but intuitive if you're an old dinosaur like me. Less intuitive if you've been infected with the SQL virus <grin>. What you're looking for is the DISTINCT keyword in an SQL query, which is really an aggregate function, like MAX or SUM or COUNT. Logical views don't perform this sort of aggregation; they merely order and/or select records. So there's no clean way to do this. You CAN do it with an OPNQRYF KEYFIELD((name)) UNIQUEKEY(*ALL). It's a little strange, but it works. Joe
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.