Subject | Re: [firebird-support] duplicate string fields? |
---|---|
Author | Ann W. Harrison |
Post date | 2008-02-07T19:24:58Z |
Woody wrote:
group with more than one member. Here's an alternative:
select a.noteid, a.folerid, b.noteid, b.folderid, a.subject
from dbnotes a
join dbnotes b on (a.subject = b.subject)
where a.noteid < b.noteid
Good luck,
Ann
> ifitsx wrote:Err, if you group by the primary key, you're seldom going to find a
>>
>> I want to find records that have a duplicate string field.
>>
> The clue is in the error message. "(not contained in either an aggregate
> function .. )"
> The having clause is only used for aggregate queries which contain,
> among other things, counts, sums, etc. Change your query to include the
> count(*) and also change the group by to include all non-aggregate fields:
>
> select noteid, folderid, subject, count(*)
> from dbnotes
> group by noteid, folderid, subject
> having count(*) > 1
group with more than one member. Here's an alternative:
select a.noteid, a.folerid, b.noteid, b.folderid, a.subject
from dbnotes a
join dbnotes b on (a.subject = b.subject)
where a.noteid < b.noteid
Good luck,
Ann