>>>No, I see the same, but what is the question then? We do indeed have just one N record for master_Code 3 or master_Code 4 and that's what my query is returning - no argument here.
>>>
>>>In other words, my query will return number of Ys if we have at least one Y and number of other Master_Ind if we have them and don't have 'Y'.
>>>It would not return the total number of records per Master_Code, if this was your point.
>>
>>You are playing with words. He had only one Y per master_code and he wanted to have the count of rows per master_code, not a constant 1 per master_code. See his original question where I replied with a 2 part SQL.
>>Cetin
>
>This query will return only records that have at least one 'Y' with the correct number of records per them:
>
>select MAX(name) as Name, COUNT(*) as CntRecs, MAX(Master_Ind) as Index1, Master_Code from @C T1
>group by master_code
>having sum(case when Master_Ind = 'Y' then 1 end) > 0
>
>but it seems that the problem is a problem of returning the correct values for the aggregated column and I'm afraid there may be no simple 1 select-SQL solution for VFP6. In VFP9 this problem can be easily solved using derived table approach.
"I'm afraid there may be no simple 1 select-SQL solution for VFP6. In VFP9 this problem can be easily solved using derived table approach." That is it. Thanks for repeating me:)
Cetin