Write SQL queries to retrieve the requested information from the Drug Test database
(a) Find the names and ids of all patients who are afflicted with both depression and asthma.
(b) Find the names and ids of all patients who were completely cured by the end of their drug trial (as indicated by all post-treatment severity levels being 0).
Solutions:
here SQL tables are as follows :
1) Patient Table
2) Disease Table
3) Drug Table
a) Find the names and ids of all patients who are afflicted with both depression and asthma.
Query :
SELECT DISTINCT patient.patientName, patient.patientId
FROM patient INNER JOIN Disease
ON patient.patientId = Disease.PatientId AND Disease.DiseaseName IN
('depression' ,'asthma')
Result :
B) Find the names and ids of all patients who were completely cured by the end of their drug trial
Query :
SELECT DISTINCT patient.patientName, patient.patientId
FROM patient INNER JOIN Drug
ON patient.patientId = Drug.PatientId AND Drug.duration = 0
Result :
Write SQL queries to retrieve the requested information from the Drug Test database (a) Find the names and ids of all patients who are afflicted with both depression and asthma. (b) Find the names an...
QUESTION: (Answer in SQL) Write an SQL query to find all pairs of users (A,B) such that both A and B have blurted on a common topic but A is not following B. Your query should print the names of A and B in that order. BACKGROUND INFO: Users can post their thoughts in form of short messages that we call “blurts”. When signing up, users need to provide their email and a password of their choice. In addition, they...