For "x times" appears, it is best to use the HAVING clause. In your case, the query might look like this:
SELECT Date FROM table GROUP BY Date HAVING COUNT(*)<k
or, you need to select columns other than Date:
SELECT * FROM Table WHERE Date IN ( SELECT Date FROM table GROUP BY Date HAVING COUNT(*)<k)
You can also rewrite IN to an INNER JOIN, however, this will not give a performance gain, since in fact the query optimizer will do this for you in most DBMSs. Having an index by date will certainly improve performance for this query.
source share