Winboy commited on
Commit
54afe69
·
verified ·
1 Parent(s): 1727d5e

Upload data.jsonl with huggingface_hub

Browse files
Files changed (1) hide show
  1. data.jsonl +2 -2
data.jsonl CHANGED
@@ -149,6 +149,7 @@
149
  {"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 blockchain.smart_contracts ( contract_id text PRIMARY KEY, creator_address text, code text, timestamp timestamp )\n", "conversations": [{"role": "user", "content": "Show me the earliest created smart contract for each creator address."}, {"role": "assistant", "content": "SELECT DISTINCT ON (creator_address) contract_id, creator_address, code, timestamp FROM blockchain.smart_contracts ORDER BY creator_address, timestamp ASC;"}, {"role": "user", "content": "Now include the total number of contracts each creator has made alongside this information."}, {"role": "assistant", "content": "WITH earliest_contracts AS (SELECT DISTINCT ON (creator_address) contract_id, creator_address, code, timestamp FROM blockchain.smart_contracts ORDER BY creator_address, timestamp ASC) SELECT ec.*, (SELECT COUNT(*) FROM blockchain.smart_contracts sc WHERE sc.creator_address = ec.creator_address) AS total_contracts FROM earliest_contracts ec;"}, {"role": "user", "content": "Filter this to only show creators who have made at least 10 contracts."}, {"role": "assistant", "content": "WITH earliest_contracts AS (SELECT DISTINCT ON (creator_address) contract_id, creator_address, code, timestamp FROM blockchain.smart_contracts ORDER BY creator_address, timestamp ASC) SELECT ec.*, (SELECT COUNT(*) FROM blockchain.smart_contracts sc WHERE sc.creator_address = ec.creator_address) AS total_contracts FROM earliest_contracts ec WHERE (SELECT COUNT(*) FROM blockchain.smart_contracts sc WHERE sc.creator_address = ec.creator_address) >= 10;"}]}
150
  {"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 blockchain.blocks (\n block_id character varying(64) NOT NULL, -- unique identifier for the block\n previous_block_id character varying(64), -- identifier of the previous block\n timestamp timestamp NOT NULL, -- time when the block was mined\n nonce integer NOT NULL, -- nonce value used in the proof of work\n merkle_root character varying(128) NOT NULL, -- root of the Merkle tree for transactions\n difficulty integer NOT NULL, -- difficulty level of the block\n PRIMARY KEY (block_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve the block ID, timestamp, current block's difficulty, and the difficulty of the *previous* block for all blocks where the current block's difficulty is strictly greater than the previous block's difficulty."}, {"role": "assistant", "content": "SELECT b1.block_id, b1.timestamp, b1.difficulty AS current_difficulty, b2.difficulty AS previous_difficulty FROM blockchain.blocks b1 JOIN blockchain.blocks b2 ON b1.previous_block_id = b2.block_id WHERE b1.difficulty > b2.difficulty;"}]}
151
  {"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 blockchain.nodes ( node_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (node_id) )\n", "conversations": [{"role": "user", "content": "Retrieve all pairs of nodes where one node was last seen before '2023-06-01' and the other after '2023-06-01', and they share the same IP address."}, {"role": "assistant", "content": "SELECT a.node_id AS node_before,\n b.node_id AS node_after,\n a.ip_address\nFROM blockchain.nodes a\nJOIN blockchain.nodes b\n ON a.ip_address = b.ip_address\nWHERE a.last_seen < '2023-06-01'\n AND b.last_seen > '2023-06-01';"}]}
 
152
  {"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 text PRIMARY KEY, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\n", "conversations": [{"role": "user", "content": "How many documents are in each verification_status?"}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nGROUP BY verification_status;"}, {"role": "user", "content": "Only include statuses with more than 100 documents."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nGROUP BY verification_status\nHAVING COUNT(*) > 100;"}, {"role": "user", "content": "Order the results by document_count in descending order."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nGROUP BY verification_status\nHAVING COUNT(*) > 100\nORDER BY document_count DESC;"}, {"role": "user", "content": "Also exclude documents where expiry_date is before today."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nWHERE expiry_date >= CURRENT_DATE\nGROUP BY verification_status\nHAVING COUNT(*) > 100\nORDER BY document_count DESC;"}]}
153
  {"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.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.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 ( document_id.text, application_id.text, citizen_id.text, document_type.text, file_reference.text, upload_timestamp.timestamp, expiry_date.date, verification_status.text, verified_by_employee_id.text, verification_timestamp.timestamp )\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.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.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 application reference numbers and the total amount paid for each application that has at least one completed payment."}, {"role": "assistant", "content": "SELECT a.reference_number, SUM(p.amount) AS total_paid FROM government_services.applications AS a JOIN government_services.payments AS p ON a.application_id = p.application_id WHERE p.status = 'Completed' GROUP BY a.reference_number;"}, {"role": "user", "content": "Also include the citizen's first and last name who submitted the application."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, a.reference_number, SUM(p.amount) AS total_paid FROM government_services.applications AS a JOIN government_services.payments AS p ON a.application_id = p.application_id JOIN government_services.citizens AS c ON a.citizen_id = c.citizen_id WHERE p.status = 'Completed' GROUP BY c.first_name, c.last_name, a.reference_number;"}]}
154
  {"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 text, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\n", "conversations": [{"role": "user", "content": "How many documents were uploaded in the month of October 2023?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM government_services.documents WHERE upload_timestamp >= '2023-10-01 00:00:00' AND upload_timestamp < '2023-11-01 00:00:00';"}]}
@@ -231,7 +232,6 @@
231
  {"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.appointments ( appointment_id character varying(64) NOT NULL, client_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, case_id character varying(64), start_time timestamp NOT NULL, end_time timestamp NOT NULL, location text, subject character varying(255), notes text, status character varying(50) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (appointment_id) )\n", "conversations": [{"role": "user", "content": "Show me the subject and start times of all appointments along with the corresponding lawyer IDs for each client."}, {"role": "assistant", "content": "SELECT client_id, lawyer_id, subject, start_time FROM legal_services.appointments;"}]}
232
  {"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.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Get a list of appointment_id, start_time, and invoice_number for appointments that have a related invoice."}, {"role": "assistant", "content": "SELECT a.appointment_id,\n a.start_time,\n i.invoice_number\nFROM legal_services.appointments a\nJOIN legal_services.invoices i\n ON a.case_id = i.case_id;"}, {"role": "user", "content": "Also include only appointments that are completed and invoices that are fully paid (status 'Paid')."}, {"role": "assistant", "content": "SELECT a.appointment_id,\n a.start_time,\n i.invoice_number\nFROM legal_services.appointments a\nJOIN legal_services.invoices i\n ON a.case_id = i.case_id\nWHERE a.status = 'Completed'\n AND i.status = 'Paid';"}]}
233
  {"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 (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all time entries from the last 90 days, including the entry description, hours spent, the name of the case, and the name of the client."}, {"role": "assistant", "content": "SELECT T1.description, T1.hours_spent, T2.case_name, T3.first_name, T3.last_name FROM legal_services.time_entries AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id JOIN clients AS T3 ON T2.client_id = T3.client_id WHERE T1.date_worked >= CURRENT_DATE - INTERVAL '90 days';"}]}
234
- {"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.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "I want to see a list of invoice_number and appointment_id for each invoice that has a scheduled appointment."}, {"role": "assistant", "content": "SELECT i.invoice_number,\n a.appointment_id\nFROM legal_services.invoices i\nJOIN legal_services.appointments a\n ON i.case_id = a.case_id\nWHERE a.status = 'Scheduled';"}, {"role": "user", "content": "Only include those invoices whose due_date is still in the future."}, {"role": "assistant", "content": "SELECT i.invoice_number,\n a.appointment_id\nFROM legal_services.invoices i\nJOIN legal_services.appointments a\n ON i.case_id = a.case_id\nWHERE a.status = 'Scheduled'\n AND i.due_date > CURRENT_DATE;"}, {"role": "user", "content": "Finally, sort the results by the invoice issue_date in descending order."}, {"role": "assistant", "content": "SELECT i.invoice_number,\n a.appointment_id\nFROM legal_services.invoices i\nJOIN legal_services.appointments a\n ON i.case_id = a.case_id\nWHERE a.status = 'Scheduled'\n AND i.due_date > CURRENT_DATE\nORDER BY i.issue_date DESC;"}]}
235
  {"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.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document\n case_id character varying(64) NOT NULL, -- FK to cases table\n document_name character varying(255) NOT NULL, -- name of the document file\n document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence\n storage_path text NOT NULL, -- path or reference to the document storage location\n uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it)\n upload_timestamp timestamp NOT NULL, -- time the document was uploaded\n version integer DEFAULT 1, -- document version number\n description text, -- brief description or notes about the document\n PRIMARY KEY (document_id)\n)\n", "conversations": [{"role": "user", "content": "List the document name, type, version, and description for all documents."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents;"}, {"role": "user", "content": "Only include documents where the description is not null."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents WHERE description IS NOT NULL;"}, {"role": "user", "content": "Also, filter to only show documents with a version greater than 2."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents WHERE description IS NOT NULL AND version > 2;"}, {"role": "user", "content": "Order the results by upload timestamp descending."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents WHERE description IS NOT NULL AND version > 2 ORDER BY upload_timestamp DESC;"}]}
236
  {"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 PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, 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.cases (\n case_id character varying(64) NOT NULL, -- unique identifier for the case/matter\n case_number character varying(100) UNIQUE, -- official case number (court or internal)\n case_name text NOT NULL, -- descriptive name or title for the case\n client_id character varying(64) NOT NULL, -- FK to clients table\n lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)\n case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP\n status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed\n date_opened timestamp NOT NULL, -- date the case was formally opened\n date_closed timestamp, -- date the case was closed (nullable)\n description text, -- detailed description of the case\n court_jurisdiction character varying(128), -- court or jurisdiction if applicable\n PRIMARY KEY (case_id)\n)\nCREATE TABLE legal_services.documents ( document_id text PRIMARY KEY, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version int, description text )\nCREATE TABLE legal_services.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Show me a list of all appointments with the subject and full name of the assigned lawyer."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.subject, l.first_name || ' ' || l.last_name AS lawyer_full_name\nFROM legal_services.appointments a\nJOIN legal_services.lawyers l ON a.lawyer_id = l.lawyer_id;"}]}
237
  {"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, 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, 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 )\nCREATE TABLE insurance.agents ( agent_id.text, 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, claim_id.text, document_type.text, file_name.text, file_path.text, file_size_bytes.integer, 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": "For every customer, show their first name, last name, and the policy number of any policies they own."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id;"}, {"role": "user", "content": "Only include policies with status 'Active' or 'Pending'. Also add the policy start date to the results."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number, T2.start_date FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id WHERE T2.status IN ('Active', 'Pending');"}, {"role": "user", "content": "Further filter the customers to only those in California ('CA'). Order the results by the customer's last name and then first name."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number, T2.start_date FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id WHERE T2.status IN ('Active', 'Pending') AND T1.state = 'CA' ORDER BY T1.last_name, T1.first_name;"}, {"role": "user", "content": "Instead of listing each policy, tell me how many 'Active' or 'Pending' policies each of these California customers has. Show their full name and the count."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, COUNT(T2.policy_id) FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id WHERE T2.status IN ('Active', 'Pending') AND T1.state = 'CA' GROUP BY T1.customer_id, T1.first_name, T1.last_name ORDER BY T1.last_name, T1.first_name;"}]}
@@ -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 legal_services.law_firms ( firm_id character varying(64) NOT NULL, firm_name character varying(200) NOT NULL, address text NOT NULL, phone character varying(32), website character varying(255), founded_date date, managing_partner_id character varying(64), PRIMARY KEY (firm_id) )\n", "conversations": [{"role": "user", "content": "List all pairs of law firms founded in the same year, showing the two firm names and the shared year."}, {"role": "assistant", "content": "SELECT f1.firm_name AS firm1, f2.firm_name AS firm2, EXTRACT(YEAR FROM f1.founded_date) AS year FROM law_firms f1 JOIN law_firms f2 ON EXTRACT(YEAR FROM f1.founded_date) = EXTRACT(YEAR FROM f2.founded_date) AND f1.firm_id <> f2.firm_id;"}, {"role": "user", "content": "Actually, only include years after 2000."}, {"role": "assistant", "content": "SELECT f1.firm_name AS firm1, f2.firm_name AS firm2, EXTRACT(YEAR FROM f1.founded_date) AS year FROM law_firms f1 JOIN law_firms f2 ON EXTRACT(YEAR FROM f1.founded_date) = EXTRACT(YEAR FROM f2.founded_date) AND f1.firm_id <> f2.firm_id WHERE EXTRACT(YEAR FROM f1.founded_date) > 2000;"}, {"role": "user", "content": "And ensure each pair only appears once."}, {"role": "assistant", "content": "SELECT f1.firm_name AS firm1, f2.firm_name AS firm2, EXTRACT(YEAR FROM f1.founded_date) AS year FROM law_firms f1 JOIN law_firms f2 ON EXTRACT(YEAR FROM f1.founded_date) = EXTRACT(YEAR FROM f2.founded_date) AND f1.firm_id < f2.firm_id WHERE EXTRACT(YEAR FROM f1.founded_date) > 2000;"}]}
 
149
  {"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 blockchain.smart_contracts ( contract_id text PRIMARY KEY, creator_address text, code text, timestamp timestamp )\n", "conversations": [{"role": "user", "content": "Show me the earliest created smart contract for each creator address."}, {"role": "assistant", "content": "SELECT DISTINCT ON (creator_address) contract_id, creator_address, code, timestamp FROM blockchain.smart_contracts ORDER BY creator_address, timestamp ASC;"}, {"role": "user", "content": "Now include the total number of contracts each creator has made alongside this information."}, {"role": "assistant", "content": "WITH earliest_contracts AS (SELECT DISTINCT ON (creator_address) contract_id, creator_address, code, timestamp FROM blockchain.smart_contracts ORDER BY creator_address, timestamp ASC) SELECT ec.*, (SELECT COUNT(*) FROM blockchain.smart_contracts sc WHERE sc.creator_address = ec.creator_address) AS total_contracts FROM earliest_contracts ec;"}, {"role": "user", "content": "Filter this to only show creators who have made at least 10 contracts."}, {"role": "assistant", "content": "WITH earliest_contracts AS (SELECT DISTINCT ON (creator_address) contract_id, creator_address, code, timestamp FROM blockchain.smart_contracts ORDER BY creator_address, timestamp ASC) SELECT ec.*, (SELECT COUNT(*) FROM blockchain.smart_contracts sc WHERE sc.creator_address = ec.creator_address) AS total_contracts FROM earliest_contracts ec WHERE (SELECT COUNT(*) FROM blockchain.smart_contracts sc WHERE sc.creator_address = ec.creator_address) >= 10;"}]}
150
  {"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 blockchain.blocks (\n block_id character varying(64) NOT NULL, -- unique identifier for the block\n previous_block_id character varying(64), -- identifier of the previous block\n timestamp timestamp NOT NULL, -- time when the block was mined\n nonce integer NOT NULL, -- nonce value used in the proof of work\n merkle_root character varying(128) NOT NULL, -- root of the Merkle tree for transactions\n difficulty integer NOT NULL, -- difficulty level of the block\n PRIMARY KEY (block_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve the block ID, timestamp, current block's difficulty, and the difficulty of the *previous* block for all blocks where the current block's difficulty is strictly greater than the previous block's difficulty."}, {"role": "assistant", "content": "SELECT b1.block_id, b1.timestamp, b1.difficulty AS current_difficulty, b2.difficulty AS previous_difficulty FROM blockchain.blocks b1 JOIN blockchain.blocks b2 ON b1.previous_block_id = b2.block_id WHERE b1.difficulty > b2.difficulty;"}]}
