You have been provided with 3 tables doctors, specialty, and operations. The doctors…
- User
You have been provided with 3 tables doctors, specialty, and operations. The doctors table maintains the details like the ID, name, and gender of the doctors. The specialty table maintains details like specialty IDs and names. The operations table holds stats of the operations that were performed in 2024, 2023, and 2022 Task Write an SQL query to fetch the names, specialty, and the average of operations performed in 2024, 2023, and 2022 by the doctors whose operation average for the years 2024, 2023, and 2022 is lesser than their specialty's cumulative operation average for the years 2024, 2023, and 2022. Sort the output in decreasing order of the doctor's individual operation average for the years 2024,2023, and 2022, and in alphabetical order of the doctor's name. Note: The mathematical formula to calculate the average of 'n' no. of entries = sum of 'n' no.of entries/count of 'n' entries. Table description Input format Table: doctors
Field id first_name last_name gender
Type Integer Represents the unique ID of the doctor String String String
Description
Represents the first name of the doctor Represents the last name of the doctor Represents the gender of the doctor
Table: specialty Field id name
Type integer string
Description Represents the unique ID of the specialty Represents the name of the specialty
Table: operations Field ops_in_2024 ops_in_2023 ops_in_2022 doctor_id specialty_id
Type Integer Integer Integer Integer Integer
description Represents the count of operations in 2024 Represents the count of operations in 2023 Represents the count of operations in 2022 Represents the unique ID of the doctor.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.