Write a query in SQL to Obtain the names of all patients who has been prescribed some medication by his/her physician who has carried out primary care and the name of that physician
- برمجة سي كيو ال sql
- 2021-09-06
- mhanasmh00489829403
الأجوبة
SELECT pt.name AS "Ptient",
p.name AS "Physician"
FROM patient pt
JOIN prescribes pr ON pr.patient=pt.ssn
JOIN physician p ON pt.pcp=p.employeeid
WHERE pt.pcp=pr.physician
AND pt.pcp=p.employeeid;
Sample Output:
Ptient | Physician ------------+------------- John Smith | John Dorian (1 row)
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال