Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Database Schema: Hospital ( hid , name, city ) / / hospital ( hid , name, city ) Doctor ( did , name, specialty, hid
Database Schema:
Hospital hid name, city hospital hid name, city
Doctor did name, specialty, hid doctor did name, specialtyArea, hid
Patient pid name, status:PosNeg patientpid name, lastTestResult:PosNeg
Admitted pid hid, admissionDate, entubationDate, deathDate, did patientAdmission pid hid, admissionDate, entubationDate, deathDate, did
TestType tid name, price, accuracy, origin:chgrtr testType tid name, price, reliability, origin:chgrtr
Test pid tid, date, result:PosNegtestpid tid, date, result:PosNeg
Using the above database schema, write the following questions in SQL:
pointsINEXISTSSOMEALL Write a query in different ways using IN EXISTS, and SOMEALL to return the record all columns of the hospital table of the hospital where the doctor named 'Ali KURT' works.
pointsEXISTS Write a query in different ways using NOT IN NOT EXISTS, and SOMEALL to return the records all columns of the hospital table of the hospitals where the doctor named 'Ali KURT' does not work.
pointsUNIONEXCEPTINTERSECT
a List the records of patients who have tested Negative for both 'Biontech' use testType.name field and 'Moderna' use testType.name field tests using INTERSECT.
b List the records of patients who have tested Positive for either a Turkish testTypeorigintr or German testTypeorigingr vaccine using UNION.
c List the records of patients who have not undergone any tests.
pointsGROUP BYHAVING Group the tests by their origin country testTypeorigin and list the number of tests done for each country found from the test table the total amount paid for these tests testTypeprice and the percentage of tests that are positive and negative, but only for tests with an accuracy testTypeaccuracy over and excluding tr origin countries.
pointsUNIQUE List the records of patients who have not taken the same named test testTypename more than once ie have taken different tests in terms of name using UNIQUE.
points WITHFROM subquery List the hids of the patients who have undergone more tests than the average number of tests per patient. Do this by first calculating the average number of tests per patient in a WITH subquery and then the average of these numbers in another WITH subquery.
points SELECT subquery List the hospital records. But while listing the records, calculate the number of doctors and inpatients in each hospital by adding a subquery each inside SELECT. SELECT subquery numberofdoctors, subquery numberofpatients FROM hospital
pointsHAVING subquery List the hids of hospitals that have at least one ie any doctor specializing in 'internal medicine' specialty'dahiliye' and the total number of doctors working in those hospitals HAVING should be used to check if the hospital employs an internal medicine specialist
pointsVIEWS Create a view named statistics date noOfTests, noOfPositives, noOfDeaths, noOfEntubedstatistics date dailyTestCount, dailyPositiveCount, dailyDeathCount, dailyEntubationCount To create this view, first find the daily positive and negative counts by GROUP BY the date field in the test table. Then find the dailyDeathCount and dailyEntubationCount by GROUP BY the admissionDate field in the admitted table. In the final step, join the results of these two steps based on the date field of the grouping. Since there might be days with only tests or only deathsentubations this join should be a FULL OUTER JOIN.
List the records of patients who have taken tests after the last test of the patient named 'Ali KURT'. In a subquery, return the test dates of Ali KURT. Compare the test dates of the patients with these dates using the SOMEALL operator
NO CHATGPT ANSWER IS ACCEPTED, PLEASE.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started