Winboy commited on
Commit
30e8b1a
·
verified ·
1 Parent(s): 54d4d15

Upload data.jsonl with huggingface_hub

Browse files
Files changed (1) hide show
  1. data.jsonl +2 -2
data.jsonl CHANGED
@@ -162,7 +162,6 @@
162
  {"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 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.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 )\n", "conversations": [{"role": "user", "content": "List all agents who have sold at least one policy for an insurance product of type 'Health'. For each agent, show their full name, agency name, and the product name."}, {"role": "assistant", "content": "SELECT DISTINCT a.first_name || ' ' || a.last_name AS agent_full_name, a.agency_name, ip.product_name\nFROM insurance.agents a\nJOIN insurance.policies p ON a.agent_id = p.agent_id\nJOIN insurance.insurance_products ip ON p.product_id = ip.product_id\nWHERE ip.product_type = 'Health';"}]}
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.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.insurance_products ( product_id text, 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 )\n", "conversations": [{"role": "user", "content": "List the product_id, product_name, and base_premium for all products that are currently inactive."}, {"role": "assistant", "content": "SELECT product_id, product_name, base_premium\nFROM insurance.insurance_products\nWHERE is_active = false;"}]}
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.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;"}]}
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.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;"}]}
@@ -189,6 +188,7 @@
189
  {"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.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\n", "conversations": [{"role": "user", "content": "Find guests who ordered the same service more than once on the same reservation and date. Return guest_id, reservation_id, service_id, and the date."}, {"role": "assistant", "content": "SELECT so1.guest_id,\n so1.reservation_id,\n so1.service_id,\n DATE(so1.order_timestamp) AS order_date\nFROM hospitality_technology.service_orders so1\nJOIN hospitality_technology.service_orders so2\n ON so1.guest_id = so2.guest_id\n AND so1.reservation_id = so2.reservation_id\n AND so1.service_id = so2.service_id\n AND DATE(so1.order_timestamp) = DATE(so2.order_timestamp)\n AND so1.order_id < so2.order_id\nGROUP BY so1.guest_id, so1.reservation_id, so1.service_id, DATE(so1.order_timestamp);"}, {"role": "user", "content": "Actually, consider only orders where status = 'Delivered'."}, {"role": "assistant", "content": "SELECT so1.guest_id,\n so1.reservation_id,\n so1.service_id,\n DATE(so1.order_timestamp) AS order_date\nFROM hospitality_technology.service_orders so1\nJOIN hospitality_technology.service_orders so2\n ON so1.guest_id = so2.guest_id\n AND so1.reservation_id = so2.reservation_id\n AND so1.service_id = so2.service_id\n AND DATE(so1.order_timestamp) = DATE(so2.order_timestamp)\n AND so1.order_id < so2.order_id\nWHERE so1.status = 'Delivered'\n AND so2.status = 'Delivered'\nGROUP BY so1.guest_id, so1.reservation_id, so1.service_id, DATE(so1.order_timestamp);"}, {"role": "user", "content": "Also, count how many times each service was reordered per date and sort by that count descending."}, {"role": "assistant", "content": "SELECT so1.guest_id,\n so1.reservation_id,\n so1.service_id,\n DATE(so1.order_timestamp) AS order_date,\n COUNT(*) AS reorder_count\nFROM hospitality_technology.service_orders so1\nJOIN hospitality_technology.service_orders so2\n ON so1.guest_id = so2.guest_id\n AND so1.reservation_id = so2.reservation_id\n AND so1.service_id = so2.service_id\n AND DATE(so1.order_timestamp) = DATE(so2.order_timestamp)\n AND so1.order_id < so2.order_id\nWHERE so1.status = 'Delivered'\n AND so2.status = 'Delivered'\nGROUP BY so1.guest_id, so1.reservation_id, so1.service_id, DATE(so1.order_timestamp)\nORDER BY reorder_count DESC;"}]}
190
  {"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.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp )\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.payments ( payment_id.text, reservation_id.text, guest_id.text, bill_id.text, amount.numeric, currency_code.text, payment_method.text, card_type.text, card_last_four.text, transaction_ref.text, payment_timestamp.timestamp, status.text, staff_id_processed.text, notes.text )\nCREATE TABLE hospitality_technology.reviews ( review_id text PRIMARY KEY, property_id text, reservation_id text, guest_id text, rating_overall int, rating_cleanliness int, rating_service int, rating_location int, rating_value int, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "Show all public reviews that have a comment."}, {"role": "assistant", "content": "SELECT review_id, property_id, guest_id, rating_overall, comment FROM reviews WHERE is_public = TRUE AND comment IS NOT NULL AND comment != '';"}, {"role": "user", "content": "From those, only show reviews with an overall rating of 5."}, {"role": "assistant", "content": "SELECT review_id, property_id, guest_id, rating_overall, comment FROM reviews WHERE is_public = TRUE AND comment IS NOT NULL AND comment != '' AND rating_overall = 5;"}]}
191
  {"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 government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.agencies ( agency_id.text, agency_name.text, jurisdiction_level.text, primary_contact_email.text, main_phone_number.text, website_url.text, established_date.date, parent_agency_id.text )\nCREATE TABLE government_services.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text )\nCREATE TABLE government_services.applications ( application_id.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text )\nCREATE TABLE government_services.payments ( payment_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, service_id character varying(64), amount numeric(12, 2) NOT NULL, currency character varying(3) NOT NULL DEFAULT 'USD', payment_method character varying(50), payment_provider_reference character varying(128), payment_timestamp timestamp NOT NULL, status character varying(30) NOT NULL, notes text, PRIMARY KEY (payment_id) )\nCREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n employee_id character varying(64), -- FK to employees table (optional, if assigned)\n location_id character varying(64), -- FK to service_locations table (if physical)\n service_id character varying(64), -- FK to services table (optional, if related to specific service)\n scheduled_start_time timestamp NOT NULL,\n scheduled_end_time timestamp,\n purpose text NOT NULL, -- reason for the appointment\n status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show\n booking_method character varying(50), -- e.g., Online, Phone, In-Person\n created_at timestamp NOT NULL, -- when the appointment was booked\n notes text,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE government_services.notifications ( notification_id text PRIMARY KEY, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "List the appointment IDs and statuses for all appointments scheduled at locations in the city of 'San Francisco'."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.status\nFROM government_services.appointments a\nJOIN government_services.service_locations l ON a.location_id = l.location_id\nWHERE l.city = 'San Francisco';"}]}
 
192
  {"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 government_services.citizens (\n citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen\n national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n date_of_birth date NOT NULL,\n gender character varying(20),\n primary_address text NOT NULL, -- full primary residential address\n contact_email character varying(128) UNIQUE,\n contact_phone character varying(32),\n registration_date timestamp NOT NULL, -- when the citizen profile was created\n is_verified boolean DEFAULT false, -- whether identity has been officially verified\n PRIMARY KEY (citizen_id)\n)\nCREATE TABLE government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\nCREATE TABLE government_services.applications (\n application_id character varying(64) NOT NULL, -- unique identifier for the application\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n service_id character varying(64) NOT NULL, -- FK to services table\n submitted_at timestamp NOT NULL, -- time the application was submitted\n status character varying(50) NOT NULL, -- e.g., Submitted, Processing, Approved, Rejected, Pending Info\n last_updated_at timestamp NOT NULL, -- time the status or details last changed\n assigned_employee_id character varying(64), -- FK to employees table (optional)\n decision_date date, -- date when a final decision was made\n notes text, -- internal notes or citizen-provided comments\n reference_number character varying(100) UNIQUE, -- publicly visible reference number\n PRIMARY KEY (application_id)\n)\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "How many total documents are recorded in the system?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM government_services.documents;"}, {"role": "user", "content": "Show me the count of documents for each verification_status."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents GROUP BY verification_status;"}, {"role": "user", "content": "Exclude any documents where the verification_status is 'Pending' or 'Rejected'."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents WHERE verification_status NOT IN ('Pending', 'Rejected') GROUP BY verification_status;"}, {"role": "user", "content": "And order the results by the count in descending order."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents WHERE verification_status NOT IN ('Pending', 'Rejected') GROUP BY verification_status ORDER BY COUNT(*) DESC;"}]}
193
  {"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 government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\n", "conversations": [{"role": "user", "content": "List all agencies that do not have a website URL specified. Return their agency_id, agency_name, and main_phone_number."}, {"role": "assistant", "content": "SELECT agency_id, agency_name, main_phone_number FROM government_services.agencies WHERE website_url IS NULL OR website_url = '';"}]}
194
  {"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 government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\nCREATE TABLE government_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n employee_id character varying(64), -- FK to employees table (optional, if assigned)\n location_id character varying(64), -- FK to service_locations table (if physical)\n service_id character varying(64), -- FK to services table (optional, if related to specific service)\n scheduled_start_time timestamp NOT NULL,\n scheduled_end_time timestamp,\n purpose text NOT NULL, -- reason for the appointment\n status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show\n booking_method character varying(50), -- e.g., Online, Phone, In-Person\n created_at timestamp NOT NULL, -- when the appointment was booked\n notes text,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE government_services.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n application_id character varying(64), -- FK to applications table (optional)\n message_subject character varying(255),\n message_body text NOT NULL,\n channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail\n sent_at timestamp NOT NULL,\n status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read\n related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request\n related_entity_id character varying(64), -- ID of the related entity\n PRIMARY KEY (notification_id)\n)\n", "conversations": [{"role": "user", "content": "List the full names and job titles of all employees who have not verified any documents."}, {"role": "assistant", "content": "SELECT e.first_name, e.last_name, e.job_title FROM government_services.employees AS e LEFT JOIN government_services.documents AS d ON e.employee_id = d.verified_by_employee_id WHERE d.document_id IS NULL;"}]}
@@ -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 healthcare.patients (\n patient_id character varying(64) NOT NULL, -- unique identifier for the patient\n first_name character varying(100) NOT NULL, -- patient's first name\n last_name character varying(100) NOT NULL, -- patient's last name\n date_of_birth date NOT NULL, -- patient's date of birth\n gender character varying(10), -- patient's gender (e.g., Male, Female, Other)\n address text, -- patient's home address\n phone_number character varying(20), -- patient's phone number\n email character varying(128) UNIQUE, -- patient's email address\n emergency_contact_name character varying(200), -- name of emergency contact\n emergency_contact_phone character varying(20), -- phone number of emergency contact\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (patient_id)\n)\nCREATE TABLE healthcare.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table\n appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment\n duration_minutes integer NOT NULL, -- expected duration in minutes\n reason text, -- reason for the visit\n status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show\n location_id character varying(64), -- FK to a potential locations/clinics table\n notes text, -- notes related to scheduling\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE healthcare.medical_records (\n record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)\n record_date timestamp with time zone NOT NULL, -- date the record/observation was made\n chief_complaint text, -- patient's primary reason for visit\n present_illness_history text, -- detailed history of the current issue\n past_medical_history text, -- relevant past conditions/surgeries\n physical_examination_notes text, -- findings from the physical exam\n assessment text, -- doctor's assessment/diagnosis summary\n treatment_plan text, -- planned course of action\n vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (record_id)\n)\n", "conversations": [{"role": "user", "content": "List each patient's first and last name along with their total number of appointments in 2024."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nLEFT JOIN healthcare.appointments a\n ON p.patient_id = a.patient_id\n AND a.appointment_time BETWEEN '2024-01-01' AND '2024-12-31'\nGROUP BY p.first_name, p.last_name;"}, {"role": "user", "content": "Now exclude all 'Cancelled' appointments from the count."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nLEFT JOIN healthcare.appointments a\n ON p.patient_id = a.patient_id\n AND a.appointment_time BETWEEN '2024-01-01' AND '2024-12-31'\n AND a.status <> 'Cancelled'\nGROUP BY p.first_name, p.last_name;"}, {"role": "user", "content": "Also, only show patients who have more than 2 appointments and sort the result by appointment_count in descending order."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nLEFT JOIN healthcare.appointments a\n ON p.patient_id = a.patient_id\n AND a.appointment_time BETWEEN '2024-01-01' AND '2024-12-31'\n AND a.status <> 'Cancelled'\nGROUP BY p.first_name, p.last_name\nHAVING COUNT(a.appointment_id) > 2\nORDER BY appointment_count DESC;"}]}
 
