I have a Sql Server query as:
SELECT AC.Author_ID, A.Author_Name, AC.Paper_ID, AC.CoAuthor_ID, AP.Venue_ID, AC.Year
FROM AuthorCoAuthor AC
JOIN AuthorPaper AP ON AP.Author_ID = AC.Author_ID AND
AP.Paper_ID = AC.Paper_ID
JOIN Author A ON A.Author_ID = AC.Author_ID
ORDER BY AC.Author_ID, AC.Year, AC.Paper_ID, AC.CoAuthor_ID, AP.Venue_ID
which returns almost 221317 rows. The sample output is:
Author_ID | Author_Name | Paper_ID | CoAuthor_ID | Venue_ID | Year
------------------------------------------------------------------
677 | Nuno Vasc | 812229 | 901706 | 64309 | 2005
677 | Nuno Vasc | 812486 | 901706 | 65182 | 2005
677 | Nuno Vasc | 818273 | 901706 | 185787 | 2007
1359 | Peng Sui | 818373 | 457348 | 18534 | 2005
1359 | Peng Sui | 868273 | 542321 | 184222 | 2006
... | ... | ... | ... | ... | ...
I want to have only 10 distinct Author_ID to be returned by the query, whereas I tried by adding
WHERE COUNT(DISTINCT(AC.Author_ID)) <= 10
this WHERE clause into the same query but still I'm getting same number of rows i.e. all the data which normally query returns.
Why my WHERE clause not working here?