Good to hear we're BOTH correct :-). Sergey, you are one of the most hands-on MVPs VFP has ever had. Good work.
>Yes, I'm sure and you're correct too. :)
>In a regular query HAVING is applied after GROUP BY and before ORDER BY. In UNION query HAVING can only be applied to individual SELECTS not the final recordset. Only ORDER BY is applied to the final recordset.
>
>but in UNION query it's aplied to individual record sets not the final recordset produced by the query.
>
>>Are you sure about that, Sergey? I thought that HAVING was applied after almost all other criteria in the SELECT clause; that is, applied to the preliminary result set and that was the difference between HAVING and WHERE.
>>
>>>No, only ORDER BY clause is applied to the whole result set. The HAVING clause is applied to each query in UNION. You can use derived table to apply additional conditions
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05