Q:

MySQL filtering out a criteria

I thought this is simple with you guys here, but a little bit hard for me to figure out how to do this. I have tried but did not get the result so wanted to consult every one here.
Here I have three columns: state, store, laptop_brand
I wanted to filter out how many store have the amount of HP < 3 ( group by State).
My idea on this is like this: 
SELECT state, count(laptop_brand) 
 FROM sample_survey 
 WHERE count(select store from sample_survey where laptop_brand = "HP") <3       group by state
but I could not make it real.
sample_survey
Attached pic snippet data for your reference.
Thank you for any suggestions.

A:

Please Try this:
SELECT state, store, count(laptop_brand) as total_laptop

FROM sample_survey

WHERE laptop_brand = "HP"

GROUP BY state, store

HAVING count(laptop_brand)<3