162
  {"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 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.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 )\n", "conversations": [{"role": "user", "content": "List all agents who have sold at least one policy for an insurance product of type 'Health'. For each agent, show their full name, agency name, and the product name."}, {"role": "assistant", "content": "SELECT DISTINCT a.first_name || ' ' || a.last_name AS agent_full_name, a.agency_name, ip.product_name\nFROM insurance.agents a\nJOIN insurance.policies p ON a.agent_id = p.agent_id\nJOIN insurance.insurance_products ip ON p.product_id = ip.product_id\nWHERE ip.product_type = 'Health';"}]}
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.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.insurance_products ( product_id text, 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 )\n", "conversations": [{"role": "user", "content": "List the product_id, product_name, and base_premium for all products that are currently inactive."}, {"role": "assistant", "content": "SELECT product_id, product_name, base_premium\nFROM insurance.insurance_products\nWHERE is_active = false;"}]}
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.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;"}]}
 
188
  {"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.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\n", "conversations": [{"role": "user", "content": "Find guests who ordered the same service more than once on the same reservation and date. Return guest_id, reservation_id, service_id, and the date."}, {"role": "assistant", "content": "SELECT so1.guest_id,\n so1.reservation_id,\n so1.service_id,\n DATE(so1.order_timestamp) AS order_date\nFROM hospitality_technology.service_orders so1\nJOIN hospitality_technology.service_orders so2\n ON so1.guest_id = so2.guest_id\n AND so1.reservation_id = so2.reservation_id\n AND so1.service_id = so2.service_id\n AND DATE(so1.order_timestamp) = DATE(so2.order_timestamp)\n AND so1.order_id < so2.order_id\nGROUP BY so1.guest_id, so1.reservation_id, so1.service_id, DATE(so1.order_timestamp);"}, {"role": "user", "content": "Actually, consider only orders where status = 'Delivered'."}, {"role": "assistant", "content": "SELECT so1.guest_id,\n so1.reservation_id,\n so1.service_id,\n DATE(so1.order_timestamp) AS order_date\nFROM hospitality_technology.service_orders so1\nJOIN hospitality_technology.service_orders so2\n ON so1.guest_id = so2.guest_id\n AND so1.reservation_id = so2.reservation_id\n AND so1.service_id = so2.service_id\n AND DATE(so1.order_timestamp) = DATE(so2.order_timestamp)\n AND so1.order_id < so2.order_id\nWHERE so1.status = 'Delivered'\n AND so2.status = 'Delivered'\nGROUP BY so1.guest_id, so1.reservation_id, so1.service_id, DATE(so1.order_timestamp);"}, {"role": "user", "content": "Also, count how many times each service was reordered per date and sort by that count descending."}, {"role": "assistant", "content": "SELECT so1.guest_id,\n so1.reservation_id,\n so1.service_id,\n DATE(so1.order_timestamp) AS order_date,\n COUNT(*) AS reorder_count\nFROM hospitality_technology.service_orders so1\nJOIN hospitality_technology.service_orders so2\n ON so1.guest_id = so2.guest_id\n AND so1.reservation_id = so2.reservation_id\n AND so1.service_id = so2.service_id\n AND DATE(so1.order_timestamp) = DATE(so2.order_timestamp)\n AND so1.order_id < so2.order_id\nWHERE so1.status = 'Delivered'\n AND so2.status = 'Delivered'\nGROUP BY so1.guest_id, so1.reservation_id, so1.service_id, DATE(so1.order_timestamp)\nORDER BY reorder_count DESC;"}]}
189
  {"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.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp )\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.payments ( payment_id.text, reservation_id.text, guest_id.text, bill_id.text, amount.numeric, currency_code.text, payment_method.text, card_type.text, card_last_four.text, transaction_ref.text, payment_timestamp.timestamp, status.text, staff_id_processed.text, notes.text )\nCREATE TABLE hospitality_technology.reviews ( review_id text PRIMARY KEY, property_id text, reservation_id text, guest_id text, rating_overall int, rating_cleanliness int, rating_service int, rating_location int, rating_value int, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "Show all public reviews that have a comment."}, {"role": "assistant", "content": "SELECT review_id, property_id, guest_id, rating_overall, comment FROM reviews WHERE is_public = TRUE AND comment IS NOT NULL AND comment != '';"}, {"role": "user", "content": "From those, only show reviews with an overall rating of 5."}, {"role": "assistant", "content": "SELECT review_id, property_id, guest_id, rating_overall, comment FROM reviews WHERE is_public = TRUE AND comment IS NOT NULL AND comment != '' AND rating_overall = 5;"}]}
190
  {"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 government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.agencies ( agency_id.text, agency_name.text, jurisdiction_level.text, primary_contact_email.text, main_phone_number.text, website_url.text, established_date.date, parent_agency_id.text )\nCREATE TABLE government_services.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text )\nCREATE TABLE government_services.applications ( application_id.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text )\nCREATE TABLE government_services.payments ( payment_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, service_id character varying(64), amount numeric(12, 2) NOT NULL, currency character varying(3) NOT NULL DEFAULT 'USD', payment_method character varying(50), payment_provider_reference character varying(128), payment_timestamp timestamp NOT NULL, status character varying(30) NOT NULL, notes text, PRIMARY KEY (payment_id) )\nCREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n employee_id character varying(64), -- FK to employees table (optional, if assigned)\n location_id character varying(64), -- FK to service_locations table (if physical)\n service_id character varying(64), -- FK to services table (optional, if related to specific service)\n scheduled_start_time timestamp NOT NULL,\n scheduled_end_time timestamp,\n purpose text NOT NULL, -- reason for the appointment\n status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show\n booking_method character varying(50), -- e.g., Online, Phone, In-Person\n created_at timestamp NOT NULL, -- when the appointment was booked\n notes text,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE government_services.notifications ( notification_id text PRIMARY KEY, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "List the appointment IDs and statuses for all appointments scheduled at locations in the city of 'San Francisco'."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.status\nFROM government_services.appointments a\nJOIN government_services.service_locations l ON a.location_id = l.location_id\nWHERE l.city = 'San Francisco';"}]}
191
+ {"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 government_services.citizens ( citizen_id text, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.services ( service_id text PRIMARY KEY, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days int, is_active boolean, online_application_url text )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\nCREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "Show the application ID, payment amount, and payment method for all payments that have a status of 'Completed' and are related to services in the 'Licensing' category."}, {"role": "assistant", "content": "SELECT p.application_id, p.amount, p.payment_method\nFROM government_services.payments p\nJOIN government_services.services s ON p.service_id = s.service_id\nWHERE p.status = 'Completed' AND s.category = 'Licensing';"}]}
192
  {"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 government_services.citizens (\n citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen\n national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n date_of_birth date NOT NULL,\n gender character varying(20),\n primary_address text NOT NULL, -- full primary residential address\n contact_email character varying(128) UNIQUE,\n contact_phone character varying(32),\n registration_date timestamp NOT NULL, -- when the citizen profile was created\n is_verified boolean DEFAULT false, -- whether identity has been officially verified\n PRIMARY KEY (citizen_id)\n)\nCREATE TABLE government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\nCREATE TABLE government_services.applications (\n application_id character varying(64) NOT NULL, -- unique identifier for the application\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n service_id character varying(64) NOT NULL, -- FK to services table\n submitted_at timestamp NOT NULL, -- time the application was submitted\n status character varying(50) NOT NULL, -- e.g., Submitted, Processing, Approved, Rejected, Pending Info\n last_updated_at timestamp NOT NULL, -- time the status or details last changed\n assigned_employee_id character varying(64), -- FK to employees table (optional)\n decision_date date, -- date when a final decision was made\n notes text, -- internal notes or citizen-provided comments\n reference_number character varying(100) UNIQUE, -- publicly visible reference number\n PRIMARY KEY (application_id)\n)\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "How many total documents are recorded in the system?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM government_services.documents;"}, {"role": "user", "content": "Show me the count of documents for each verification_status."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents GROUP BY verification_status;"}, {"role": "user", "content": "Exclude any documents where the verification_status is 'Pending' or 'Rejected'."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents WHERE verification_status NOT IN ('Pending', 'Rejected') GROUP BY verification_status;"}, {"role": "user", "content": "And order the results by the count in descending order."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents WHERE verification_status NOT IN ('Pending', 'Rejected') GROUP BY verification_status ORDER BY COUNT(*) DESC;"}]}
193
  {"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 government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\n", "conversations": [{"role": "user", "content": "List all agencies that do not have a website URL specified. Return their agency_id, agency_name, and main_phone_number."}, {"role": "assistant", "content": "SELECT agency_id, agency_name, main_phone_number FROM government_services.agencies WHERE website_url IS NULL OR website_url = '';"}]}
194
  {"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 government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\nCREATE TABLE government_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n employee_id character varying(64), -- FK to employees table (optional, if assigned)\n location_id character varying(64), -- FK to service_locations table (if physical)\n service_id character varying(64), -- FK to services table (optional, if related to specific service)\n scheduled_start_time timestamp NOT NULL,\n scheduled_end_time timestamp,\n purpose text NOT NULL, -- reason for the appointment\n status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show\n booking_method character varying(50), -- e.g., Online, Phone, In-Person\n created_at timestamp NOT NULL, -- when the appointment was booked\n notes text,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE government_services.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n application_id character varying(64), -- FK to applications table (optional)\n message_subject character varying(255),\n message_body text NOT NULL,\n channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail\n sent_at timestamp NOT NULL,\n status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read\n related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request\n related_entity_id character varying(64), -- ID of the related entity\n PRIMARY KEY (notification_id)\n)\n", "conversations": [{"role": "user", "content": "List the full names and job titles of all employees who have not verified any documents."}, {"role": "assistant", "content": "SELECT e.first_name, e.last_name, e.job_title FROM government_services.employees AS e LEFT JOIN government_services.documents AS d ON e.employee_id = d.verified_by_employee_id WHERE d.document_id IS NULL;"}]}
 
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 government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\n", "conversations": [{"role": "user", "content": "For each employee who has verified more than one document, list their employee ID, the first document they verified, and the next document they verified, along with both verification timestamps."}, {"role": "assistant", "content": "SELECT\n d1.verified_by_employee_id AS employee_id,\n d1.document_id AS first_verified_document,\n d1.verification_timestamp AS first_verification_time,\n d2.document_id AS next_verified_document,\n d2.verification_timestamp AS next_verification_time\nFROM government_services.documents d1\nJOIN government_services.documents d2\n ON d1.verified_by_employee_id = d2.verified_by_employee_id\n AND d2.verification_timestamp > d1.verification_timestamp\nWHERE d1.verification_status = 'Verified'\n AND d2.verification_status = 'Verified';"}]}