Update your 3rd query to –
SELECT Patient.Name, Patient.age
from Patient
where patient.age < '50'
and EXISTS (
SELECT Prescription.DoctorID
from Prescription
where Patient.Primary_DoctorID = Prescription.DoctorID
and Prescription.P_ID = (
select Prescription_Medicine.P_ID
FROM Prescription_Medicine
where Prescription_Medicine.Tradename="Vitamin" )
);
And update your 4th query to –
SELECT dname
FROM doctor d
JOIN (SELECT speciality, MAX(doctor.experience)
FROM doctor
GROUP BY speciality) d1 on d.speciality = d1.speciality
WHERE speciality = 'Heart'
solved what will be the sql query code of this “Healthcare” database?