Yep - my mistake. Thanks for putting that right.
Sure, the example I gave would have worked but it's not the right way to do it. A select criterion based on the author's ID code would definitely belong in the pre-grouped section of the query - under a WHERE clause.
In fact, the example I gave was pretty lame and would make no sense whatsoever in a properly normalised database wherein an author's ID code would never appear more than once in the Author table.
A better example would be as follows:
Picture the database behind an online forum such as dBForums. There would likely be a table called 'Thread' in which posts made by various dBForum members or 'authors' would be persisted - one record per post.
Let's say you want to retrieve a list of authors that have posted and the number of posts each has made, but only those authors with an ID code less than 20 and of those, only those that have posted more than 50 times. Finally, you want to order the dataset so that the most prolific posters are at the top.
SELECT Author_ID, Count(Author_ID) As NumberOfPosts
FROM Thread
WHERE Author_ID < 20
GROUP BY Author_ID
HAVING Count( Author_ID ) > 50
ORDER BY NumberOfPosts DESC
Lesson learnt: Never try to write a technical forum reply when Larry's in the office standing behind you talking about Golf at the height of his voice!
