Is it possible to use a WHERE clause after a HAVING clause?
The first thing that comes to my mind is sub queries, but I’m not sure.
P.S. If the answer is affirmative, could you give some examples?
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.
No, not in the same query.
The
whereclause goes before thehavingand thegroup by. If you want to filter out records before the grouping the condition goes in thewhereclause, and if you want to filter out grouped records the condition goes in thehavingclause:If neither of those are possible to use for some odd reason, you have to make the query a subquery so that you can put the
whereclause in the outer query: