You need a double SELECT.
First you get w_id along with the label of the first article:
SELECT w_id, MIN(timestamp) as publish FROM articles GROUP BY w_id
Then you request to publish no earlier than 5:
SELECT w_id, MIN(timestamp) as publish FROM articles GROUP BY w_id HAVING publish >= 5;
You will then join this βtableβ with writers to get the name if you want.
But if you only need a count, you don't need a writers table at all:
SELECT COUNT(*) AS answer FROM ( SELECT w_id, MIN(timestamp) AS publish FROM articles GROUP BY w_id HAVING publish >= 5 ) AS counter;
Test: http://sqlfiddle.com/#!2/0e90f/30/0
source share