Can someone convert this english to SQL I have tried several things but no luck.
SELECT CASE WHEN COUNT(person_id) > 3 THEN person_id end FROM table
I am trying to only get the person_id(s) that occur > 3 times in the table.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use:
You can not use aggregate functions, or column aliases to derived columns using aggregate functions, in the WHERE clause. These can only be used in the HAVING clause, which requires defining a GROUP BY clause (if it doesn’t already exist).
I don’t recommend using the column alias in GROUP BY or HAVING clauses – there’s a risk that the query will not be portable to other databases. SQL Server and MySQL are the only databases that I’m aware of that supports column aliases in the GROUP BY or HAVING clauses.