Patient ( pid : integer, lname : string, fname : string, primary_did : integer,
ID: 3681146 • Letter: P
Question
Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer)
MedicalTest (testid: integer, pid: integer, dateOrdered: date, whoOrdered: integer, dateGiven: date, timeGiven: time, nid: integer, techID: integer)
TestInformation (testid: integer, name: string, cost: integer, machine_needed: string)
Write query in SQL.
1.) Find the last and first names of all patients who have a medical test that requires a machine called an "audiometer". Also include in the results the dates the tests were given. The results should be sorted by the test dates.
Explanation / Answer
SELECT lname,fname,dateOrdered FROM Patient,MedicalTest,Testinformation WHERE Patient.pid=MedicalTest.pid AND Testinformation.testid=MedicalTest.pid AND Testinformation.name="audiometer" ORDER BY dateOrdered ASC ;