Hi all,
Usually I use the "HAVING" clause in a SELECT statement to limit result rows in a situation where I am doing a GROUP BY at the same time (like a count using a GROUP BY).
Is it legit - i.e. will I get correct results - to use filter conditions in the HAVING clause to avoid repeating a filter condition in a UNION? i.e. I have a 3 way UNION each of which has a couple of unique conditions but then all 3 of them have 3 more conditions. Instead of repeating these last 3 conditions 3 times, I thought maybe I could put them in as a "HAVING" as I think I remember reading that that works like a WHERE clause and is processed after the UNION is done. BTW, the unique conditions are complex enough I don't want to try to code a complicated set of conditions joined by two "OR"s. By doing it as a UNION, it is much more readable.
Just want to confirm. Here is the example:
SELECT ;
File.* ;
FROM File ;
WHERE <unique conditions> ;
UNION SELECT ;
File.* ;
FROM File ;
WHERE <more unique conditions> ;
UNION SELECT ;
File.* ;
FROM Files ;
WHERE <more unique conditions> ;
HAVING ;
< 3 conditions common to the above)
INTO CURSOR x
Thanks,
Albert