151
  {"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 blockchain.nodes ( node_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (node_id) )\n", "conversations": [{"role": "user", "content": "Retrieve all pairs of nodes where one node was last seen before '2023-06-01' and the other after '2023-06-01', and they share the same IP address."}, {"role": "assistant", "content": "SELECT a.node_id AS node_before,\n b.node_id AS node_after,\n a.ip_address\nFROM blockchain.nodes a\nJOIN blockchain.nodes b\n ON a.ip_address = b.ip_address\nWHERE a.last_seen < '2023-06-01'\n AND b.last_seen > '2023-06-01';"}]}
152
+ {"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.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 (\n service_id character varying(64) NOT NULL, -- unique identifier for the service\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n service_name character varying(255) NOT NULL, -- name of the service (e.g., Driver's License Renewal)\n description text,\n category character varying(100), -- e.g., Licensing, Benefits, Taxation, Permits\n eligibility_criteria text, -- description of who is eligible\n standard_fee numeric(10, 2) DEFAULT 0.00, -- typical fee for the service\n average_processing_time_days integer, -- estimated processing time\n is_active boolean DEFAULT true, -- whether the service is currently offered\n online_application_url character varying(255),\n PRIMARY KEY (service_id)\n)\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\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 ( 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": "List the names of services that have been scheduled at accessible service locations."}, {"role": "assistant", "content": "SELECT DISTINCT T1.service_name FROM government_services.services AS T1 JOIN government_services.appointments AS T2 ON T1.service_id = T2.service_id JOIN government_services.service_locations AS T3 ON T2.location_id = T3.location_id WHERE T3.is_accessible = TRUE"}, {"role": "user", "content": "Now, only include services from agencies with 'State' jurisdiction level."}, {"role": "assistant", "content": "SELECT DISTINCT T1.service_name FROM government_services.services AS T1 JOIN government_services.appointments AS T2 ON T1.service_id = T2.service_id JOIN government_services.service_locations AS T3 ON T2.location_id = T3.location_id JOIN government_services.agencies AS T4 ON T1.agency_id = T4.agency_id WHERE T3.is_accessible = TRUE AND T4.jurisdiction_level = 'State'"}]}
153
  {"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 text PRIMARY KEY, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\n", "conversations": [{"role": "user", "content": "How many documents are in each verification_status?"}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nGROUP BY verification_status;"}, {"role": "user", "content": "Only include statuses with more than 100 documents."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nGROUP BY verification_status\nHAVING COUNT(*) > 100;"}, {"role": "user", "content": "Order the results by document_count in descending order."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nGROUP BY verification_status\nHAVING COUNT(*) > 100\nORDER BY document_count DESC;"}, {"role": "user", "content": "Also exclude documents where expiry_date is before today."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) AS document_count\nFROM government_services.documents\nWHERE expiry_date >= CURRENT_DATE\nGROUP BY verification_status\nHAVING COUNT(*) > 100\nORDER BY document_count DESC;"}]}
154
  {"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.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.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 ( document_id.text, application_id.text, citizen_id.text, document_type.text, file_reference.text, upload_timestamp.timestamp, expiry_date.date, verification_status.text, verified_by_employee_id.text, verification_timestamp.timestamp )\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.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.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 application reference numbers and the total amount paid for each application that has at least one completed payment."}, {"role": "assistant", "content": "SELECT a.reference_number, SUM(p.amount) AS total_paid FROM government_services.applications AS a JOIN government_services.payments AS p ON a.application_id = p.application_id WHERE p.status = 'Completed' GROUP BY a.reference_number;"}, {"role": "user", "content": "Also include the citizen's first and last name who submitted the application."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, a.reference_number, SUM(p.amount) AS total_paid FROM government_services.applications AS a JOIN government_services.payments AS p ON a.application_id = p.application_id JOIN government_services.citizens AS c ON a.citizen_id = c.citizen_id WHERE p.status = 'Completed' GROUP BY c.first_name, c.last_name, a.reference_number;"}]}
155
  {"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 text, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\n", "conversations": [{"role": "user", "content": "How many documents were uploaded in the month of October 2023?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM government_services.documents WHERE upload_timestamp >= '2023-10-01 00:00:00' AND upload_timestamp < '2023-11-01 00:00:00';"}]}
 
232
  {"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.appointments ( appointment_id character varying(64) NOT NULL, client_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, case_id character varying(64), start_time timestamp NOT NULL, end_time timestamp NOT NULL, location text, subject character varying(255), notes text, status character varying(50) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (appointment_id) )\n", "conversations": [{"role": "user", "content": "Show me the subject and start times of all appointments along with the corresponding lawyer IDs for each client."}, {"role": "assistant", "content": "SELECT client_id, lawyer_id, subject, start_time FROM legal_services.appointments;"}]}
233
  {"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.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Get a list of appointment_id, start_time, and invoice_number for appointments that have a related invoice."}, {"role": "assistant", "content": "SELECT a.appointment_id,\n a.start_time,\n i.invoice_number\nFROM legal_services.appointments a\nJOIN legal_services.invoices i\n ON a.case_id = i.case_id;"}, {"role": "user", "content": "Also include only appointments that are completed and invoices that are fully paid (status 'Paid')."}, {"role": "assistant", "content": "SELECT a.appointment_id,\n a.start_time,\n i.invoice_number\nFROM legal_services.appointments a\nJOIN legal_services.invoices i\n ON a.case_id = i.case_id\nWHERE a.status = 'Completed'\n AND i.status = 'Paid';"}]}
234
  {"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 (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all time entries from the last 90 days, including the entry description, hours spent, the name of the case, and the name of the client."}, {"role": "assistant", "content": "SELECT T1.description, T1.hours_spent, T2.case_name, T3.first_name, T3.last_name FROM legal_services.time_entries AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id JOIN clients AS T3 ON T2.client_id = T3.client_id WHERE T1.date_worked >= CURRENT_DATE - INTERVAL '90 days';"}]}
 
235
  {"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.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document\n case_id character varying(64) NOT NULL, -- FK to cases table\n document_name character varying(255) NOT NULL, -- name of the document file\n document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence\n storage_path text NOT NULL, -- path or reference to the document storage location\n uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it)\n upload_timestamp timestamp NOT NULL, -- time the document was uploaded\n version integer DEFAULT 1, -- document version number\n description text, -- brief description or notes about the document\n PRIMARY KEY (document_id)\n)\n", "conversations": [{"role": "user", "content": "List the document name, type, version, and description for all documents."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents;"}, {"role": "user", "content": "Only include documents where the description is not null."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents WHERE description IS NOT NULL;"}, {"role": "user", "content": "Also, filter to only show documents with a version greater than 2."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents WHERE description IS NOT NULL AND version > 2;"}, {"role": "user", "content": "Order the results by upload timestamp descending."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, description FROM documents WHERE description IS NOT NULL AND version > 2 ORDER BY upload_timestamp DESC;"}]}
236
  {"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 PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, 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.cases (\n case_id character varying(64) NOT NULL, -- unique identifier for the case/matter\n case_number character varying(100) UNIQUE, -- official case number (court or internal)\n case_name text NOT NULL, -- descriptive name or title for the case\n client_id character varying(64) NOT NULL, -- FK to clients table\n lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)\n case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP\n status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed\n date_opened timestamp NOT NULL, -- date the case was formally opened\n date_closed timestamp, -- date the case was closed (nullable)\n description text, -- detailed description of the case\n court_jurisdiction character varying(128), -- court or jurisdiction if applicable\n PRIMARY KEY (case_id)\n)\nCREATE TABLE legal_services.documents ( document_id text PRIMARY KEY, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version int, description text )\nCREATE TABLE legal_services.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Show me a list of all appointments with the subject and full name of the assigned lawyer."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.subject, l.first_name || ' ' || l.last_name AS lawyer_full_name\nFROM legal_services.appointments a\nJOIN legal_services.lawyers l ON a.lawyer_id = l.lawyer_id;"}]}
237
  {"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, 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, 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 )\nCREATE TABLE insurance.agents ( agent_id.text, 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, claim_id.text, document_type.text, file_name.text, file_path.text, file_size_bytes.integer, 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": "For every customer, show their first name, last name, and the policy number of any policies they own."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id;"}, {"role": "user", "content": "Only include policies with status 'Active' or 'Pending'. Also add the policy start date to the results."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number, T2.start_date FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id WHERE T2.status IN ('Active', 'Pending');"}, {"role": "user", "content": "Further filter the customers to only those in California ('CA'). Order the results by the customer's last name and then first name."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number, T2.start_date FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id WHERE T2.status IN ('Active', 'Pending') AND T1.state = 'CA' ORDER BY T1.last_name, T1.first_name;"}, {"role": "user", "content": "Instead of listing each policy, tell me how many 'Active' or 'Pending' policies each of these California customers has. Show their full name and the count."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, COUNT(T2.policy_id) FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id WHERE T2.status IN ('Active', 'Pending') AND T1.state = 'CA' GROUP BY T1.customer_id, T1.first_name, T1.last_name ORDER BY T1.last_name, T1.first_name;"}]}
 
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 gaming_technology.players ( player_id uuid NOT NULL DEFAULT gen_random_uuid(), username character varying(100) NOT NULL UNIQUE, email character varying(255) NOT NULL UNIQUE, password_hash text NOT NULL, registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, last_login timestamp with time zone, country_code character(2), status character varying(20) NOT NULL DEFAULT 'active', profile_data jsonb, PRIMARY KEY (player_id) )\n", "conversations": [{"role": "user", "content": "Show me the number of players who registered each year. List the registration year and the count."}, {"role": "assistant", "content": "SELECT EXTRACT(YEAR FROM registration_date) AS registration_year, COUNT(*) AS player_count FROM gaming_technology.players GROUP BY registration_year ORDER BY registration_year;"}, {"role": "user", "content": "Now, filter that list to only show years where more than 50 players registered."}, {"role": "assistant", "content": "SELECT EXTRACT(YEAR FROM registration_date) AS registration_year, COUNT(*) AS player_count FROM gaming_technology.players GROUP BY EXTRACT(YEAR FROM registration_date) HAVING COUNT(*) > 50 ORDER BY registration_year;"}, {"role": "user", "content": "Also include the earliest and latest registration date for each of those years."}, {"role": "assistant", "content": "SELECT EXTRACT(YEAR FROM registration_date) AS registration_year, COUNT(*) AS player_count, MIN(registration_date) AS earliest_registration_date, MAX(registration_date) AS latest_registration_date FROM gaming_technology.players GROUP BY EXTRACT(YEAR FROM registration_date) HAVING COUNT(*) > 50 ORDER BY registration_year;"}, {"role": "user", "content": "Order the results by the player count in descending order."}, {"role": "assistant", "content": "SELECT EXTRACT(YEAR FROM registration_date) AS registration_year, COUNT(*) AS player_count, MIN(registration_date) AS earliest_registration_date, MAX(registration_date) AS latest_registration_date FROM gaming_technology.players GROUP BY EXTRACT(YEAR FROM registration_date) HAVING COUNT(*) > 50 ORDER BY player_count DESC;"}]}