CREATE TABLE Affiliated_With (Physician INT, Department INT, PrimaryAffiliation BOOLEAN)
CREATE TABLE Undergoes (Patient INT, Procedures INT, Stay INT, DateUndergoes DATETIME, Physician INT, AssistingNurse INT)
CREATE TABLE Prescribes (Physician INT, Patient INT, Medication INT, Date DATETIME, Appointment INT, Dose VARCHAR)
CREATE TABLE Medication (Code INT, Name VARCHAR, Brand VARCHAR, Description VARCHAR)
CREATE TABLE Appointment (AppointmentID INT, Patient INT, PrepNurse INT, Physician INT, Start DATETIME, End DATETIME, ExaminationRoom TEXT)
CREATE TABLE Stay (StayID INT, Patient INT, Room INT, StayStart DATETIME, StayEnd DATETIME)
CREATE TABLE On_Call (Nurse INT, BlockFloor INT, BlockCode INT, OnCallStart DATETIME, OnCallEnd DATETIME)
CREATE TABLE Department (DepartmentID INT, Name VARCHAR, Head INT)
CREATE TABLE Nurse (EmployeeID INT, Name VARCHAR, Position VARCHAR, Registered BOOLEAN, SSN INT)
CREATE TABLE Physician (EmployeeID INT, Name VARCHAR, Position VARCHAR, SSN INT)
CREATE TABLE Patient (SSN INT, Name VARCHAR, Address VARCHAR, Phone VARCHAR, InsuranceID INT, PCP INT)
CREATE TABLE Room (RoomNumber INT, RoomType VARCHAR, BlockFloor INT, BlockCode INT, Unavailable BOOLEAN)
CREATE TABLE Block (BlockFloor INT, BlockCode INT)
CREATE TABLE Procedures (Code INT, Name VARCHAR, Cost FLOAT)
CREATE TABLE Trained_In (Physician INT, Treatment INT, CertificationDate DATETIME, CertificationExpires DATETIME)

Which physicians are trained in procedures that are more expensive than 5000, and count them by a pie chart
SELECT T1.Name, COUNT(T1.Name) FROM Physician AS T1 JOIN Trained_In AS T2 ON T1.EmployeeID = T2.Physician JOIN Procedures AS T3 ON T3.Code = T2.Treatment WHERE T3.Cost > 5000 GROUP BY T1.Name
SELECT "T1"."Name", COUNT("T1"."Name") FROM "Physician" AS "T1" JOIN "Trained_In" AS "T2" ON "T1"."EmployeeID" = "T2"."Physician" JOIN "Procedures" AS "T3" ON "T2"."Treatment" = "T3"."Code" AND "T3"."Cost" > 5000 GROUP BY "T1"."Name"