Answer the question
In order to leave comments, you need to log in
How to make a SQL fetch?
Hello. The comments
table has a task_id numeric field that stores non-unique entries.
You need to make a unique selection of all task_id entries that have the same value less than 3 .
Example: if the task_id contains such entries (1, 1, 2, 3, 3, 3, 4, 5, 5, 5, 5), then you need to get (1, 2, 4) the values 3 and 5 are not included, because entries 3 and 5 are greater than three.
I tried to solve it like this, but it's definitely wrong. because it returns an empty tuple
SELECT task_id FROM comments GROUP BY task_id HAVING COUNT(task_id)<=3
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question