Upload data.jsonl with huggingface_hub
Browse files- data.jsonl +2 -2
data.jsonl
CHANGED
|
@@ -108,7 +108,6 @@
|
|
| 108 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "I need to find patients who received prescriptions within 7 days after their latest appointment. Show patient_id, first and last name, appointment_time, prescription_date, and medication_name."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Actually, restrict it to prescriptions where dosage contains 'mg'."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Also, sort the results by prescription_date descending and limit to 5."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id\nORDER BY pr.prescription_date DESC\nLIMIT 5"}]}
|
| 109 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Show a list of patients along with their most recent diagnoses, including patient ID, diagnosis description, and the diagnosis date."}, {"role": "assistant", "content": "SELECT d.patient_id, d.description AS diagnosis_description, d.diagnosis_date FROM healthcare.diagnoses d INNER JOIN (SELECT patient_id, MAX(diagnosis_date) AS latest_date FROM healthcare.diagnoses GROUP BY patient_id) latest ON d.patient_id = latest.patient_id AND d.diagnosis_date = latest.latest_date;"}, {"role": "user", "content": "Add the doctor's full name who made each diagnosis to the results."}, {"role": "assistant", "content": "SELECT d.patient_id, doc.first_name || ' ' || doc.last_name AS doctor_full_name, d.description AS diagnosis_description, d.diagnosis_date FROM healthcare.diagnoses d INNER JOIN (SELECT patient_id, MAX(diagnosis_date) AS latest_date FROM healthcare.diagnoses GROUP BY patient_id) latest ON d.patient_id = latest.patient_id AND d.diagnosis_date = latest.latest_date INNER JOIN healthcare.doctors doc ON d.doctor_id = doc.doctor_id;"}, {"role": "user", "content": "Could you also include the diagnosis code in the output?"}, {"role": "assistant", "content": "SELECT d.patient_id, doc.first_name || ' ' || doc.last_name AS doctor_full_name, d.diagnosis_code, d.description AS diagnosis_description, d.diagnosis_date FROM healthcare.diagnoses d INNER JOIN (SELECT patient_id, MAX(diagnosis_date) AS latest_date FROM healthcare.diagnoses GROUP BY patient_id) latest ON d.patient_id = latest.patient_id AND d.diagnosis_date = latest.latest_date INNER JOIN healthcare.doctors doc ON d.doctor_id = doc.doctor_id;"}]}
|
| 110 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "I need a count of appointments per patient that took place between '2024-04-01' and '2024-04-30', showing patient_id, first_name, last_name, and the total number of appointments."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nJOIN healthcare.appointments a ON p.patient_id = a.patient_id\nWHERE a.appointment_time BETWEEN '2024-04-01' AND '2024-04-30'\nGROUP BY p.patient_id, p.first_name, p.last_name;"}, {"role": "user", "content": "Only include patients who had at least 2 appointments in that period."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nJOIN healthcare.appointments a ON p.patient_id = a.patient_id\nWHERE a.appointment_time BETWEEN '2024-04-01' AND '2024-04-30'\nGROUP BY p.patient_id, p.first_name, p.last_name\nHAVING COUNT(a.appointment_id) >= 2;"}]}
|
| 111 |
-
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "Find all medications whose NDC code starts with '0003'. Show the medication ID and NDC code."}, {"role": "assistant", "content": "SELECT medication_id, ndc_code FROM healthcare.medications WHERE ndc_code LIKE '0003%';"}, {"role": "user", "content": "Count the number of medications for each manufacturer and show manufacturers with more than 100 medications."}, {"role": "assistant", "content": "SELECT manufacturer, COUNT(*) AS medication_count FROM healthcare.medications GROUP BY manufacturer HAVING COUNT(*) > 100;"}]}
|
| 112 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, address_line1.text, city.text, state_province.text, postal_code.text, country_code.text, preferences.text, loyalty_member_id.text, communication_consent.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.reviews (\n review_id character varying(64) NOT NULL, -- unique identifier for the review\n property_id character varying(64) NOT NULL, -- FK to properties table\n reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good)\n guest_id character varying(64) NOT NULL, -- FK to guests table\n rating_overall integer, -- overall score (e.g., 1-5 or 1-10)\n rating_cleanliness integer,\n rating_service integer,\n rating_location integer,\n rating_value integer,\n comment text, -- guest's written feedback\n review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com\n review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted\n is_public boolean DEFAULT true, -- whether the review is publicly visible\n staff_response text, -- official response from the property\n response_staff_id character varying(64), -- FK to staff (who responded)\n response_date timestamp with time zone, -- when the response was posted\n PRIMARY KEY (review_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "For each reservation in the last three months, show the reservation ID, check-in date, number of adults, and the corresponding room type name."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.check_in_date, r.num_adults, rt.type_name\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nWHERE r.created_at >= NOW() - INTERVAL '3 months';"}, {"role": "user", "content": "Also include the name of the property for each reservation."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.check_in_date, r.num_adults, rt.type_name, p.property_name\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nWHERE r.created_at >= NOW() - INTERVAL '3 months';"}, {"role": "user", "content": "Sort the results by number of adults descending, and then by check-in date ascending."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.check_in_date, r.num_adults, rt.type_name, p.property_name\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nWHERE r.created_at >= NOW() - INTERVAL '3 months'\nORDER BY r.num_adults DESC, r.check_in_date ASC;"}]}
|
| 113 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, room_number character varying(10) NOT NULL, room_type_id character varying(64) NOT NULL, floor integer, status character varying(50) NOT NULL, is_smoking boolean NOT NULL DEFAULT false, features text, current_condition text, last_cleaned_at timestamp with time zone, PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all services in the 'Concierge' department along with their names, price, and whether they are currently available. Include the property name as well."}, {"role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge';"}, {"role": "user", "content": "Could you filter only those services that are not currently available and sort by price ascending?"}, {"role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge'\n AND s.is_available = false\nORDER BY s.price ASC;"}, {"role": "user", "content": "Instead, show only properties in the city of 'Miami' and add the service category to the results."}, {"role": "assistant", "content": "SELECT s.service_name, s.category, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge'\n AND s.is_available = false\n AND p.city = 'Miami'\nORDER BY s.price ASC;"}]}
|
| 114 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.staff ( staff_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, position character varying(100) NOT NULL, work_email character varying(255) UNIQUE, work_phone character varying(30), hire_date date NOT NULL, termination_date date, is_active boolean NOT NULL DEFAULT true, access_level integer NOT NULL, manager_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (staff_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all staff members, showing their full name, position, and the name of the property where they work."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.position, T2.property_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id;"}, {"role": "user", "content": "Only include staff who are currently active and add their manager's full name if they have one."}, {"role": "assistant", "content": "SELECT T1.first_name AS staff_first_name, T1.last_name AS staff_last_name, T1.position, T2.property_name, T3.first_name AS manager_first_name, T3.last_name AS manager_last_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id LEFT JOIN hospitality_technology.staff AS T3 ON T1.manager_id = T3.staff_id WHERE T1.is_active = TRUE;"}, {"role": "user", "content": "Filter further to only include staff working at properties in the 'California' state and sort by property name, then staff last name."}, {"role": "assistant", "content": "SELECT T1.first_name AS staff_first_name, T1.last_name AS staff_last_name, T1.position, T2.property_name, T3.first_name AS manager_first_name, T3.last_name AS manager_last_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id LEFT JOIN hospitality_technology.staff AS T3 ON T1.manager_id = T3.staff_id WHERE T1.is_active = TRUE AND T2.state_province = 'California' ORDER BY T2.property_name, T1.last_name;"}]}
|
|
@@ -164,6 +163,7 @@
|
|
| 164 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims ( claim_id text, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "I want a list of all claims where at least one document is larger than 2 megabytes. Include the claim ID, incident date, and the file name of such documents."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152;"}, {"role": "user", "content": "Actually, please also show the document type and only include documents uploaded after June 1, 2024."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name, d.document_type\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152\n AND d.uploaded_at > '2024-06-01';"}, {"role": "user", "content": "Add the file size in kilobytes and order the results by file size descending."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name, d.document_type, (d.file_size_bytes/1024) AS file_size_kb\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152\n AND d.uploaded_at > '2024-06-01'\nORDER BY d.file_size_bytes DESC;"}, {"role": "user", "content": "Sorry, I'm getting some records where file_size_bytes is NULL. Please exclude those from the results."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name, d.document_type, (d.file_size_bytes/1024) AS file_size_kb\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152\n AND d.uploaded_at > '2024-06-01'\n AND d.file_size_bytes IS NOT NULL\nORDER BY d.file_size_bytes DESC;"}]}
|
| 165 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id.text, customer_id.text, product_id.text, agent_id.text, policy_number.text, start_date.date, end_date.date, premium_amount.numeric, coverage_limit.numeric, deductible.numeric, status.text, issued_at.timestamp, cancellation_date.date, cancellation_reason.text )\nCREATE TABLE insurance.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text )\nCREATE TABLE insurance.premium_payments ( payment_id.text, policy_id.text, customer_id.text, payment_date.timestamp, amount_paid.numeric, payment_method.text, transaction_reference.text, due_date.date, payment_period_start.date, payment_period_end.date, status.text )\n", "conversations": [{"role": "user", "content": "Show me all active policies with coverage limits above $1,000,000, along with the customer names and agent names, sorted by coverage limit in descending order."}, {"role": "assistant", "content": "SELECT p.policy_id, p.customer_id, p.agent_id, p.coverage_limit, p.premium_amount, p.start_date, p.end_date FROM insurance.policies p WHERE p.status = 'active' AND p.coverage_limit > 1000000 ORDER BY p.coverage_limit DESC;"}, {"role": "user", "content": "Actually, I need to see the customer's first and last name from the customers table and the agent's full name from the agents table as well."}, {"role": "assistant", "content": "SELECT p.policy_id, p.coverage_limit, p.premium_amount, c.first_name AS customer_first_name, c.last_name AS customer_last_name, a.first_name AS agent_first_name, a.last_name AS agent_last_name FROM insurance.policies p JOIN insurance.customers c ON p.customer_id = c.customer_id JOIN insurance.agents a ON p.agent_id = a.agent_id WHERE p.status = 'active' AND p.coverage_limit > 1000000 ORDER BY p.coverage_limit DESC;"}, {"role": "user", "content": "Now I also want to see the total number of claims each of these high-coverage policies has had."}, {"role": "assistant", "content": "SELECT p.policy_id, p.coverage_limit, p.premium_amount, c.first_name AS customer_first_name, c.last_name AS customer_last_name, a.first_name AS agent_first_name, a.last_name AS agent_last_name, COUNT(cl.claim_id) AS total_claims FROM insurance.policies p JOIN insurance.customers c ON p.customer_id = c.customer_id JOIN insurance.agents a ON p.agent_id = a.agent_id LEFT JOIN insurance.claims cl ON p.policy_id = cl.policy_id WHERE p.status = 'active' AND p.coverage_limit > 1000000 GROUP BY p.policy_id, p.coverage_limit, p.premium_amount, c.first_name, c.last_name, a.first_name, a.last_name ORDER BY p.coverage_limit DESC;"}, {"role": "user", "content": "Finally, filter these results to only show policies that have at least one claim and include the average settlement amount for those claims."}, {"role": "assistant", "content": "SELECT p.policy_id, p.coverage_limit, p.premium_amount, c.first_name AS customer_first_name, c.last_name AS customer_last_name, a.first_name AS agent_first_name, a.last_name AS agent_last_name, COUNT(cl.claim_id) AS total_claims, AVG(cl.settlement_amount) AS avg_settlement FROM insurance.policies p JOIN insurance.customers c ON p.customer_id = c.customer_id JOIN insurance.agents a ON p.agent_id = a.agent_id JOIN insurance.claims cl ON p.policy_id = cl.policy_id WHERE p.status = 'active' AND p.coverage_limit > 1000000 GROUP BY p.policy_id, p.coverage_limit, p.premium_amount, c.first_name, c.last_name, a.first_name, a.last_name HAVING COUNT(cl.claim_id) > 0 ORDER BY p.coverage_limit DESC;"}]}
|
| 166 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "Show the top 5 largest documents by file size, including document_id, claim_id, file_name, and file_size_bytes."}, {"role": "assistant", "content": "SELECT document_id,\n claim_id,\n file_name,\n file_size_bytes\nFROM insurance.claim_documents\nORDER BY file_size_bytes DESC\nLIMIT 5;"}]}
|
|
|
|
| 167 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the customer ID, payment ID, payment amount, and payment date for all premium payments with an amount paid over 2000."}, {"role": "assistant", "content": "SELECT customer_id, payment_id, amount_paid, payment_date\nFROM insurance.premium_payments\nWHERE amount_paid > 2000;"}]}
|
| 168 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.policies ( policy_id text PRIMARY KEY, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text PRIMARY KEY, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve the number of open claims each customer has filed. Return customer_id, first_name, last_name, and open_claim_count."}, {"role": "assistant", "content": "SELECT cu.customer_id, cu.first_name, cu.last_name, COUNT(cl.claim_id) AS open_claim_count\nFROM insurance.customers cu\nLEFT JOIN insurance.claims cl ON cu.customer_id = cl.customer_id AND cl.status = 'Open'\nGROUP BY cu.customer_id, cu.first_name, cu.last_name;"}, {"role": "user", "content": "Now include only customers who have at least 3 open claims and order the results by open_claim_count descending."}, {"role": "assistant", "content": "SELECT cu.customer_id, cu.first_name, cu.last_name, COUNT(cl.claim_id) AS open_claim_count\nFROM insurance.customers cu\nJOIN insurance.claims cl ON cu.customer_id = cl.customer_id\nWHERE cl.status = 'Open'\nGROUP BY cu.customer_id, cu.first_name, cu.last_name\nHAVING COUNT(cl.claim_id) >= 3\nORDER BY open_claim_count DESC;"}]}
|
| 169 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\n", "conversations": [{"role": "user", "content": "Show me all policies that have at least two premium payments associated with them, along with the total amount paid for each policy."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nGROUP BY p.policy_id, p.policy_number\nHAVING COUNT(pp.payment_id) >= 2;"}, {"role": "user", "content": "Actually, also include the start_date and status of each policy in the result."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, p.start_date, p.status, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nGROUP BY p.policy_id, p.policy_number, p.start_date, p.status\nHAVING COUNT(pp.payment_id) >= 2;"}, {"role": "user", "content": "Now restrict the result to only policies with status 'active'."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, p.start_date, p.status, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nWHERE p.status = 'active'\nGROUP BY p.policy_id, p.policy_number, p.start_date, p.status\nHAVING COUNT(pp.payment_id) >= 2;"}]}
|
|
@@ -247,4 +247,4 @@
|
|
| 247 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )\nCREATE TABLE healthcare.insurance_plans ( plan_id character varying(64) NOT NULL, plan_name character varying(200) NOT NULL, insurance_provider character varying(100) NOT NULL, plan_type character varying(50), contact_phone character varying(20), website character varying(255), PRIMARY KEY (plan_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Which patients have a primary insurance policy and are subscribed to a plan provided by 'Cigna'? List patient ID, full name, policy number, plan ID, and insurance provider."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna';"}, {"role": "user", "content": "Additionally, only show results where the policy has not expired yet."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna' AND (pi.expiration_date IS NULL OR pi.expiration_date >= CURRENT_DATE);"}]}
|
| 248 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers ( lawyer_id text, first_name text, last_name text, bar_number text, firm_id text, email text, phone text, specialization text, hire_date timestamp, is_partner boolean )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents ( document_id text, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version integer, description text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "I need a list showing the name of each law firm and the full name of every lawyer employed by that firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.firm_id = T2.firm_id;"}]}
|
| 249 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\n", "conversations": [{"role": "user", "content": "Show me all customers (customer_id, first_name, last_name, email) who were born after 1985 (date_of_birth > '1985-12-31') and have an email address ending with '@yahoo.com', along with their city and state information."}, {"role": "assistant", "content": "SELECT customer_id, first_name, last_name, email, city, state FROM financial_services.customers WHERE date_of_birth > '1985-12-31' AND email LIKE '%@yahoo.com';"}]}
|
| 250 |
-
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE
|
|
|
|
| 108 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "I need to find patients who received prescriptions within 7 days after their latest appointment. Show patient_id, first and last name, appointment_time, prescription_date, and medication_name."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Actually, restrict it to prescriptions where dosage contains 'mg'."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Also, sort the results by prescription_date descending and limit to 5."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id\nORDER BY pr.prescription_date DESC\nLIMIT 5"}]}
|
| 109 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Show a list of patients along with their most recent diagnoses, including patient ID, diagnosis description, and the diagnosis date."}, {"role": "assistant", "content": "SELECT d.patient_id, d.description AS diagnosis_description, d.diagnosis_date FROM healthcare.diagnoses d INNER JOIN (SELECT patient_id, MAX(diagnosis_date) AS latest_date FROM healthcare.diagnoses GROUP BY patient_id) latest ON d.patient_id = latest.patient_id AND d.diagnosis_date = latest.latest_date;"}, {"role": "user", "content": "Add the doctor's full name who made each diagnosis to the results."}, {"role": "assistant", "content": "SELECT d.patient_id, doc.first_name || ' ' || doc.last_name AS doctor_full_name, d.description AS diagnosis_description, d.diagnosis_date FROM healthcare.diagnoses d INNER JOIN (SELECT patient_id, MAX(diagnosis_date) AS latest_date FROM healthcare.diagnoses GROUP BY patient_id) latest ON d.patient_id = latest.patient_id AND d.diagnosis_date = latest.latest_date INNER JOIN healthcare.doctors doc ON d.doctor_id = doc.doctor_id;"}, {"role": "user", "content": "Could you also include the diagnosis code in the output?"}, {"role": "assistant", "content": "SELECT d.patient_id, doc.first_name || ' ' || doc.last_name AS doctor_full_name, d.diagnosis_code, d.description AS diagnosis_description, d.diagnosis_date FROM healthcare.diagnoses d INNER JOIN (SELECT patient_id, MAX(diagnosis_date) AS latest_date FROM healthcare.diagnoses GROUP BY patient_id) latest ON d.patient_id = latest.patient_id AND d.diagnosis_date = latest.latest_date INNER JOIN healthcare.doctors doc ON d.doctor_id = doc.doctor_id;"}]}
|
| 110 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "I need a count of appointments per patient that took place between '2024-04-01' and '2024-04-30', showing patient_id, first_name, last_name, and the total number of appointments."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nJOIN healthcare.appointments a ON p.patient_id = a.patient_id\nWHERE a.appointment_time BETWEEN '2024-04-01' AND '2024-04-30'\nGROUP BY p.patient_id, p.first_name, p.last_name;"}, {"role": "user", "content": "Only include patients who had at least 2 appointments in that period."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nJOIN healthcare.appointments a ON p.patient_id = a.patient_id\nWHERE a.appointment_time BETWEEN '2024-04-01' AND '2024-04-30'\nGROUP BY p.patient_id, p.first_name, p.last_name\nHAVING COUNT(a.appointment_id) >= 2;"}]}
|
|
|
|
| 111 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, address_line1.text, city.text, state_province.text, postal_code.text, country_code.text, preferences.text, loyalty_member_id.text, communication_consent.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.reviews (\n review_id character varying(64) NOT NULL, -- unique identifier for the review\n property_id character varying(64) NOT NULL, -- FK to properties table\n reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good)\n guest_id character varying(64) NOT NULL, -- FK to guests table\n rating_overall integer, -- overall score (e.g., 1-5 or 1-10)\n rating_cleanliness integer,\n rating_service integer,\n rating_location integer,\n rating_value integer,\n comment text, -- guest's written feedback\n review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com\n review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted\n is_public boolean DEFAULT true, -- whether the review is publicly visible\n staff_response text, -- official response from the property\n response_staff_id character varying(64), -- FK to staff (who responded)\n response_date timestamp with time zone, -- when the response was posted\n PRIMARY KEY (review_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "For each reservation in the last three months, show the reservation ID, check-in date, number of adults, and the corresponding room type name."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.check_in_date, r.num_adults, rt.type_name\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nWHERE r.created_at >= NOW() - INTERVAL '3 months';"}, {"role": "user", "content": "Also include the name of the property for each reservation."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.check_in_date, r.num_adults, rt.type_name, p.property_name\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nWHERE r.created_at >= NOW() - INTERVAL '3 months';"}, {"role": "user", "content": "Sort the results by number of adults descending, and then by check-in date ascending."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.check_in_date, r.num_adults, rt.type_name, p.property_name\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nWHERE r.created_at >= NOW() - INTERVAL '3 months'\nORDER BY r.num_adults DESC, r.check_in_date ASC;"}]}
|
| 112 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, room_number character varying(10) NOT NULL, room_type_id character varying(64) NOT NULL, floor integer, status character varying(50) NOT NULL, is_smoking boolean NOT NULL DEFAULT false, features text, current_condition text, last_cleaned_at timestamp with time zone, PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all services in the 'Concierge' department along with their names, price, and whether they are currently available. Include the property name as well."}, {"role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge';"}, {"role": "user", "content": "Could you filter only those services that are not currently available and sort by price ascending?"}, {"role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge'\n AND s.is_available = false\nORDER BY s.price ASC;"}, {"role": "user", "content": "Instead, show only properties in the city of 'Miami' and add the service category to the results."}, {"role": "assistant", "content": "SELECT s.service_name, s.category, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge'\n AND s.is_available = false\n AND p.city = 'Miami'\nORDER BY s.price ASC;"}]}
|
| 113 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.staff ( staff_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, position character varying(100) NOT NULL, work_email character varying(255) UNIQUE, work_phone character varying(30), hire_date date NOT NULL, termination_date date, is_active boolean NOT NULL DEFAULT true, access_level integer NOT NULL, manager_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (staff_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all staff members, showing their full name, position, and the name of the property where they work."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.position, T2.property_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id;"}, {"role": "user", "content": "Only include staff who are currently active and add their manager's full name if they have one."}, {"role": "assistant", "content": "SELECT T1.first_name AS staff_first_name, T1.last_name AS staff_last_name, T1.position, T2.property_name, T3.first_name AS manager_first_name, T3.last_name AS manager_last_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id LEFT JOIN hospitality_technology.staff AS T3 ON T1.manager_id = T3.staff_id WHERE T1.is_active = TRUE;"}, {"role": "user", "content": "Filter further to only include staff working at properties in the 'California' state and sort by property name, then staff last name."}, {"role": "assistant", "content": "SELECT T1.first_name AS staff_first_name, T1.last_name AS staff_last_name, T1.position, T2.property_name, T3.first_name AS manager_first_name, T3.last_name AS manager_last_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id LEFT JOIN hospitality_technology.staff AS T3 ON T1.manager_id = T3.staff_id WHERE T1.is_active = TRUE AND T2.state_province = 'California' ORDER BY T2.property_name, T1.last_name;"}]}
|
|
|
|
| 163 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims ( claim_id text, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "I want a list of all claims where at least one document is larger than 2 megabytes. Include the claim ID, incident date, and the file name of such documents."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152;"}, {"role": "user", "content": "Actually, please also show the document type and only include documents uploaded after June 1, 2024."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name, d.document_type\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152\n AND d.uploaded_at > '2024-06-01';"}, {"role": "user", "content": "Add the file size in kilobytes and order the results by file size descending."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name, d.document_type, (d.file_size_bytes/1024) AS file_size_kb\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152\n AND d.uploaded_at > '2024-06-01'\nORDER BY d.file_size_bytes DESC;"}, {"role": "user", "content": "Sorry, I'm getting some records where file_size_bytes is NULL. Please exclude those from the results."}, {"role": "assistant", "content": "SELECT c.claim_id, c.incident_date, d.file_name, d.document_type, (d.file_size_bytes/1024) AS file_size_kb\nFROM insurance.claims c\nJOIN insurance.claim_documents d ON c.claim_id = d.claim_id\nWHERE d.file_size_bytes > 2097152\n AND d.uploaded_at > '2024-06-01'\n AND d.file_size_bytes IS NOT NULL\nORDER BY d.file_size_bytes DESC;"}]}
|
| 164 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id.text, customer_id.text, product_id.text, agent_id.text, policy_number.text, start_date.date, end_date.date, premium_amount.numeric, coverage_limit.numeric, deductible.numeric, status.text, issued_at.timestamp, cancellation_date.date, cancellation_reason.text )\nCREATE TABLE insurance.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text )\nCREATE TABLE insurance.premium_payments ( payment_id.text, policy_id.text, customer_id.text, payment_date.timestamp, amount_paid.numeric, payment_method.text, transaction_reference.text, due_date.date, payment_period_start.date, payment_period_end.date, status.text )\n", "conversations": [{"role": "user", "content": "Show me all active policies with coverage limits above $1,000,000, along with the customer names and agent names, sorted by coverage limit in descending order."}, {"role": "assistant", "content": "SELECT p.policy_id, p.customer_id, p.agent_id, p.coverage_limit, p.premium_amount, p.start_date, p.end_date FROM insurance.policies p WHERE p.status = 'active' AND p.coverage_limit > 1000000 ORDER BY p.coverage_limit DESC;"}, {"role": "user", "content": "Actually, I need to see the customer's first and last name from the customers table and the agent's full name from the agents table as well."}, {"role": "assistant", "content": "SELECT p.policy_id, p.coverage_limit, p.premium_amount, c.first_name AS customer_first_name, c.last_name AS customer_last_name, a.first_name AS agent_first_name, a.last_name AS agent_last_name FROM insurance.policies p JOIN insurance.customers c ON p.customer_id = c.customer_id JOIN insurance.agents a ON p.agent_id = a.agent_id WHERE p.status = 'active' AND p.coverage_limit > 1000000 ORDER BY p.coverage_limit DESC;"}, {"role": "user", "content": "Now I also want to see the total number of claims each of these high-coverage policies has had."}, {"role": "assistant", "content": "SELECT p.policy_id, p.coverage_limit, p.premium_amount, c.first_name AS customer_first_name, c.last_name AS customer_last_name, a.first_name AS agent_first_name, a.last_name AS agent_last_name, COUNT(cl.claim_id) AS total_claims FROM insurance.policies p JOIN insurance.customers c ON p.customer_id = c.customer_id JOIN insurance.agents a ON p.agent_id = a.agent_id LEFT JOIN insurance.claims cl ON p.policy_id = cl.policy_id WHERE p.status = 'active' AND p.coverage_limit > 1000000 GROUP BY p.policy_id, p.coverage_limit, p.premium_amount, c.first_name, c.last_name, a.first_name, a.last_name ORDER BY p.coverage_limit DESC;"}, {"role": "user", "content": "Finally, filter these results to only show policies that have at least one claim and include the average settlement amount for those claims."}, {"role": "assistant", "content": "SELECT p.policy_id, p.coverage_limit, p.premium_amount, c.first_name AS customer_first_name, c.last_name AS customer_last_name, a.first_name AS agent_first_name, a.last_name AS agent_last_name, COUNT(cl.claim_id) AS total_claims, AVG(cl.settlement_amount) AS avg_settlement FROM insurance.policies p JOIN insurance.customers c ON p.customer_id = c.customer_id JOIN insurance.agents a ON p.agent_id = a.agent_id JOIN insurance.claims cl ON p.policy_id = cl.policy_id WHERE p.status = 'active' AND p.coverage_limit > 1000000 GROUP BY p.policy_id, p.coverage_limit, p.premium_amount, c.first_name, c.last_name, a.first_name, a.last_name HAVING COUNT(cl.claim_id) > 0 ORDER BY p.coverage_limit DESC;"}]}
|
| 165 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "Show the top 5 largest documents by file size, including document_id, claim_id, file_name, and file_size_bytes."}, {"role": "assistant", "content": "SELECT document_id,\n claim_id,\n file_name,\n file_size_bytes\nFROM insurance.claim_documents\nORDER BY file_size_bytes DESC\nLIMIT 5;"}]}
|
| 166 |
+
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.policies ( policy_id text PRIMARY KEY, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\nCREATE TABLE insurance.premium_payments ( payment_id text PRIMARY KEY, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\n", "conversations": [{"role": "user", "content": "Show the policy number, start date, and the first and last name of the agent for all policies that started in 2024."}, {"role": "assistant", "content": "SELECT p.policy_number, p.start_date, a.first_name AS agent_first_name, a.last_name AS agent_last_name\nFROM insurance.policies p\nJOIN insurance.agents a ON p.agent_id = a.agent_id\nWHERE p.start_date >= '2024-01-01' AND p.start_date < '2025-01-01';"}, {"role": "user", "content": "Also include the status of each policy and only show those where the policy's premium_amount is over 3000."}, {"role": "assistant", "content": "SELECT p.policy_number, p.start_date, a.first_name AS agent_first_name, a.last_name AS agent_last_name, p.status, p.premium_amount\nFROM insurance.policies p\nJOIN insurance.agents a ON p.agent_id = a.agent_id\nWHERE p.start_date >= '2024-01-01' AND p.start_date < '2025-01-01' AND p.premium_amount > 3000;"}]}
|
| 167 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the customer ID, payment ID, payment amount, and payment date for all premium payments with an amount paid over 2000."}, {"role": "assistant", "content": "SELECT customer_id, payment_id, amount_paid, payment_date\nFROM insurance.premium_payments\nWHERE amount_paid > 2000;"}]}
|
| 168 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.policies ( policy_id text PRIMARY KEY, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text PRIMARY KEY, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve the number of open claims each customer has filed. Return customer_id, first_name, last_name, and open_claim_count."}, {"role": "assistant", "content": "SELECT cu.customer_id, cu.first_name, cu.last_name, COUNT(cl.claim_id) AS open_claim_count\nFROM insurance.customers cu\nLEFT JOIN insurance.claims cl ON cu.customer_id = cl.customer_id AND cl.status = 'Open'\nGROUP BY cu.customer_id, cu.first_name, cu.last_name;"}, {"role": "user", "content": "Now include only customers who have at least 3 open claims and order the results by open_claim_count descending."}, {"role": "assistant", "content": "SELECT cu.customer_id, cu.first_name, cu.last_name, COUNT(cl.claim_id) AS open_claim_count\nFROM insurance.customers cu\nJOIN insurance.claims cl ON cu.customer_id = cl.customer_id\nWHERE cl.status = 'Open'\nGROUP BY cu.customer_id, cu.first_name, cu.last_name\nHAVING COUNT(cl.claim_id) >= 3\nORDER BY open_claim_count DESC;"}]}
|
| 169 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\n", "conversations": [{"role": "user", "content": "Show me all policies that have at least two premium payments associated with them, along with the total amount paid for each policy."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nGROUP BY p.policy_id, p.policy_number\nHAVING COUNT(pp.payment_id) >= 2;"}, {"role": "user", "content": "Actually, also include the start_date and status of each policy in the result."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, p.start_date, p.status, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nGROUP BY p.policy_id, p.policy_number, p.start_date, p.status\nHAVING COUNT(pp.payment_id) >= 2;"}, {"role": "user", "content": "Now restrict the result to only policies with status 'active'."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, p.start_date, p.status, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nWHERE p.status = 'active'\nGROUP BY p.policy_id, p.policy_number, p.start_date, p.status\nHAVING COUNT(pp.payment_id) >= 2;"}]}
|
|
|
|
| 247 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )\nCREATE TABLE healthcare.insurance_plans ( plan_id character varying(64) NOT NULL, plan_name character varying(200) NOT NULL, insurance_provider character varying(100) NOT NULL, plan_type character varying(50), contact_phone character varying(20), website character varying(255), PRIMARY KEY (plan_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Which patients have a primary insurance policy and are subscribed to a plan provided by 'Cigna'? List patient ID, full name, policy number, plan ID, and insurance provider."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna';"}, {"role": "user", "content": "Additionally, only show results where the policy has not expired yet."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna' AND (pi.expiration_date IS NULL OR pi.expiration_date >= CURRENT_DATE);"}]}
|
| 248 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers ( lawyer_id text, first_name text, last_name text, bar_number text, firm_id text, email text, phone text, specialization text, hire_date timestamp, is_partner boolean )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents ( document_id text, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version integer, description text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "I need a list showing the name of each law firm and the full name of every lawyer employed by that firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.firm_id = T2.firm_id;"}]}
|
| 249 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\n", "conversations": [{"role": "user", "content": "Show me all customers (customer_id, first_name, last_name, email) who were born after 1985 (date_of_birth > '1985-12-31') and have an email address ending with '@yahoo.com', along with their city and state information."}, {"role": "assistant", "content": "SELECT customer_id, first_name, last_name, email, city, state FROM financial_services.customers WHERE date_of_birth > '1985-12-31' AND email LIKE '%@yahoo.com';"}]}
|
| 250 |
+
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Can you list all billable and non-billable entry pairs for the same lawyer on the same date?"}, {"role": "assistant", "content": "SELECT b.lawyer_id,\n b.date_worked,\n b.entry_id AS billable_entry,\n n.entry_id AS non_billable_entry,\n b.description AS billable_desc,\n n.description AS non_billable_desc\nFROM legal_services.time_entries b\nJOIN legal_services.time_entries n\n ON b.lawyer_id = n.lawyer_id\n AND b.date_worked = n.date_worked\nWHERE b.is_billable = TRUE\n AND n.is_billable = FALSE;"}, {"role": "user", "content": "Actually, only include pairs where the creation times differ by less than 6 hours."}, {"role": "assistant", "content": "SELECT b.lawyer_id,\n b.date_worked,\n b.entry_id AS billable_entry,\n n.entry_id AS non_billable_entry,\n b.description AS billable_desc,\n n.description AS non_billable_desc\nFROM legal_services.time_entries b\nJOIN legal_services.time_entries n\n ON b.lawyer_id = n.lawyer_id\n AND b.date_worked = n.date_worked\n AND ABS(b.created_at - n.created_at) < INTERVAL '6 hours'\nWHERE b.is_billable = TRUE\n AND n.is_billable = FALSE;"}]}
|