BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Filtering repeated fields in DBF files

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Pedro Restrepo
Guest





PostPosted: Mon Apr 26, 2004 4:10 am    Post subject: Filtering repeated fields in DBF files Reply with 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
Mike Shkolnik
Guest





PostPosted: Mon Apr 26, 2004 4:38 am    Post subject: Re: Filtering repeated fields in DBF files Reply with quote



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





PostPosted: Mon Apr 26, 2004 2:04 pm    Post subject: Re: Filtering repeated fields in DBF files Reply with quote



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





PostPosted: Mon Apr 26, 2004 11:49 pm    Post subject: Re: Filtering repeated fields in DBF files Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.