This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT e.Symptoms | |
| FROM Examination e | |
| JOIN Patient p ON e.ID = p.ID | |
| WHERE p.Admission = '+' | |
| AND STRFTIME('%Y', e.`Examination Date`) BETWEEN '1995' AND '1999' | |
| AND e.Thrombosis = '2' | |
| AND e.`ANA Pattern` = 'S' | |
| AND e.`aCL IgM` < (SELECT AVG(`aCL IgM`) + AVG(`aCL IgM`) * 1 FROM Examination); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH threshold AS ( | |
| SELECT AVG("aCL IgM") AS avg_igm | |
| FROM Examination | |
| WHERE "aCL IgM" IS NOT NULL | |
| ) | |
| SELECT DISTINCT e.Symptoms | |
| FROM Examination e | |
| JOIN Patient p ON p.ID = e.ID | |
| CROSS JOIN threshold t | |
| WHERE p.Admission = '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH fall_semester_events AS ( | |
| -- Identify fall semester events (Sep-Nov 2019, the only/most recent fall semester in the DB) | |
| SELECT event_id, event_name, event_date | |
| FROM Event | |
| WHERE strftime('%m', event_date) BETWEEN '09' AND '11' | |
| AND strftime('%Y', event_date) = '2019' | |
| ), | |
| -- Part 1: Advertisement budget ratio | |
| adv_budgets AS ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH budget_comparison AS ( | |
| SELECT | |
| e.event_name, | |
| b.amount as advertisement_budget | |
| FROM Event e | |
| JOIN Budget b ON e.event_id = b.link_to_event | |
| WHERE e.event_name IN ('Yearly Kickoff', 'October Meeting') | |
| AND b.category = 'Advertisement' | |
| AND e.event_date >= '2019-08-01' AND e.event_date <= '2019-12-31' | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH fall_semester AS ( | |
| -- Identify the most recent fall semester events (Yearly Kickoff and October Meeting) | |
| SELECT e.event_id, e.event_name, e.event_date | |
| FROM Event e | |
| WHERE e.event_name IN ('Yearly Kickoff', 'October Meeting') | |
| AND strftime('%Y', e.event_date) = ( | |
| SELECT MAX(strftime('%Y', e2.event_date)) | |
| FROM Event e2 | |
| WHERE e2.event_name = 'October Meeting' | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH budget_comparison AS ( | |
| SELECT | |
| e.event_name, | |
| b.amount, | |
| CASE WHEN e.event_name = 'Yearly Kickoff' THEN b.amount END as kickoff_budget, | |
| CASE WHEN e.event_name = 'October Meeting' THEN b.amount END as october_budget | |
| FROM Event e | |
| JOIN Budget b ON e.event_id = b.link_to_event | |
| WHERE e.event_name IN ('Yearly Kickoff', 'October Meeting') | |
| AND b.category = 'Advertisement' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH fall_year AS ( | |
| SELECT MAX(CAST(strftime('%Y', event_date) AS INT)) AS yr | |
| FROM Event | |
| WHERE CAST(strftime('%m', event_date) AS INT) BETWEEN 8 AND 12 | |
| ), | |
| kickoff_ad AS ( | |
| SELECT b.amount AS kickoff_ad | |
| FROM Budget b | |
| JOIN Event e ON b.link_to_event = e.event_id | |
| JOIN fall_year fy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH fall_year AS ( | |
| SELECT MAX(CAST(strftime('%Y', event_date) AS INTEGER)) AS yr | |
| FROM Event | |
| WHERE CAST(strftime('%m', event_date) AS INTEGER) BETWEEN 9 AND 12 | |
| ), | |
| ads AS ( | |
| SELECT e.event_name, b.amount | |
| FROM Budget b | |
| JOIN Event e ON b.link_to_event = e.event_id | |
| JOIN fall_year fy ON CAST(strftime('%Y', e.event_date) AS INTEGER)=fy.yr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT E.Symptoms | |
| FROM Examination E | |
| INNER JOIN Patient P ON E.ID = P.ID | |
| WHERE E.Thrombosis = '2' | |
| AND E.`ANA Pattern` = 'S' | |
| AND strftime('%Y', E.`Examination Date`) BETWEEN '1995' AND '1999' | |
| AND E.`aCL IgM` < ( | |
| SELECT AVG(`aCL IgM`) + AVG(`aCL IgM`) * 1 | |
| FROM Examination | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH threshold_calc AS ( | |
| SELECT AVG("aCL IgM") + AVG("aCL IgM") * 0.2 as acl_igm_threshold | |
| FROM Examination | |
| WHERE "aCL IgM" IS NOT NULL | |
| ), | |
| core_patients AS ( | |
| SELECT DISTINCT ID | |
| FROM Examination | |
| ) | |
| SELECT DISTINCT e.Symptoms |
NewerOlder