Question: You are tasked with writing a SQL query for a hospital's database system to help analyze the appointment patterns of senior patients. The hospital's system
You are tasked with writing a SQL query for a hospital's database system to help analyze the appointment patterns of senior patients. The hospital's system maintains two databases: Patients and Appointments. The Patients database holds information about each patient, including PatientID, Name, Age, Gender, and Address. The Appointments database records all appointments, with fields like AppointmentID, PatientID, DoctorName, AppointmentDate, and Department. Your objective is to generate a report listing the appointment details of patients over years old who had appointments between January and December with a focus on frequent visitors.
Display Name, Age, Gender, DoctorName, AppointmentDate, and Department for patients over years old.
Include only appointments that occurred in the year
Sort the results by Age in descending order, and then by AppointmentDate in ascending order.
Tables Schema as Below:
Patients
columnName dataType
PatientID INT
Name VARCHAR
Age INT
Gender VARCHAR
Address VARCHAR
Appointments
columnName dataType
AppointmentID INT
PatientID INT
DoctorName VARCHAR
AppointmentDate DATE
Department VARCHAR
FOREIGN KEY PatientID undefined
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
