Consider the following relational database : Doctor (dno, dname, dcity), Hospital (hno, hname, hcity), doc-hosp (dno, hno) Write a function to return count of number of hospitals located in ‘Ahmednagar’ City.
Answers
Answered by
0
Answer:
SELECT count(hospitals) FROM Hospital WHERE hcity = "Ahmednagar";
Explanation:
The given relational database schema is:
Doctor (dno, dname, dcity),
Hospital (hno, hname, hcity),
doc-hosp (dno, hno)
Now we want to write a query that can fetch a number of hospitals from Ahmednagar city.
- First, we will use a SELECT command that will select the number of total hospitals in the Hospital table.
- Now we want to apply the condition that the city of the hospital should be Ahmednagar. For this, we have used the WHERE clause with the condition.
- Lastly, we count the number of hospitals using the count function of SQL and return the result.
#SPJ2
Similar questions