My query looks like this,
SELECT field1, field2, (SELECT TOP 1 field1 from table1) as field3
FROM table2
HAVING field3 > 0
it throws an error
invalid column name field3
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.
Don’t use a
HAVING. AWHEREis more appropriate here.Now, I am assuming that you have some work of
WHEREon the sub query. That uses values from table2. Otherwise, pull that query out and assign the value to a variable.Now, only do this if you need to return empty result set. If you don’t need the empty result set, we can exclude the query all together.