>>>Hi,
>>>I have two tables with one-to-many relation.
>>>Is there a way - in one sql statement - to count all the records
>>>which have only one record relation in the "many" table.
>>>
>>>Thanks.
>>
>>Untested:
>>
>>
>>SELECT PKinOneTable ;
>> FROM TheManyTable ;
>> GROUP BY PKinOneTable ;
>> HAVING CNT(*) = 1 ;
>> INTO CURSOR OnlyOneChild
>>
>>
>>Tamar
>
>Thanks, it's ok but the problem is that it doesn't count the records but lists them.
select count(MT.FkField) from TheManyTable MT INNER join (SELECT FKField ;
FROM TheManyTable ;
GROUP BY FkField ;
HAVING CNT(*) = 1) O1 on MT.FkField = O1.FkField
If it's not broken, fix it until it is.
My Blog