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 60 years old who had appointments between January 1,2023, and December 31,2023, with a focus on frequent visitors.
1. Display Name, Age, Gender, DoctorName, AppointmentDate, and Department for patients over 60 years old.
2. Include only appointments that occurred in the year 2023.
3. 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(100)
Age INT
Gender VARCHAR(10)
Address VARCHAR(255)
Appointments
columnName dataType
AppointmentID INT
PatientID INT
DoctorName VARCHAR(100)
AppointmentDate DATE
Department VARCHAR(50)
FOREIGN KEY (PatientID) undefined

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!