Hi
I'm very stuck with this query, any help would be much appreciated i'm very new to SQL. Basically I need the query to give me a list of hospitals that have less than a given number of patients (for example less than 2) within a certain state (for example 001).
My current attempt is:
select count(hospital_no)quantity,hospital_no
from Records_table
where state_no = '001'
and where quantity < '2'
group by species_no
but I cant see where I am going wrong, I think i may need to add a subquery somehow? In the above code, 'quantity' is a name given to the result of the count as shown. I have tried to reference it later to say give me all records with less than 2 for quantity but it doesnt take it.
I am using SQL Query Analyzer for this project.