| View previous topic :: View next topic |
| Author |
Message |
Pedro Restrepo Guest
|
Posted: Mon Apr 26, 2004 4:10 am Post subject: Filtering repeated fields in DBF files |
|
|
Hi,
I have a DBF file with 3 fields, something like this:
First field: Name
Second Field: Family Name
Third field: Sex
I am trying to make a SQL query that produces only the Family Names
repeated
Example:
DBF file:
John Smith Male
Paul Brown Male
Wilma Flintstone Female
Louis Armstrong Male
Charlie Brown Male
Neil Armstrong Male
Fred Flinstone Male
Betty Marble
Resulting query:
Brown
Armstrong
Flintstone
(something like using TOTAL ON in DBase with a counting field and after
that filtering by the counting field)
I have tried using GROUP, adding a counting field and using sum in that
new field but without success.
Could anybody help me?
Thanks in advance.
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Mon Apr 26, 2004 4:38 am Post subject: Re: Filtering repeated fields in DBF files |
|
|
SELECT DISTINCT LASTNAME
FROM yourTable
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Pedro Restrepo" <pedrores (AT) tutopia (DOT) com> wrote
| Quote: | Hi,
I have a DBF file with 3 fields, something like this:
First field: Name
Second Field: Family Name
Third field: Sex
I am trying to make a SQL query that produces only the Family Names
repeated
Example:
DBF file:
John Smith Male
Paul Brown Male
Wilma Flintstone Female
Louis Armstrong Male
Charlie Brown Male
Neil Armstrong Male
Fred Flinstone Male
Betty Marble
Resulting query:
Brown
Armstrong
Flintstone
(something like using TOTAL ON in DBase with a counting field and after
that filtering by the counting field)
I have tried using GROUP, adding a counting field and using sum in that
new field but without success.
Could anybody help me?
Thanks in advance.
|
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Mon Apr 26, 2004 2:04 pm Post subject: Re: Filtering repeated fields in DBF files |
|
|
Sverre Hårstadstrand wrote:
| Quote: |
SELECT DISTINCT Lastname FROM "table"
GROUP BY Lastname
HAVING COUNT(Lastname) > 1
|
No need for Distinct here since it is already being groupe by the same
field.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"True peace is not the absence of tension, but the presence of
justice." - Martin Luther King, Jr.
|
|
| Back to top |
|
 |
Pedro Restrepo Guest
|
Posted: Mon Apr 26, 2004 11:49 pm Post subject: Re: Filtering repeated fields in DBF files |
|
|
Hi,
Thanks a lot.
It works perfectly!!
Another question: Where can I find documentation about the use of SQL on
Delphi using DBF files?
I have had many problems like the one I asked yesterday. The SQL standard
frequently present problems when applied on DBF files.
Another time, Thank you very much !!
"Sverre Hårstadstrand" wrote:
| Quote: | Wayne Niddery [TeamB] wrote:
No need for Distinct here since it is already being groupe by the same
field.
That's true...
SverreEH
|
|
|
| Back to top |
|
 |
|