{"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 social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\n", "conversations": [{"role": "user", "content": "I need a list of all group chat names with every username."}, {"role": "assistant", "content": "SELECT u.username, c.group_name\nFROM social_media.users u\nJOIN social_media.conversations c ON 1=1\nWHERE c.is_group_chat = true;"}, {"role": "user", "content": "Actually, only include users who are verified."}, {"role": "assistant", "content": "SELECT u.username, c.group_name\nFROM social_media.users u\nJOIN social_media.conversations c ON 1=1\nWHERE c.is_group_chat = true\n AND u.is_verified = true;"}]} {"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.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\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)\nCREATE TABLE legal_services.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "List all cases that have an invoice issued in July 2024, showing the case name, case number, invoice number, and issue date."}, {"role": "assistant", "content": "SELECT T1.case_name, T1.case_number, T2.invoice_number, T2.issue_date FROM legal_services.cases AS T1 JOIN legal_services.invoices AS T2 ON T1.case_id = T2.case_id WHERE T2.issue_date BETWEEN '2024-07-01' AND '2024-07-31';"}]} {"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.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\n", "conversations": [{"role": "user", "content": "For each patient, find their latest medical record and show patient_id, latest_record_id, and record_date."}, {"role": "assistant", "content": "SELECT a.patient_id,\n a.record_id AS latest_record_id,\n a.record_date\nFROM healthcare.medical_records a\nLEFT JOIN healthcare.medical_records b\n ON a.patient_id = b.patient_id\n AND a.record_date < b.record_date\nWHERE b.record_id IS NULL;"}, {"role": "user", "content": "Actually, only include records created after January 1st, 2024."}, {"role": "assistant", "content": "SELECT a.patient_id,\n a.record_id AS latest_record_id,\n a.record_date\nFROM healthcare.medical_records a\nLEFT JOIN healthcare.medical_records b\n ON a.patient_id = b.patient_id\n AND a.record_date < b.record_date\nWHERE b.record_id IS NULL\n AND a.record_date > '2024-01-01';"}]} {"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 trading_platform.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(128) NOT NULL, -- username of the user\n email character varying(128) NOT NULL, -- email address of the user\n password_hash text NOT NULL, -- hashed password of the user\n created_at timestamp NOT NULL, -- time when the user account was created\n PRIMARY KEY (user_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all users whose email address contains the word 'test', along with their user IDs and the date they registered."}, {"role": "assistant", "content": "SELECT user_id, username, email, created_at FROM trading_platform.users WHERE email ILIKE '%test%';"}, {"role": "user", "content": "Actually, only include users who registered after January 1, 2024, and sort them by newest registration date first."}, {"role": "assistant", "content": "SELECT user_id, username, email, created_at FROM trading_platform.users WHERE email ILIKE '%test%' AND created_at > '2024-01-01' ORDER BY created_at DESC;"}]} {"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.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": "List all beneficiaries who have a relationship of 'Parent' and a percentage_share less than 25%. Show their beneficiary_id, first_name, last_name, relationship, and percentage_share."}, {"role": "assistant", "content": "SELECT beneficiary_id, first_name, last_name, relationship, percentage_share\nFROM insurance.policy_beneficiaries\nWHERE relationship = 'Parent' AND percentage_share < 25;"}]} {"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 character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\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) )\nCREATE TABLE legal_services.cases ( case_id character varying(64) NOT NULL, case_number character varying(100) UNIQUE, case_name text NOT NULL, client_id character varying(64) NOT NULL, lead_lawyer_id character varying(64) NOT NULL, case_type character varying(100) NOT NULL, status character varying(50) NOT NULL, date_opened timestamp NOT NULL, date_closed timestamp, description text, court_jurisdiction character varying(128), PRIMARY KEY (case_id) )\nCREATE TABLE legal_services.documents ( document_id character varying(64) NOT NULL, case_id character varying(64) NOT NULL, document_name character varying(255) NOT NULL, document_type character varying(100), storage_path text NOT NULL, uploaded_by_lawyer_id character varying(64), upload_timestamp timestamp NOT NULL, version integer DEFAULT 1, description text, PRIMARY KEY (document_id) )\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": "List documents uploaded for cases of type 'Intellectual Property', showing the document name, upload timestamp, and the case number."}, {"role": "assistant", "content": "SELECT T1.document_name, T1.upload_timestamp, T2.case_number FROM documents AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id WHERE T2.case_type = 'Intellectual Property';"}, {"role": "user", "content": "Only include documents with a version greater than 1 and order by upload timestamp descending."}, {"role": "assistant", "content": "SELECT T1.document_name, T1.upload_timestamp, T2.case_number FROM documents AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id WHERE T2.case_type = 'Intellectual Property' AND T1.version > 1 ORDER BY T1.upload_timestamp DESC;"}]} {"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 PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb )\nCREATE TABLE gaming_technology.achievements ( achievement_id uuid PRIMARY KEY, game_id uuid, name text, description text, icon_url text, points int, hidden boolean )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\nCREATE TABLE gaming_technology.in_game_items ( item_id.uuid, game_id.uuid, item_name.text, item_type.text, description.text, rarity.text, cost_currency.text, cost_amount.numeric, attributes.jsonb )\nCREATE TABLE gaming_technology.player_inventory (\n inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry\n player_id uuid NOT NULL, -- FK linking to the player owning the item\n item_id uuid NOT NULL, -- FK linking to the item definition\n quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items)\n acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired\n instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability)\n PRIMARY KEY (inventory_id),\n -- Optional unique constraint if items are non-stackable or unique instances\n -- UNIQUE (player_id, item_id) -- Use if quantity is always 1\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id)\n)\n", "conversations": [{"role": "user", "content": "For each player, show their username and the total number of achievements they have unlocked in games where they also own at least one item. Only include players who have unlocked at least one achievement."}, {"role": "assistant", "content": "SELECT p.username, COUNT(DISTINCT pa.achievement_id) AS total_achievements\nFROM gaming_technology.players p\nJOIN gaming_technology.player_achievements pa ON p.player_id = pa.player_id\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nGROUP BY p.player_id, p.username\nHAVING COUNT(DISTINCT pa.achievement_id) > 0;"}, {"role": "user", "content": "Instead of just players with at least one achievement, limit the query to players who have unlocked 3 or more achievements, and sort by total_achievements descending."}, {"role": "assistant", "content": "SELECT p.username, COUNT(DISTINCT pa.achievement_id) AS total_achievements\nFROM gaming_technology.players p\nJOIN gaming_technology.player_achievements pa ON p.player_id = pa.player_id\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nGROUP BY p.player_id, p.username\nHAVING COUNT(DISTINCT pa.achievement_id) >= 3\nORDER BY total_achievements DESC;"}]} {"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 transportation.bookings (\n booking_id character varying(64) NOT NULL, -- unique identifier for the booking\n passenger_id character varying(64) NOT NULL, -- identifier of the passenger making the booking\n trip_id character varying(64) NOT NULL, -- identifier of the trip being booked\n seat_number character varying(16), -- assigned seat number (if applicable)\n booking_time timestamp with time zone NOT NULL, -- time when the booking was made\n status character varying(32) NOT NULL, -- e.g., Confirmed, Cancelled, Pending Payment\n fare numeric(10, 2) NOT NULL, -- price paid for the booking\n payment_transaction_id character varying(128), -- reference to the payment transaction\n special_requests text, -- any special requests from the passenger\n PRIMARY KEY (booking_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the total number of bookings and total fare collected per trip. Only include trips that have collected more than 500 in total fare."}, {"role": "assistant", "content": "SELECT trip_id, COUNT(*) AS booking_count, SUM(fare) AS total_fare\nFROM transportation.bookings\nGROUP BY trip_id\nHAVING SUM(fare) > 500;"}]} {"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 cex_token_balance ( snapshot_time.text, chain.text, address.text, exchange.text, token_address.text, token_symbol.text, balance.numeric, usd_value.numeric, price.numeric )\n", "conversations": [{"role": "user", "content": "How many unique tokens are recorded for each chain in the latest snapshot in cex_token_balance?"}, {"role": "assistant", "content": "WITH latest_snapshot AS (\n SELECT MAX(snapshot_time) AS max_time FROM cex_token_balance\n)\nSELECT \n chain, \n COUNT(DISTINCT token_symbol) AS unique_token_count\nFROM cex_token_balance c\nJOIN latest_snapshot l ON c.snapshot_time = l.max_time\nGROUP BY chain\nORDER BY unique_token_count DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "I need to find all pairs of medications that share the same manufacturer. For each pair, show the first medication's ID and name, the second medication's ID and name, and the manufacturer."}, {"role": "assistant", "content": "SELECT m1.medication_id AS med1_id,\n m1.medication_name AS med1_name,\n m2.medication_id AS med2_id,\n m2.medication_name AS med2_name,\n m1.manufacturer\nFROM healthcare.medications m1\nJOIN healthcare.medications m2\n ON m1.manufacturer = m2.manufacturer\n AND m1.medication_id < m2.medication_id;"}, {"role": "user", "content": "Actually, only include pairs where the two medications have different generic_name values."}, {"role": "assistant", "content": "SELECT m1.medication_id AS med1_id,\n m1.medication_name AS med1_name,\n m2.medication_id AS med2_id,\n m2.medication_name AS med2_name,\n m1.manufacturer\nFROM healthcare.medications m1\nJOIN healthcare.medications m2\n ON m1.manufacturer = m2.manufacturer\n AND m1.medication_id < m2.medication_id\nWHERE m1.generic_name <> m2.generic_name;"}, {"role": "user", "content": "Also, exclude any pairs where the manufacturer field is NULL for either medication."}, {"role": "assistant", "content": "SELECT m1.medication_id AS med1_id,\n m1.medication_name AS med1_name,\n m2.medication_id AS med2_id,\n m2.medication_name AS med2_name,\n m1.manufacturer\nFROM healthcare.medications m1\nJOIN healthcare.medications m2\n ON m1.manufacturer = m2.manufacturer\n AND m1.medication_id < m2.medication_id\nWHERE m1.generic_name <> m2.generic_name\n AND m1.manufacturer IS NOT NULL\n AND m2.manufacturer IS NOT NULL;"}, {"role": "user", "content": "Finally, limit the result to manufacturers that have at least three medications in the table."}, {"role": "assistant", "content": "SELECT m1.medication_id AS med1_id,\n m1.medication_name AS med1_name,\n m2.medication_id AS med2_id,\n m2.medication_name AS med2_name,\n m1.manufacturer\nFROM healthcare.medications m1\nJOIN healthcare.medications m2\n ON m1.manufacturer = m2.manufacturer\n AND m1.medication_id < m2.medication_id\nWHERE m1.generic_name <> m2.generic_name\n AND m1.manufacturer IS NOT NULL\n AND m2.manufacturer IS NOT NULL\n AND m1.manufacturer IN (\n SELECT manufacturer\n FROM healthcare.medications\n WHERE manufacturer IS NOT NULL\n GROUP BY manufacturer\n HAVING COUNT(*) >= 3\n );"}]} {"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, creator_address.text, code.text, timestamp.timestamp )\n", "conversations": [{"role": "user", "content": "Find all smart contracts where the contract code contains the keyword 'proxy'."}, {"role": "assistant", "content": "SELECT contract_id, creator_address, timestamp FROM blockchain.smart_contracts WHERE code LIKE '%proxy%';"}, {"role": "user", "content": "For these 'proxy' contracts, can you also include the total number of contracts deployed by each creator?"}, {"role": "assistant", "content": "SELECT sc.contract_id, sc.creator_address, sc.timestamp, creator_counts.total_contracts FROM blockchain.smart_contracts sc JOIN ( SELECT creator_address, COUNT(*) as total_contracts FROM blockchain.smart_contracts GROUP BY creator_address ) creator_counts ON sc.creator_address = creator_counts.creator_address WHERE sc.code LIKE '%proxy%';"}]} {"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);"}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "List all insurance products along with their product types and the date they were last updated, but only include products where the base premium is greater than 2000."}, {"role": "assistant", "content": "SELECT product_id, product_name, product_type, updated_at\nFROM insurance.insurance_products\nWHERE base_premium > 2000;"}]} {"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 )\nCREATE TABLE financial_services.transactions ( transaction_id text, account_id text, related_account_id text, transaction_type text, amount numeric, currency text, transaction_date timestamp, effective_date date, description text, status text, reference_number text )\nCREATE TABLE financial_services.securities ( security_id.text, ticker_symbol.text, isin_code.text, cusip_code.text, security_name.text, security_type.text, exchange.text, currency.text, issuer_name.text, sector.text, last_updated.timestamp )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the employee\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(100) NOT NULL, -- e.g., Teller, Branch Manager, Financial Advisor, Analyst\n department character varying(100), -- e.g., Retail Banking, Wealth Management, IT\n branch_id character varying(64), -- Identifier for the branch they work at (if applicable)\n email character varying(128) NOT NULL UNIQUE,\n phone_extension character varying(20),\n hire_date date NOT NULL,\n termination_date date, -- Date of termination, null if currently employed\n manager_id character varying(64), -- Self-referencing key for manager relationship\n status character varying(32) NOT NULL, -- e.g., Active, Terminated, On Leave\n PRIMARY KEY (employee_id),\n FOREIGN KEY (branch_id) REFERENCES financial_services.branches(branch_id), -- Assuming a branches table exists\n FOREIGN KEY (manager_id) REFERENCES financial_services.employees(employee_id)\n)\n", "conversations": [{"role": "user", "content": "List all employees hired in 2023 along with their job title and email."}, {"role": "assistant", "content": "SELECT employee_id, first_name, last_name, job_title, email\nFROM financial_services.employees\nWHERE EXTRACT(YEAR FROM hire_date) = 2023;"}, {"role": "user", "content": "Can you also include the full name of their direct manager for each employee?"}, {"role": "assistant", "content": "SELECT e.employee_id, e.first_name, e.last_name, e.job_title, e.email, CONCAT(m.first_name, ' ', m.last_name) AS manager_full_name\nFROM financial_services.employees e\nLEFT JOIN financial_services.employees m ON e.manager_id = m.employee_id\nWHERE EXTRACT(YEAR FROM e.hire_date) = 2023;"}, {"role": "user", "content": "Now limit the output to only employees who are currently 'Active'."}, {"role": "assistant", "content": "SELECT e.employee_id, e.first_name, e.last_name, e.job_title, e.email, CONCAT(m.first_name, ' ', m.last_name) AS manager_full_name\nFROM financial_services.employees e\nLEFT JOIN financial_services.employees m ON e.manager_id = m.employee_id\nWHERE EXTRACT(YEAR FROM e.hire_date) = 2023 AND e.status = 'Active';"}]} {"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.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "Show all insurance plans where the plan name includes the word 'Care'."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, insurance_provider, plan_type\nFROM healthcare.insurance_plans\nWHERE plan_name ILIKE '%Care%';"}]} {"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 character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\nCREATE TABLE legal_services.invoices ( invoice_id character varying(64) NOT NULL, invoice_number character varying(100) UNIQUE NOT NULL, client_id character varying(64) NOT NULL, case_id character varying(64), issue_date date NOT NULL, due_date date NOT NULL, total_amount numeric(12, 2) NOT NULL, amount_paid numeric(12, 2) DEFAULT 0.00, status character varying(50) NOT NULL, payment_date timestamp, notes text, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (invoice_id) )\n", "conversations": [{"role": "user", "content": "Calculate the total amount billed for each client, showing their first name, last name, and the total amount."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, SUM(i.total_amount) FROM legal_services.clients c JOIN legal_services.invoices i ON c.client_id = i.client_id GROUP BY c.client_id, c.first_name, c.last_name;"}]} {"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 web3.wallets ( wallet_id text PRIMARY KEY, user_id text, address text, private_key text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "For each wallet, find the previous wallet created by the same user. Show current wallet_id, previous_wallet_id, user_id, and the difference in days between their creation dates."}, {"role": "assistant", "content": "SELECT\n wallet_id AS current_wallet_id,\n LAG(wallet_id) OVER (PARTITION BY user_id ORDER BY created_at) AS previous_wallet_id,\n user_id,\n EXTRACT(EPOCH FROM (\n created_at - LAG(created_at) OVER (PARTITION BY user_id ORDER BY created_at)\n )) / 86400 AS diff_days\nFROM web3.wallets;"}]} {"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 smart_money_token_performance ( token_address character varying(100) NOT NULL, token_symbol character varying(100), pnl numeric(38,2), net_flow numeric(38,2), avg_cost numeric(38,16), price double precision, realized_ratio numeric(10,2), roi numeric(10,2), chain character varying(100) )\n", "conversations": [{"role": "user", "content": "Which token on the Ethereum chain had the highest realized ratio last quarter? Show the symbol, realized ratio, and ROI."}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 1;"}, {"role": "user", "content": "Can you show the top 3 tokens by realized ratio instead of just the top one?"}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 3;"}, {"role": "user", "content": "Include their average cost in the result."}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi, avg_cost FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 3;"}, {"role": "user", "content": "Also show their current price."}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi, avg_cost, price FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 3;"}]} {"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 social_media.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool )\n", "conversations": [{"role": "user", "content": "Show the usernames of users who have used any hashtag in their posts, along with the tag name."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username, T4.tag_name FROM social_media.users AS T1 JOIN posts AS T2 ON T1.user_id = T2.user_id JOIN post_hashtags AS T3 ON T2.post_id = T3.post_id JOIN hashtags AS T4 ON T3.hashtag_id = T4.hashtag_id;"}, {"role": "user", "content": "Only include users who have used hashtags more than 3 times across all their posts."}, {"role": "assistant", "content": "SELECT T1.username, COUNT(T3.hashtag_id) AS hashtag_usage_count FROM social_media.users AS T1 JOIN posts AS T2 ON T1.user_id = T2.user_id JOIN post_hashtags AS T3 ON T2.post_id = T3.post_id GROUP BY T1.username HAVING COUNT(T3.hashtag_id) > 3;"}]} {"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 erc1155_approval_for_all ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text )\nCREATE TABLE erc20_balances_historical ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.integer )\nCREATE TABLE nft_holders ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )\nCREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )\nCREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )\nCREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )\nCREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )\nCREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )\nCREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_activities_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\n", "conversations": [{"role": "user", "content": "List all ERC20 tokens where the price is between $1 and $10, including their names, symbols, and contract addresses."}, {"role": "assistant", "content": "SELECT t.name, t.symbol, t.address FROM token_prices_latest t WHERE t.price BETWEEN 1 AND 10;"}, {"role": "user", "content": "I think there's an error in your query - it should be joining with sui_coins_metadata on coin_type not address. Also, can you add the current price to the results?"}, {"role": "assistant", "content": "SELECT scm.name, scm.symbol, tpl.address, tpl.price FROM token_prices_latest tpl JOIN sui_coins_metadata scm ON tpl.address = scm.coin_type WHERE tpl.price BETWEEN 1 AND 10;"}, {"role": "user", "content": "Now filter these results to only show tokens with decimals equal to 18 and sort by name alphabetically."}, {"role": "assistant", "content": "SELECT scm.name, scm.symbol, tpl.address, tpl.price FROM token_prices_latest tpl JOIN sui_coins_metadata scm ON tpl.address = scm.coin_type WHERE tpl.price BETWEEN 1 AND 10 AND scm.decimals = 18 ORDER BY scm.name ASC;"}]} {"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.transactions ( transaction_id text, account_id text, related_account_id text, transaction_type text, amount numeric, currency text, transaction_date timestamp, effective_date date, description text, status text, reference_number text )\n", "conversations": [{"role": "user", "content": "Show the total incoming and outgoing amounts for each account_id, along with the number of transactions for each type (incoming and outgoing). An incoming transaction is when the account_id appears as related_account_id."}, {"role": "assistant", "content": "SELECT account_id, SUM(CASE WHEN related_account_id IS NOT NULL THEN amount ELSE 0 END) AS outgoing_amount, COUNT(CASE WHEN related_account_id IS NOT NULL THEN 1 END) AS outgoing_transactions, SUM(CASE WHEN account_id IN (SELECT DISTINCT related_account_id FROM financial_services.transactions WHERE related_account_id IS NOT NULL) THEN 0 ELSE amount END) AS incoming_amount, COUNT(CASE WHEN account_id IN (SELECT DISTINCT related_account_id FROM financial_services.transactions WHERE related_account_id IS NOT NULL) THEN NULL ELSE 1 END) AS incoming_transactions FROM financial_services.transactions GROUP BY account_id;"}, {"role": "user", "content": "The query did not give the correct incoming transactions. Please show incoming amounts where the account_id is equal to related_account_id."}, {"role": "assistant", "content": "SELECT account_id, SUM(CASE WHEN account_id = related_account_id THEN amount ELSE 0 END) AS incoming_amount, COUNT(CASE WHEN account_id = related_account_id THEN 1 END) AS incoming_transactions, SUM(CASE WHEN account_id <> related_account_id THEN amount ELSE 0 END) AS outgoing_amount, COUNT(CASE WHEN account_id <> related_account_id THEN 1 END) AS outgoing_transactions FROM financial_services.transactions GROUP BY account_id;"}, {"role": "user", "content": "Now, show only accounts with more than 5 incoming transactions."}, {"role": "assistant", "content": "SELECT account_id, SUM(CASE WHEN account_id = related_account_id THEN amount ELSE 0 END) AS incoming_amount, COUNT(CASE WHEN account_id = related_account_id THEN 1 END) AS incoming_transactions, SUM(CASE WHEN account_id <> related_account_id THEN amount ELSE 0 END) AS outgoing_amount, COUNT(CASE WHEN account_id <> related_account_id THEN 1 END) AS outgoing_transactions FROM financial_services.transactions GROUP BY account_id HAVING COUNT(CASE WHEN account_id = related_account_id THEN 1 END) > 5;"}]} {"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 character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, incident_date timestamp NOT NULL, reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text NOT NULL, estimated_loss numeric(15, 2), status character varying(30) NOT NULL, settlement_amount numeric(15, 2), settlement_date date, claim_handler_id character varying(64), police_report_number character varying(100), PRIMARY KEY (claim_id) )\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 )\n", "conversations": [{"role": "user", "content": "Find all documents that are larger than 5MB. Show the document ID, claim ID, file name, and file size in bytes."}, {"role": "assistant", "content": "SELECT document_id, claim_id, file_name, file_size_bytes\nFROM insurance.claim_documents\nWHERE file_size_bytes > 5242880;"}]} {"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 transportation.vehicles ( vehicle_id.text, license_plate.text, vin.text, make.text, model.text, year.integer, type.text, capacity.integer, fuel_type.text, status.text, depot_id.text, acquisition_date.date )\n", "conversations": [{"role": "user", "content": "Show me all vehicles that are due for their next service before the end of this month, along with their last service date and type."}, {"role": "assistant", "content": "SELECT v.vehicle_id, v.make, v.model, s.service_date, s.service_type FROM transportation.vehicles v JOIN transportation.service_logs s ON v.vehicle_id = s.vehicle_id WHERE s.next_service_due <= DATE('now', 'start of month', '+1 month', '-1 day') ORDER BY s.next_service_due;"}, {"role": "user", "content": "Can you include the mechanic who performed the last service and order the results by how soon the next service is due?"}, {"role": "assistant", "content": "SELECT v.vehicle_id, v.make, v.model, s.service_date, s.service_type, s.mechanic, s.next_service_due FROM transportation.vehicles v JOIN transportation.service_logs s ON v.vehicle_id = s.vehicle_id WHERE s.next_service_due <= DATE('now', 'start of month', '+1 month', '-1 day') ORDER BY s.next_service_due ASC;"}, {"role": "user", "content": "Now filter this to only show vehicles where the last service was an 'Engine Tune-up'."}, {"role": "assistant", "content": "SELECT v.vehicle_id, v.make, v.model, s.service_date, s.service_type, s.mechanic, s.next_service_due FROM transportation.vehicles v JOIN transportation.service_logs s ON v.vehicle_id = s.vehicle_id WHERE s.next_service_due <= DATE('now', 'start of month', '+1 month', '-1 day') AND s.service_type = 'Engine Tune-up' ORDER BY s.next_service_due ASC;"}]} {"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 transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.trips ( trip_id.text, route_id.text, vehicle_id.text, driver_id.text, scheduled_departure.timestamp, actual_departure.timestamp, scheduled_arrival.timestamp, actual_arrival.timestamp, origin_location_id.text, destination_location_id.text, status.text, passenger_count.integer, cargo_manifest_id.text )\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Count the number of trips for each route type."}, {"role": "assistant", "content": "SELECT R.type, COUNT(T.trip_id) FROM transportation.trips AS T JOIN transportation.routes AS R ON T.route_id = R.route_id GROUP BY R.type;"}]} {"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 transportation.vehicles ( vehicle_id.text, license_plate.text, vin.text, make.text, model.text, year.integer, type.text, capacity.integer, fuel_type.text, status.text, depot_id.text, acquisition_date.date )\nCREATE TABLE transportation.trips ( trip_id.text, route_id.text, vehicle_id.text, driver_id.text, scheduled_departure.timestamp, actual_departure.timestamp, scheduled_arrival.timestamp, actual_arrival.timestamp, origin_location_id.text, destination_location_id.text, status.text, passenger_count.integer, cargo_manifest_id.text )\nCREATE TABLE transportation.locations ( location_id.text, name.text, type.text, address_line1.text, city.text, state_province.text, postal_code.text, country.text, latitude.numeric, longitude.numeric, timezone.text )\nCREATE TABLE transportation.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Find all vehicles that have at least one fuel log and at least one maintenance log. For each vehicle, show vehicle_id, make, model, the date of its most recent maintenance, and the timestamp of its earliest fuel log."}, {"role": "assistant", "content": "SELECT v.vehicle_id,\n v.make,\n v.model,\n MAX(m.service_date) AS last_service_date,\n MIN(f.log_timestamp) AS first_fuel_log_timestamp\nFROM transportation.vehicles v\nJOIN transportation.maintenance_logs m\n ON v.vehicle_id = m.vehicle_id\nJOIN transportation.fuel_logs f\n ON v.vehicle_id = f.vehicle_id\nGROUP BY v.vehicle_id, v.make, v.model;"}, {"role": "user", "content": "Now only include vehicles where the earliest fuel log occurred before the most recent maintenance service."}, {"role": "assistant", "content": "SELECT v.vehicle_id,\n v.make,\n v.model,\n MAX(m.service_date) AS last_service_date,\n MIN(f.log_timestamp) AS first_fuel_log_timestamp\nFROM transportation.vehicles v\nJOIN transportation.maintenance_logs m\n ON v.vehicle_id = m.vehicle_id\nJOIN transportation.fuel_logs f\n ON v.vehicle_id = f.vehicle_id\nGROUP BY v.vehicle_id, v.make, v.model\nHAVING MIN(f.log_timestamp) < MAX(m.service_date);"}, {"role": "user", "content": "Also include the odometer reading at the most recent maintenance and the quantity of the earliest fuel log, and order the results by the time difference between the maintenance and fuel log in descending order."}, {"role": "assistant", "content": "WITH last_maint AS (\n SELECT ml.vehicle_id,\n ml.odometer_reading,\n ml.service_date\n FROM transportation.maintenance_logs ml\n JOIN (\n SELECT vehicle_id, MAX(service_date) AS max_date\n FROM transportation.maintenance_logs\n GROUP BY vehicle_id\n ) mx\n ON ml.vehicle_id = mx.vehicle_id\n AND ml.service_date = mx.max_date\n), first_fuel AS (\n SELECT fl.vehicle_id,\n fl.quantity,\n fl.log_timestamp\n FROM transportation.fuel_logs fl\n JOIN (\n SELECT vehicle_id, MIN(log_timestamp) AS min_ts\n FROM transportation.fuel_logs\n GROUP BY vehicle_id\n ) mn\n ON fl.vehicle_id = mn.vehicle_id\n AND fl.log_timestamp = mn.min_ts\n)\nSELECT v.vehicle_id,\n v.make,\n v.model,\n lm.odometer_reading AS last_odo,\n ff.quantity AS first_fuel_qty,\n (lm.service_date - ff.log_timestamp) AS time_diff\nFROM last_maint lm\nJOIN first_fuel ff\n ON lm.vehicle_id = ff.vehicle_id\nJOIN transportation.vehicles v\n ON v.vehicle_id = lm.vehicle_id\nORDER BY time_diff DESC;"}]} {"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.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\n", "conversations": [{"role": "user", "content": "Show me each patient and doctor pair that have both an active chronic diagnosis and at least one prescription recorded in the same medical record. Include patient_id, doctor_id, diagnosis_date, prescription_date, and medication_id."}, {"role": "assistant", "content": "SELECT\n d.patient_id,\n d.doctor_id,\n d.diagnosis_date,\n p.prescription_date,\n p.medication_id\nFROM healthcare.diagnoses d\nJOIN healthcare.prescriptions p\n ON d.record_id = p.record_id\nWHERE d.is_chronic = TRUE\n AND d.status = 'Active';"}, {"role": "user", "content": "I only want records from the last six months and please order by prescription_date descending."}, {"role": "assistant", "content": "SELECT\n d.patient_id,\n d.doctor_id,\n d.diagnosis_date,\n p.prescription_date,\n p.medication_id\nFROM healthcare.diagnoses d\nJOIN healthcare.prescriptions p\n ON d.record_id = p.record_id\nWHERE d.is_chronic = TRUE\n AND d.status = 'Active'\n AND d.diagnosis_date >= CURRENT_DATE - INTERVAL '6 months'\nORDER BY p.prescription_date DESC;"}]} {"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. 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 train_station_management.platforms ( platform_id text PRIMARY KEY, station_id text, platform_number text, track_number text, status text, length_meters numeric, accessible boolean )\n", "conversations": [{"role": "user", "content": "What is the average delay time for trains departing from platform 4 at station LMN during the past year?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide information on train delay times as this data is not stored in the platforms table. The table only contains details about platform characteristics such as ID, station, number, track, status, length, and accessibility. For delay statistics, you may need to refer to a different dataset or system."}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "For each service location, find the nearest accessible service location. Show the location_id, location_name, nearest_location_id, and the distance."}, {"role": "assistant", "content": "SELECT l.location_id,\n l.location_name,\n nearest.location_id AS nearest_location_id,\n SQRT(POWER(l.latitude - nearest.latitude, 2) + POWER(l.longitude - nearest.longitude, 2)) AS distance\nFROM service_locations l\nJOIN LATERAL (\n SELECT sl.location_id, sl.latitude, sl.longitude\n FROM service_locations sl\n WHERE sl.location_id <> l.location_id\n AND sl.is_accessible = TRUE\n ORDER BY POWER(l.latitude - sl.latitude, 2) + POWER(l.longitude - sl.longitude, 2)\n LIMIT 1\n) AS nearest ON TRUE;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\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 (property_id)\n)\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.staff (\n staff_id character varying(64) NOT NULL, -- unique identifier for the staff member\n property_id character varying(64) NOT NULL, -- FK to properties table (primary property)\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge\n work_email character varying(255) UNIQUE, -- staff member's work email\n work_phone character varying(30),\n hire_date date NOT NULL,\n termination_date date, -- date employment ended (if applicable)\n is_active boolean NOT NULL DEFAULT true, -- currently employed flag\n access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin)\n manager_id character varying(64), -- FK to staff table (self-referencing for supervisor)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (staff_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Show the number of staff members for each property, along with the property name."}, {"role": "assistant", "content": "SELECT p.property_name, COUNT(s.staff_id) AS staff_count\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.staff s ON p.property_id = s.property_id\nGROUP BY p.property_name;"}, {"role": "user", "content": "Only include properties with more than 20 staff members, and order the result by staff count descending."}, {"role": "assistant", "content": "SELECT p.property_name, COUNT(s.staff_id) AS staff_count\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.staff s ON p.property_id = s.property_id\nGROUP BY p.property_name\nHAVING COUNT(s.staff_id) > 20\nORDER BY staff_count DESC;"}]} {"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 ( 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.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 )\nCREATE TABLE government_services.notifications ( notification_id text, 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": "For each notification sent through the 'SMS' channel, list the notification ID, message subject, and the full name of the citizen who received it."}, {"role": "assistant", "content": "SELECT n.notification_id, n.message_subject, c.first_name || ' ' || c.last_name AS full_name\nFROM government_services.notifications n\nJOIN government_services.citizens c ON n.citizen_id = c.citizen_id\nWHERE n.channel = 'SMS';"}]} {"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 social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\n", "conversations": [{"role": "user", "content": "List the last 20 messages that have a media_url, showing message_id, sender_user_id, media_type, and sent_at, ordered by sent_at descending."}, {"role": "assistant", "content": "SELECT message_id,\n sender_user_id,\n media_type,\n sent_at\nFROM social_media.messages\nWHERE media_url IS NOT NULL\nORDER BY sent_at DESC\nLIMIT 20;"}]} {"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 social_media.hashtags (\n hashtag_id character varying(64) NOT NULL, -- unique identifier for the hashtag\n tag_name character varying(100) NOT NULL UNIQUE, -- the actual hashtag text (without '#')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when the hashtag was first used\n PRIMARY KEY (hashtag_id)\n)\n", "conversations": [{"role": "user", "content": "How many hashtags are currently stored in the hashtags table?"}, {"role": "assistant", "content": "SELECT COUNT(*) AS total_hashtags\nFROM social_media.hashtags;"}]} {"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 token_dexpool_info ( pair_address character varying(512) NOT NULL, -- the id of dexpool token_name character varying(100) NOT NULL, -- the name of the token in the dexpool token_symbol character varying(100) NOT NULL, -- the token's symbol chain text, -- the chain that the dexpool resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_6h double precision, -- change in value divided by the absolute price value of the original token price in 6 hours price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours makers_24h double precision, -- the makers of the dex pool in 24 hours volume_24h double precision, -- the trade volume of the dex pool in 24 hours liquidity double precision, -- the liquidity of the dex pool market_cap double precision, -- the market cap of the token trend_rank bigint, -- the rank of token in the dex pool of recent trending, value 1 expresses the most popular token. ,PRIMARY KEY (pair_address, chain) )\n", "conversations": [{"role": "user", "content": "List tokens on 'Arbitrum' with liquidity over 5000000."}, {"role": "assistant", "content": "SELECT * FROM token_dexpool_info WHERE chain = 'Arbitrum' AND liquidity > 5000000;"}, {"role": "user", "content": "Filter those tokens to only include ones with a positive price change in the last 24 hours."}, {"role": "assistant", "content": "SELECT * FROM token_dexpool_info WHERE chain = 'Arbitrum' AND liquidity > 5000000 AND price_change_percentage_24h > 0;"}, {"role": "user", "content": "Order the results by 24-hour trading volume descending and show the top 5 tokens."}, {"role": "assistant", "content": "SELECT * FROM token_dexpool_info WHERE chain = 'Arbitrum' AND liquidity > 5000000 AND price_change_percentage_24h > 0 ORDER BY volume_24h DESC LIMIT 5;"}, {"role": "user", "content": "Also show their market cap and trend rank."}, {"role": "assistant", "content": "SELECT token_symbol, token_name, chain, price, liquidity, price_change_percentage_24h, volume_24h, market_cap, trend_rank FROM token_dexpool_info WHERE chain = 'Arbitrum' AND liquidity > 5000000 AND price_change_percentage_24h > 0 ORDER BY volume_24h DESC LIMIT 5;"}]} {"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.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)\n", "conversations": [{"role": "user", "content": "List the full names of all employees who are currently employed (i.e., have no termination date)."}, {"role": "assistant", "content": "SELECT first_name || ' ' || last_name AS full_name FROM government_services.employees WHERE termination_date IS NULL;"}]} {"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 token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )\nCREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )\nCREATE TABLE token_prices_latest (\n blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract\n address varchar(42) NOT NULL, -- address fields for the functionType in contract\n decimals bigint NOT NULL, -- decimals fields for the functionType in contract\n symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract\n price real NOT NULL, -- price fields for the functionType in contract\n timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract\n)\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(255) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply varchar NOT NULL, amount varchar NOT NULL )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\n", "conversations": [{"role": "user", "content": "Show the total transfer volume and number of transfers for each Avalanche token in the past 7 days, including token tick and its creator."}, {"role": "assistant", "content": "SELECT ta.tick, ti.creator, SUM(ta.amt) AS total_volume, COUNT(*) AS transfer_count\nFROM token_activities ta\nJOIN token_info ti ON ta.tick = ti.tick\nWHERE ta.block_timestamp >= now() - interval '7 days'\nGROUP BY ta.tick, ti.creator;"}, {"role": "user", "content": "Only include tokens where total_volume > 1000 and sort by total_volume descending."}, {"role": "assistant", "content": "SELECT ta.tick, ti.creator, SUM(ta.amt) AS total_volume, COUNT(*) AS transfer_count\nFROM token_activities ta\nJOIN token_info ti ON ta.tick = ti.tick\nWHERE ta.block_timestamp >= now() - interval '7 days'\nGROUP BY ta.tick, ti.creator\nHAVING SUM(ta.amt) > 1000\nORDER BY total_volume DESC;"}, {"role": "user", "content": "Limit the output to the top 5 tokens."}, {"role": "assistant", "content": "SELECT ta.tick, ti.creator, SUM(ta.amt) AS total_volume, COUNT(*) AS transfer_count\nFROM token_activities ta\nJOIN token_info ti ON ta.tick = ti.tick\nWHERE ta.block_timestamp >= now() - interval '7 days'\nGROUP BY ta.tick, ti.creator\nHAVING SUM(ta.amt) > 1000\nORDER BY total_volume DESC\nLIMIT 5;"}]} {"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.market_data (\n data_point_id bigserial NOT NULL, -- auto-incrementing primary key\n security_id character varying(64) NOT NULL, -- identifier for the security\n data_timestamp timestamp NOT NULL, -- timestamp for the data point (e.g., end of day, intraday)\n open_price numeric(19, 8), -- opening price for the period\n high_price numeric(19, 8), -- highest price during the period\n low_price numeric(19, 8), -- lowest price during the period\n close_price numeric(19, 8) NOT NULL, -- closing price for the period\n adjusted_close_price numeric(19, 8), -- closing price adjusted for dividends and splits\n volume bigint, -- trading volume during the period\n source character varying(50), -- source of the market data (e.g., Bloomberg, Refinitiv)\n PRIMARY KEY (data_point_id),\n UNIQUE (security_id, data_timestamp), -- Ensure unique data point per security per time\n FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id)\n)\n", "conversations": [{"role": "user", "content": "List the ticker symbol and security name for all securities that had a volume greater than 100000 on '2023-10-27'."}, {"role": "assistant", "content": "SELECT T2.ticker_symbol, T2.security_name FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.data_timestamp::date = '2023-10-27' AND T1.volume > 100000;"}, {"role": "user", "content": "Also include the close price from that day in the result."}, {"role": "assistant", "content": "SELECT T2.ticker_symbol, T2.security_name, T1.close_price FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.data_timestamp::date = '2023-10-27' AND T1.volume > 100000;"}, {"role": "user", "content": "Filter this list to only show securities belonging to the 'Technology' sector."}, {"role": "assistant", "content": "SELECT T2.ticker_symbol, T2.security_name, T1.close_price FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.data_timestamp::date = '2023-10-27' AND T1.volume > 100000 AND T2.sector = 'Technology';"}]} {"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 project_fundraising_record ( id.text, project_id.text, project_name.text, rounds_name.text, investment_value.numeric, investment_date.text, introduction.text, valuation.numeric )\n", "conversations": [{"role": "user", "content": "Which projects raised funds in January 2022?"}, {"role": "assistant", "content": "SELECT project_name, rounds_name, investment_value, investment_date FROM project_fundraising_record WHERE investment_date >= '2022-01-01' AND investment_date < '2022-02-01';"}, {"role": "user", "content": "Please also show their introductions."}, {"role": "assistant", "content": "SELECT project_name, rounds_name, investment_value, investment_date, introduction FROM project_fundraising_record WHERE investment_date >= '2022-01-01' AND investment_date < '2022-02-01';"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Find all patients who have more than two primary active insurance policies, showing their patient ID and the count of such policies. Also, list the plan names for these policies."}, {"role": "assistant", "content": "SELECT pi.patient_id, COUNT(*) AS active_primary_policy_count, STRING_AGG(ip.plan_name, ', ') AS plan_names\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = TRUE AND (pi.expiration_date IS NULL OR pi.expiration_date > CURRENT_DATE)\nGROUP BY pi.patient_id\nHAVING COUNT(*) > 2;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id.text, first_name.text, last_name.text, specialty.text, license_number.text, phone_number.text, email.text, hospital_affiliation_id.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records (\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)\nCREATE TABLE healthcare.diagnoses (\n diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry\n record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)\n diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)\n code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used\n description text, -- textual description of the diagnosis\n diagnosis_date date NOT NULL, -- date the diagnosis was made\n status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out\n is_chronic boolean DEFAULT false, -- flag for chronic conditions\n PRIMARY KEY (diagnosis_id)\n)\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.prescriptions ( prescription_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, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )\n", "conversations": [{"role": "user", "content": "Count the number of distinct patients enrolled in each insurance plan. Return plan_id and patient_count."}, {"role": "assistant", "content": "SELECT plan_id,\n COUNT(DISTINCT patient_id) AS patient_count\nFROM healthcare.patient_insurance\nGROUP BY plan_id;"}, {"role": "user", "content": "Only include plans with more than 5 patients and sort by patient_count descending."}, {"role": "assistant", "content": "SELECT plan_id,\n COUNT(DISTINCT patient_id) AS patient_count\nFROM healthcare.patient_insurance\nGROUP BY plan_id\nHAVING COUNT(DISTINCT patient_id) > 5\nORDER BY patient_count DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text PRIMARY KEY, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.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.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "List the subscriber names from patient insurance entries where the group number is not provided (is null)."}, {"role": "assistant", "content": "SELECT subscriber_name FROM healthcare.patient_insurance WHERE group_number IS NULL;"}, {"role": "user", "content": "From that list, only show subscribers whose name starts with 'J'."}, {"role": "assistant", "content": "SELECT subscriber_name FROM healthcare.patient_insurance WHERE group_number IS NULL AND subscriber_name LIKE 'J%';"}]} {"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 text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\nCREATE TABLE healthcare.diagnoses (\n diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry\n record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)\n diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)\n code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used\n description text, -- textual description of the diagnosis\n diagnosis_date date NOT NULL, -- date the diagnosis was made\n status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out\n is_chronic boolean DEFAULT false, -- flag for chronic conditions\n PRIMARY KEY (diagnosis_id)\n)\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )\n", "conversations": [{"role": "user", "content": "Show the name of each insurance plan and the total number of patients whose primary insurance policy for that plan is currently active. Include only plans that have at least one such patient."}, {"role": "assistant", "content": "SELECT T1.plan_name, COUNT(DISTINCT T2.patient_id) FROM healthcare.insurance_plans AS T1 JOIN healthcare.patient_insurance AS T2 ON T1.plan_id = T2.plan_id WHERE T2.is_primary = TRUE AND (T2.effective_date <= CURRENT_DATE AND (T2.expiration_date IS NULL OR T2.expiration_date >= CURRENT_DATE)) GROUP BY T1.plan_name HAVING COUNT(DISTINCT T2.patient_id) > 0;"}]} {"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\n// db.createCollection('stations')\n// Optional: Add unique index: db.stations.createIndex({ station_id: 1 }, { unique: true })\n{\n _id: ObjectId(), // Auto-generated MongoDB ID\n station_id: \"station_xyz\", // String (unique identifier, corresponds to SQL PK)\n station_name: \"Grand Central Terminal\", // String\n city: \"New York\", // String\n state_province: \"NY\", // String\n country_code: \"USA\", // String\n address: \"89 E 42nd St, New York, NY 10017\", // String\n timezone: \"America/New_York\", // String\n number_of_platforms: 44, // Int32\n created_at: ISODate(\"2023-01-15T10:00:00Z\"), // Date\n last_updated_at: ISODate(\"2023-10-28T15:30:00Z\") // Date\n}\n// db.createCollection('trains')\n// Optional: db.trains.createIndex({ train_id: 1 }, { unique: true })\n// Optional: db.trains.createIndex({ train_number: 1 }, { unique: true })\n{\n _id: ObjectId(),\n train_id: \"train_789\", // String (unique)\n train_number: \"Acela 2151\", // String (unique)\n model: \"Siemens Velaro\", // String\n manufacturer: \"Siemens\", // String\n year_manufactured: 2010, // Int32\n capacity: 304, // Int32\n status: \"Active\", // String ('Active', 'Maintenance', 'Retired')\n last_maintenance_date: ISODate(\"2023-09-15\"), // Date (Date part only relevant)\n next_maintenance_date: ISODate(\"2024-03-15\") // Date (Date part only relevant)\n}\n// db.createCollection('bookings')\n// Optional: db.bookings.createIndex({ booking_id: 1 }, { unique: true })\n// Optional: db.bookings.createIndex({ passenger_id: 1 })\n// Optional: db.bookings.createIndex({ schedule_id: 1 })\n{\n _id: ObjectId(),\n booking_id: \"book_zyx\", // String (unique)\n passenger_id: \"pass_pqr\", // String (references passengers.passenger_id)\n schedule_id: \"sched_1122\", // String (references schedules.schedule_id)\n booking_datetime: ISODate(\"2024-04-15T14:30:00Z\"), // Date\n status: \"Confirmed\", // String ('Confirmed', 'Cancelled', 'Pending')\n total_price: 150.75, // Decimal128 or Double\n currency_code: \"USD\", // String\n special_requests: \"Wheelchair assistance required at origin\" // String\n}\n// db.createCollection('staff')\n// Optional: db.staff.createIndex({ staff_id: 1 }, { unique: true })\n// Optional: db.staff.createIndex({ employee_number: 1 }, { unique: true })\n// Optional: db.staff.createIndex({ contact_email: 1 }, { unique: true, sparse: true })\n{\n _id: ObjectId(),\n staff_id: \"staff_mno\", // String (unique)\n first_name: \"Bob\", // String\n last_name: \"Jones\", // String\n role: \"Conductor\", // String\n primary_station_id: null, // String (references stations.station_id, nullable)\n employee_number: \"E12345\", // String (unique)\n hire_date: ISODate(\"2018-06-01\"), // Date\n contact_email: \"bob.jones@example-rail.com\", // String (unique, sparse)\n contact_phone: \"+15559876543\", // String\n is_active: true // Boolean\n}\n", "conversations": [{"role": "user", "content": "Can you help me count the total number of active staff members in the database?"}, {"role": "assistant", "content": "db.staff.countDocuments({ is_active: true });"}]} {"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 web3.contracts ( contract_id.text, address.text, abi.text, bytecode.text, deployer_address.text, deployed_at.timestamp, network_id.text, status.text )\nCREATE TABLE web3.events (\n event_id character varying(64) NOT NULL, -- unique identifier for the event\n contract_id character varying(64) NOT NULL, -- identifier of the contract emitting the event\n event_name character varying(128) NOT NULL, -- name of the event\n data text NOT NULL, -- data payload of the event\n emitted_at timestamp NOT NULL, -- time when the event was emitted\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction that triggered the event\n log_index integer NOT NULL, -- index of the event log in the transaction\n PRIMARY KEY (event_id)\n)\nCREATE TABLE web3.tokens ( token_id text PRIMARY KEY, contract_address text, token_name text, token_symbol text, decimals int, total_supply numeric )\nCREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )\nCREATE TABLE web3.users ( user_id text, username text, email text, password_hash text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Find the contract ID, address, and deployer address for all contracts that have not emitted any events."}, {"role": "assistant", "content": "SELECT c.contract_id, c.address, c.deployer_address FROM web3.contracts AS c LEFT JOIN web3.events AS e ON c.contract_id = e.contract_id WHERE e.event_id IS NULL;"}]} {"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 transportation.trips (\n trip_id character varying(64) NOT NULL, -- unique identifier for a specific trip instance\n route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips)\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used\n driver_id character varying(64) NOT NULL, -- identifier of the driver operating\n scheduled_departure timestamp with time zone NOT NULL, -- planned departure time\n actual_departure timestamp with time zone, -- actual departure time\n scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time\n actual_arrival timestamp with time zone, -- actual arrival time\n origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin)\n destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination)\n status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled\n passenger_count integer, -- number of passengers (if applicable)\n cargo_manifest_id character varying(64), -- link to cargo details (if applicable)\n PRIMARY KEY (trip_id)\n)\nCREATE TABLE transportation.passengers (\n passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger\n first_name character varying(128) NOT NULL, -- passenger's first name\n last_name character varying(128) NOT NULL, -- passenger's last name\n email character varying(128) UNIQUE, -- email address\n phone_number character varying(32) UNIQUE, -- phone number\n date_of_birth date, -- passenger's date of birth\n loyalty_program_id character varying(64), -- identifier for loyalty program membership\n created_at timestamp with time zone NOT NULL, -- time when the passenger record was created\n PRIMARY KEY (passenger_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve trip_id and passenger full names for all trips where the passenger record was created before the scheduled departure."}, {"role": "assistant", "content": "SELECT t.trip_id, p.first_name || ' ' || p.last_name AS passenger_name\nFROM transportation.trips t\nJOIN transportation.passengers p\n ON p.created_at < t.scheduled_departure;"}, {"role": "user", "content": "Filter the results to only include trips with passenger_count greater than 5."}, {"role": "assistant", "content": "SELECT t.trip_id, t.passenger_count, p.first_name || ' ' || p.last_name AS passenger_name\nFROM transportation.trips t\nJOIN transportation.passengers p\n ON p.created_at < t.scheduled_departure\nWHERE t.passenger_count > 5;"}, {"role": "user", "content": "Also sort the output by passenger_count descending and limit to the top 10 records."}, {"role": "assistant", "content": "SELECT t.trip_id, t.passenger_count, p.first_name || ' ' || p.last_name AS passenger_name\nFROM transportation.trips t\nJOIN transportation.passengers p\n ON p.created_at < t.scheduled_departure\nWHERE t.passenger_count > 5\nORDER BY t.passenger_count DESC\nLIMIT 10;"}]} {"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 social_media.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )\n", "conversations": [{"role": "user", "content": "Please provide each follow relationship, including the follower's username, the followed user's username, and the follow creation timestamp."}, {"role": "assistant", "content": "SELECT\n u1.username AS follower_username,\n u2.username AS following_username,\n f.created_at AS follow_date\nFROM\n social_media.follows f\n JOIN social_media.users u1 ON f.follower_user_id = u1.user_id\n JOIN social_media.users u2 ON f.following_user_id = u2.user_id;"}, {"role": "user", "content": "Actually, I only want follows from the last month and order by the follow date descending."}, {"role": "assistant", "content": "SELECT\n u1.username AS follower_username,\n u2.username AS following_username,\n f.created_at AS follow_date\nFROM\n social_media.follows f\n JOIN social_media.users u1 ON f.follower_user_id = u1.user_id\n JOIN social_media.users u2 ON f.following_user_id = u2.user_id\nWHERE\n f.created_at >= now() - INTERVAL '1 month'\nORDER BY\n f.created_at DESC;"}]} {"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 social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )\nCREATE TABLE social_media.comments ( comment_id text PRIMARY KEY, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.notifications ( notification_id text, recipient_user_id text, sender_user_id text, notification_type text, target_entity_id text, target_entity_type text, created_at timestamp, read_at timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "For hashtag ID 'H789', get each post ID and the number of distinct comments that have been made on those posts."}, {"role": "assistant", "content": "SELECT ph.post_id,\n COUNT(DISTINCT c.comment_id) AS comment_count\nFROM social_media.post_hashtags ph\nJOIN social_media.comments c ON ph.post_id = c.post_id\nWHERE ph.hashtag_id = 'H789'\nGROUP BY ph.post_id;"}]} {"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 project_fundraising_record ( id character varying(32) NOT NULL, -- fundraising record id project_id character varying(32) NOT NULL, -- the invested project's id project_name character varying(128) NOT NULL, -- name of the invested project rounds_name character varying(32), -- name of the fundraising round investment_value numeric(38,14), -- amount of the fundraising in USD investment_date character varying(128), -- the date of the investment happened introduction character varying(128), -- the introduction of the invested project valuation numeric(38,14), -- the valuation of the project in USD when invested )\nCREATE TABLE token_basic_info ( coin_id text, token_name text, token_symbol text, token_address text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, highest_price_24h numeric, lowest_price_24h numeric, market_cap numeric, market_cap_rank numeric, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank numeric )\nCREATE TABLE token_dexpool_info ( pair_address text, token_name text, token_symbol text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_6h numeric, price_change_percentage_24h numeric, makers_24h numeric, volume_24h numeric, liquidity numeric, market_cap numeric, trend_rank numeric )\n \"CREATE TABLE cex_token_balance (\",\n \"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp\",\n \"chain character varying(128) NOT NULL, -- the chain that the token resides\",\n \"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX\",\n \"exchange character varying(512) NOT NULL, -- a centralized exchange name\",\n \"token_address character varying(128) NOT NULL, -- token contract address\",\n \"token_symbol character varying(512), --token symbol\",\n \"balance numeric(38,10), -- token balance\",\n \"usd_value numeric(38,14), -- value of the token held in USD\",\n \"price double precision, --price of the token in USD\",\n \",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));\"\n\n", "conversations": [{"role": "user", "content": "Calculate the average 24-hour trading volume for all tokens listed in DEX pools on the 'BSC' chain."}, {"role": "assistant", "content": "SELECT AVG(volume_24h) FROM token_dexpool_info WHERE chain = 'BSC'"}]} {"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.games (\n game_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game\n title character varying(200) NOT NULL, -- official title of the game\n developer_id uuid NOT NULL, -- FK linking to the developers table\n publisher_id uuid, -- FK linking to a potential publishers table (optional)\n genre character varying(100), -- primary genre (e.g., RPG, FPS, Strategy)\n release_date date, -- official release date\n description text, -- short description or synopsis of the game\n platform character varying(50) NOT NULL, -- primary platform (e.g., PC, PlayStation 5, Xbox Series X, Mobile)\n engine character varying(100), -- game engine used (e.g., Unreal Engine 5, Unity)\n website character varying(255), -- official website URL\n PRIMARY KEY (game_id)\n -- FOREIGN KEY (developer_id) REFERENCES gaming_technology.developers(developer_id) -- Example FK constraint\n)\n", "conversations": [{"role": "user", "content": "List pairs of games that share the same publisher but belong to different genres, showing both titles and genres."}, {"role": "assistant", "content": "SELECT g1.game_id AS game1_id,\n g1.title AS title1,\n g1.genre AS genre1,\n g2.game_id AS game2_id,\n g2.title AS title2,\n g2.genre AS genre2\nFROM gaming_technology.games g1\nJOIN gaming_technology.games g2\n ON g1.publisher_id = g2.publisher_id\n AND g1.game_id < g2.game_id\n AND g1.genre <> g2.genre;"}, {"role": "user", "content": "Exclude any pairs where the publisher_id is NULL."}, {"role": "assistant", "content": "SELECT g1.game_id AS game1_id,\n g1.title AS title1,\n g1.genre AS genre1,\n g2.game_id AS game2_id,\n g2.title AS title2,\n g2.genre AS genre2\nFROM gaming_technology.games g1\nJOIN gaming_technology.games g2\n ON g1.publisher_id = g2.publisher_id\n AND g1.game_id < g2.game_id\n AND g1.genre <> g2.genre\nWHERE g1.publisher_id IS NOT NULL;"}, {"role": "user", "content": "Further restrict to game pairs released within one year of each other."}, {"role": "assistant", "content": "SELECT g1.game_id AS game1_id,\n g1.title AS title1,\n g1.release_date AS release1,\n g2.game_id AS game2_id,\n g2.title AS title2,\n g2.release_date AS release2\nFROM gaming_technology.games g1\nJOIN gaming_technology.games g2\n ON g1.publisher_id = g2.publisher_id\n AND g1.game_id < g2.game_id\n AND ABS(EXTRACT(YEAR FROM AGE(g1.release_date, g2.release_date))) <= 1\nWHERE g1.publisher_id IS NOT NULL;"}, {"role": "user", "content": "Order the final result by publisher_id and then by the earliest release_date among each pair."}, {"role": "assistant", "content": "SELECT g1.publisher_id,\n g1.game_id AS game1_id,\n g1.title AS title1,\n g1.release_date AS release1,\n g2.game_id AS game2_id,\n g2.title AS title2,\n g2.release_date AS release2\nFROM gaming_technology.games g1\nJOIN gaming_technology.games g2\n ON g1.publisher_id = g2.publisher_id\n AND g1.game_id < g2.game_id\n AND ABS(EXTRACT(YEAR FROM AGE(g1.release_date, g2.release_date))) <= 1\nWHERE g1.publisher_id IS NOT NULL\nORDER BY g1.publisher_id,\n LEAST(g1.release_date, g2.release_date) ASC;"}]} {"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.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "List all patients who have insurance plans with group numbers, showing their patient IDs and the count of such plans per patient."}, {"role": "assistant", "content": "SELECT patient_id, COUNT(*) AS plan_count FROM healthcare.patient_insurance WHERE group_number IS NOT NULL GROUP BY patient_id;"}, {"role": "user", "content": "Actually, I only need patients who have more than 2 such plans."}, {"role": "assistant", "content": "SELECT patient_id, COUNT(*) AS plan_count FROM healthcare.patient_insurance WHERE group_number IS NOT NULL GROUP BY patient_id HAVING COUNT(*) > 2;"}, {"role": "user", "content": "Can you also include the earliest effective date among these plans for each patient?"}, {"role": "assistant", "content": "SELECT patient_id, COUNT(*) AS plan_count, MIN(effective_date) AS earliest_effective_date FROM healthcare.patient_insurance WHERE group_number IS NOT NULL GROUP BY patient_id HAVING COUNT(*) > 2;"}]} {"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 social_media.posts ( post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, visibility character varying(20) NOT NULL DEFAULT 'public', location_lat numeric(9,6), location_lon numeric(9,6), PRIMARY KEY (post_id) )\nCREATE TABLE social_media.comments (\n comment_id character varying(64) NOT NULL, -- unique identifier for the comment\n post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)\n user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)\n parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)\n content text NOT NULL, -- textual content of the comment\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit\n PRIMARY KEY (comment_id)\n)\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.post_hashtags (\n post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link\n post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id)\n hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id)\n PRIMARY KEY (post_hashtag_id),\n CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post\n)\nCREATE TABLE social_media.messages ( message_id text PRIMARY KEY, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp )\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.user_settings ( setting_id text, user_id text, theme text, email_notifications_enabled boolean, push_notifications_enabled boolean, private_profile boolean, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Find posts that have been liked by users the author of the post is following. List the post_id and the user_id of the post author."}, {"role": "assistant", "content": "SELECT p.post_id, p.user_id AS post_author_user_id FROM social_media.posts AS p JOIN social_media.likes AS l ON p.post_id = l.post_id JOIN social_media.follows AS f ON f.follower_user_id = p.user_id AND f.following_user_id = l.user_id;"}, {"role": "user", "content": "Can you refine this to only include posts where the author started following the user *before* the post was created?"}, {"role": "assistant", "content": "SELECT p.post_id, p.user_id AS post_author_user_id FROM social_media.posts AS p JOIN social_media.likes AS l ON p.post_id = l.post_id JOIN social_media.follows AS f ON f.follower_user_id = p.user_id AND f.following_user_id = l.user_id WHERE f.created_at < p.created_at;"}]} {"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.accounts ( account_id.text, customer_id.text, account_number.text, account_type.text, balance.numeric, currency.text, opened_date.date, status.text, interest_rate.numeric, last_updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Summarize the total balance and average interest rate for each account type."}, {"role": "assistant", "content": "SELECT account_type, SUM(balance) AS total_balance, AVG(interest_rate) AS average_interest_rate FROM financial_services.accounts GROUP BY account_type"}, {"role": "user", "content": "Only include account types where the total balance is greater than 1000000."}, {"role": "assistant", "content": "SELECT account_type, SUM(balance) AS total_balance, AVG(interest_rate) AS average_interest_rate FROM financial_services.accounts GROUP BY account_type HAVING SUM(balance) > 1000000"}, {"role": "user", "content": "Also, include the total count of accounts for each type in the result."}, {"role": "assistant", "content": "SELECT account_type, COUNT(*) AS total_accounts, SUM(balance) AS total_balance, AVG(interest_rate) AS average_interest_rate FROM financial_services.accounts GROUP BY account_type HAVING SUM(balance) > 1000000"}, {"role": "user", "content": "Finally, sort the results by the total balance in descending order."}, {"role": "assistant", "content": "SELECT account_type, COUNT(*) AS total_accounts, SUM(balance) AS total_balance, AVG(interest_rate) AS average_interest_rate FROM financial_services.accounts GROUP BY account_type HAVING SUM(balance) > 1000000 ORDER BY total_balance DESC"}]} {"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 web3.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\n", "conversations": [{"role": "user", "content": "How many users registered in each month?"}, {"role": "assistant", "content": "SELECT date_trunc('month', created_at) AS month,\n COUNT(*) AS registrations\nFROM web3.users\nGROUP BY month\nORDER BY month;"}, {"role": "user", "content": "Actually, show only those months where registrations exceed 10."}, {"role": "assistant", "content": "SELECT date_trunc('month', created_at) AS month,\n COUNT(*) AS registrations\nFROM web3.users\nGROUP BY month\nHAVING COUNT(*) > 10\nORDER BY month;"}]} {"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.accounts ( account_id text PRIMARY KEY, customer_id text, account_number text, account_type text, balance numeric, currency text, opened_date date, status text, interest_rate numeric, last_updated_at timestamp )\nCREATE TABLE financial_services.transactions ( transaction_id text PRIMARY KEY, account_id text, related_account_id text, transaction_type text, amount numeric, currency text, transaction_date timestamp, effective_date date, description text, status text, reference_number text )\nCREATE TABLE financial_services.trades ( trade_id text PRIMARY KEY, account_id text, security_id text, order_id text, trade_type text, quantity numeric, price_per_unit numeric, total_amount numeric, commission numeric, trade_timestamp timestamp, settlement_date date, status text, execution_venue text )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial PRIMARY KEY, security_id text, data_timestamp timestamp, open_price numeric, high_price numeric, low_price numeric, close_price numeric, adjusted_close_price numeric, volume bigint, source text )\nCREATE TABLE financial_services.employees ( employee_id text PRIMARY KEY, first_name text, last_name text, job_title text, department text, branch_id text, email text, phone_extension text, hire_date date, termination_date date, manager_id text, status text )\n", "conversations": [{"role": "user", "content": "Can you provide a list of all trades in the past 90 days, including the security_id, account_id, trade_type, quantity, total_amount, and the current balance of the involved account?"}, {"role": "assistant", "content": "SELECT t.trade_id, t.security_id, t.account_id, t.trade_type, t.quantity, t.total_amount, a.balance\nFROM financial_services.trades t\nJOIN financial_services.accounts a ON t.account_id = a.account_id\nWHERE t.trade_timestamp >= NOW() - INTERVAL '90 days';"}, {"role": "user", "content": "Please also include the execution venue for each trade in the result."}, {"role": "assistant", "content": "SELECT t.trade_id, t.security_id, t.account_id, t.trade_type, t.quantity, t.total_amount, t.execution_venue, a.balance\nFROM financial_services.trades t\nJOIN financial_services.accounts a ON t.account_id = a.account_id\nWHERE t.trade_timestamp >= NOW() - INTERVAL '90 days';"}, {"role": "user", "content": "Now, only show trades where the total_amount is above 10000."}, {"role": "assistant", "content": "SELECT t.trade_id, t.security_id, t.account_id, t.trade_type, t.quantity, t.total_amount, t.execution_venue, a.balance\nFROM financial_services.trades t\nJOIN financial_services.accounts a ON t.account_id = a.account_id\nWHERE t.trade_timestamp >= NOW() - INTERVAL '90 days'\n AND t.total_amount > 10000;"}, {"role": "user", "content": "Finally, order the output by trade_timestamp descending."}, {"role": "assistant", "content": "SELECT t.trade_id, t.security_id, t.account_id, t.trade_type, t.quantity, t.total_amount, t.execution_venue, a.balance\nFROM financial_services.trades t\nJOIN financial_services.accounts a ON t.account_id = a.account_id\nWHERE t.trade_timestamp >= NOW() - INTERVAL '90 days'\n AND t.total_amount > 10000\nORDER BY t.trade_timestamp DESC;"}]} {"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.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)\n", "conversations": [{"role": "user", "content": "List the first name, last name, and job title of each employee, along with the job title of their manager."}, {"role": "assistant", "content": "SELECT e.first_name AS employee_first_name, e.last_name AS employee_last_name, e.job_title AS employee_job_title, m.job_title AS manager_job_title FROM government_services.employees AS e LEFT JOIN government_services.employees AS m ON e.manager_employee_id = m.employee_id;"}]} {"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. 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 train_station_management.trains ( train_id.text, train_number.text, model.text, manufacturer.text, year_manufactured.integer, capacity.integer, status.text, last_maintenance_date.date, next_maintenance_date.date )\n", "conversations": [{"role": "user", "content": "What is the average speed of train number T9876 during its last journey?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide information on the average speed of train number T9876 during its last journey. The data in the trains table does not include details about travel speed or journey-specific performance metrics."}]} {"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 transportation.trips ( trip_id text, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count integer, cargo_manifest_id text )\n", "conversations": [{"role": "user", "content": "List all trips with their trip_id, vehicle_id, and the corresponding origin_location_id and destination_location_id, but only where the origin and destination are not the same."}, {"role": "assistant", "content": "SELECT trip_id, vehicle_id, origin_location_id, destination_location_id FROM transportation.trips WHERE origin_location_id <> destination_location_id;"}]} {"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.applications ( application_id text PRIMARY KEY, 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 )\n", "conversations": [{"role": "user", "content": "List the application ID, submitted date, and assigned employee ID for all applications that are currently in 'Processing' status and were submitted before January 1st, 2024."}, {"role": "assistant", "content": "SELECT application_id, submitted_at, assigned_employee_id FROM government_services.applications WHERE status = 'Processing' AND submitted_at < '2024-01-01';"}]} {"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 social_media.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(50) NOT NULL UNIQUE, -- user's unique handle\n email character varying(128) NOT NULL UNIQUE, -- user's email address\n password_hash text NOT NULL, -- hashed password\n full_name character varying(100), -- user's full name\n profile_picture_url text, -- URL to the profile picture\n bio text, -- short user biography\n location character varying(100), -- user's location\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update\n is_verified boolean NOT NULL DEFAULT false, -- verification status\n PRIMARY KEY (user_id)\n)\n", "conversations": [{"role": "user", "content": "Show the content of comments and the content of the posts they belong to, for comments made by users whose location is 'New York'. Also include the username of the commenter."}, {"role": "assistant", "content": "SELECT c.content AS comment_content, p.content AS post_content, u.username FROM comments c JOIN posts p ON c.post_id = p.post_id JOIN social_media.users u ON c.user_id = u.user_id WHERE u.location = 'New York';"}, {"role": "user", "content": "Additionally, only include comments made by users who are verified."}, {"role": "assistant", "content": "SELECT c.content AS comment_content, p.content AS post_content, u.username FROM comments c JOIN posts p ON c.post_id = p.post_id JOIN social_media.users u ON c.user_id = u.user_id WHERE u.location = 'New York' AND u.is_verified = true;"}]} {"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 transportation.vehicles (\n vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle\n license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate\n vin character varying(17) UNIQUE, -- vehicle identification number\n make character varying(64) NOT NULL, -- manufacturer of the vehicle\n model character varying(64) NOT NULL, -- model of the vehicle\n year integer NOT NULL, -- manufacturing year\n type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)\n capacity integer, -- passenger or cargo capacity\n fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen\n status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned\n depot_id character varying(64), -- identifier of the home depot/base\n acquisition_date date, -- date the vehicle was acquired\n PRIMARY KEY (vehicle_id)\n)\nCREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text )\nCREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\n", "conversations": [{"role": "user", "content": "For each route, show its route number, distance in kilometers, and the total number of trips that have used that route."}, {"role": "assistant", "content": "SELECT r.route_number, r.distance_km, COUNT(t.trip_id) AS trip_count\nFROM transportation.routes r\nLEFT JOIN transportation.trips t ON r.route_id = t.route_id\nGROUP BY r.route_number, r.distance_km;"}]} {"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 )\nCREATE TABLE financial_services.accounts ( account_id.text, customer_id.text, account_number.text, account_type.text, balance.numeric, currency.text, opened_date.date, status.text, interest_rate.numeric, last_updated_at.timestamp )\nCREATE TABLE financial_services.transactions ( transaction_id text, account_id text, related_account_id text, transaction_type text, amount numeric, currency text, transaction_date timestamp, effective_date date, description text, status text, reference_number text )\nCREATE TABLE financial_services.securities ( security_id.text, ticker_symbol.text, isin_code.text, cusip_code.text, security_name.text, security_type.text, exchange.text, currency.text, issuer_name.text, sector.text, last_updated.timestamp )\nCREATE TABLE financial_services.trades ( trade_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, security_id character varying(64) NOT NULL, order_id character varying(64), trade_type character varying(10) NOT NULL, quantity numeric(19, 8) NOT NULL, price_per_unit numeric(19, 8) NOT NULL, total_amount numeric(19, 4) NOT NULL, commission numeric(10, 4), trade_timestamp timestamp NOT NULL, settlement_date date, status character varying(32) NOT NULL, execution_venue character varying(100), PRIMARY KEY (trade_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.loans ( loan_id text, account_id text, loan_type text, principal_amount numeric, current_principal_balance numeric, interest_rate numeric, term_months integer, origination_date date, maturity_date date, monthly_payment numeric, collateral_description text, status text )\n", "conversations": [{"role": "user", "content": "Show me the total number of customers and their average age grouped by city."}, {"role": "assistant", "content": "SELECT city, COUNT(customer_id) AS total_customers, AVG(EXTRACT(YEAR FROM NOW()) - EXTRACT(YEAR FROM date_of_birth)) AS average_age FROM financial_services.customers WHERE city IS NOT NULL GROUP BY city"}, {"role": "user", "content": "Only include customers with status 'Active'."}, {"role": "assistant", "content": "SELECT city, COUNT(customer_id) AS total_customers, AVG(EXTRACT(YEAR FROM NOW()) - EXTRACT(YEAR FROM date_of_birth)) AS average_age FROM financial_services.customers WHERE city IS NOT NULL AND status = 'Active' GROUP BY city"}]} {"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 )\n", "conversations": [{"role": "user", "content": "Find all pairs of citizens who share the same last name but have different dates of birth. Display both full names, the shared last name, and each date of birth."}, {"role": "assistant", "content": "SELECT\n c1.first_name || ' ' || c1.last_name AS citizen1_name,\n c2.first_name || ' ' || c2.last_name AS citizen2_name,\n c1.last_name AS shared_last_name,\n c1.date_of_birth AS dob1,\n c2.date_of_birth AS dob2\nFROM government_services.citizens c1\nJOIN government_services.citizens c2\n ON c1.last_name = c2.last_name\n AND c1.citizen_id < c2.citizen_id\n AND c1.date_of_birth <> c2.date_of_birth;"}]} {"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.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\n", "conversations": [{"role": "user", "content": "List the first name, last name, email, and the name of the law firm for all lawyers."}, {"role": "assistant", "content": "SELECT T1.first_name , T1.last_name , T1.email , T2.firm_name FROM legal_services.lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id"}]} {"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 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, ssn_hash character varying(128), address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state character varying(50) NOT NULL, zip_code character varying(20) NOT NULL, country character varying(50) NOT NULL DEFAULT 'USA', phone_number character varying(30), email character varying(128) UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, status character varying(20) NOT NULL DEFAULT 'Active', PRIMARY KEY (customer_id) )\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.insurance_products ( product_id character varying(64) NOT NULL, product_name character varying(150) NOT NULL, product_type character varying(50) NOT NULL, description text, base_premium numeric(10, 2) NOT NULL, coverage_details text, underwriting_rules text, is_active boolean NOT NULL DEFAULT true, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, PRIMARY KEY (product_id) )\nCREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, amount_paid numeric(12, 2) NOT NULL, payment_method character varying(50), transaction_reference character varying(128) UNIQUE, due_date date, payment_period_start date, payment_period_end date, status character varying(30) NOT NULL DEFAULT 'Completed', PRIMARY KEY (payment_id) )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, relationship character varying(50) NOT NULL, percentage_share numeric(5, 2) NOT NULL CHECK (percentage_share > 0 AND percentage_share <= 100), contact_info text, added_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (beneficiary_id), UNIQUE (policy_id, customer_id) )\n", "conversations": [{"role": "user", "content": "Show me all customers who have purchased policies for insurance products of type 'health', including their full name, policy number, and the insurance product's name."}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name, c.last_name, p.policy_number, ip.product_name\nFROM insurance.customers c\nJOIN insurance.policies p ON p.customer_id = c.customer_id\nJOIN insurance.insurance_products ip ON ip.product_id = p.product_id\nWHERE ip.product_type = 'health';"}, {"role": "user", "content": "Add the premium amount of the policy and the product's base premium to the result."}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name, c.last_name, p.policy_number, ip.product_name, p.premium_amount, ip.base_premium\nFROM insurance.customers c\nJOIN insurance.policies p ON p.customer_id = c.customer_id\nJOIN insurance.insurance_products ip ON ip.product_id = p.product_id\nWHERE ip.product_type = 'health';"}, {"role": "user", "content": "Actually, only include policies that are currently active and have a premium amount greater than the base premium of the product."}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name, c.last_name, p.policy_number, ip.product_name, p.premium_amount, ip.base_premium\nFROM insurance.customers c\nJOIN insurance.policies p ON p.customer_id = c.customer_id\nJOIN insurance.insurance_products ip ON ip.product_id = p.product_id\nWHERE ip.product_type = 'health'\n AND p.status = 'active'\n AND p.premium_amount > ip.base_premium;"}]} {"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.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me all rooms on floor 4 or above together with their room number, features, and current status."}, {"role": "assistant", "content": "SELECT room_id, room_number, features, status\nFROM hospitality_technology.rooms\nWHERE floor >= 4;"}, {"role": "user", "content": "Only include rooms that are marked as non-smoking and sort the results by floor descending."}, {"role": "assistant", "content": "SELECT room_id, room_number, features, status, floor\nFROM hospitality_technology.rooms\nWHERE floor >= 4 AND is_smoking = FALSE\nORDER BY floor DESC;"}]} {"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\nUse Hashes. Key pattern: 'inv:'. Example: HSET inv:INVREC500 component_id \"component:WINGBOLT\" quantity 5000 location_warehouse \"WH3\" batch_number \"BCH778899\" ... Consider Sorted Set by expiry date: ZADD component_expiry: .\n", "conversations": [{"role": "user", "content": "Can you help me retrieve the inventory details for a specific component ID, including the quantity and warehouse location?"}, {"role": "assistant", "content": "HGETALL inv:"}, {"role": "user", "content": "Can you also include the batch number for that inventory record?"}, {"role": "assistant", "content": "HGETALL inv:"}, {"role": "user", "content": "If I want to check the expiry date for this component, how can I retrieve that information?"}, {"role": "assistant", "content": "ZRANGE component_expiry: 0 -1 WITHSCORES"}, {"role": "user", "content": "Can you filter the results to show only inventory records with an expiry date after a specific timestamp?"}, {"role": "assistant", "content": "ZRANGEBYSCORE component_expiry: +inf WITHSCORES"}]} {"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 social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean )\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.messages ( message_id.text, conversation_id.text, sender_user_id.text, content.text, media_url.text, media_type.text, sent_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Get the five most recent public posts that have media_type = 'video', showing post_id, created_at, and the author's username."}, {"role": "assistant", "content": "SELECT\n p.post_id,\n p.created_at,\n u.username\nFROM social_media.posts p\nJOIN social_media.users u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.media_type = 'video'\nORDER BY p.created_at DESC\nLIMIT 5;"}, {"role": "user", "content": "Actually, filter to only include posts made by verified users."}, {"role": "assistant", "content": "SELECT\n p.post_id,\n p.created_at,\n u.username\nFROM social_media.posts p\nJOIN social_media.users u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.media_type = 'video'\n AND u.is_verified = TRUE\nORDER BY p.created_at DESC\nLIMIT 5;"}]} {"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.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": "Find all review comments that have a staff response, showing the comment and the staff response date."}, {"role": "assistant", "content": "SELECT comment, response_date FROM reviews WHERE response_date IS NOT NULL;"}, {"role": "user", "content": "Now, also include the name of the staff member who responded."}, {"role": "assistant", "content": "SELECT T1.comment, T1.response_date, T2.first_name, T2.last_name FROM reviews AS T1 JOIN staff AS T2 ON T1.response_staff_id = T2.staff_id WHERE T1.response_date IS NOT NULL;"}, {"role": "user", "content": "Further filter this list to only show responses made more than 24 hours after the review was submitted, and include the review date and the reservation ID."}, {"role": "assistant", "content": "SELECT T1.comment, T1.response_date, T2.first_name, T2.last_name, T1.review_date, T1.reservation_id FROM reviews AS T1 JOIN staff AS T2 ON T1.response_staff_id = T2.staff_id WHERE T1.response_date IS NOT NULL AND T1.response_date > T1.review_date + INTERVAL '24 hours';"}]} {"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.transactions ( transaction_id.text, account_id.text, related_account_id.text, transaction_type.text, amount.numeric, currency.text, transaction_date.timestamp, effective_date.date, description.text, status.text, reference_number.text )\nCREATE TABLE financial_services.market_data ( data_point_id.bigint, security_id.text, data_timestamp.timestamp, open_price.numeric, high_price.numeric, low_price.numeric, close_price.numeric, adjusted_close_price.numeric, volume.bigint, source.text )\n", "conversations": [{"role": "user", "content": "Show me the number of market data points and average adjusted close price per source."}, {"role": "assistant", "content": "SELECT source, COUNT(*) AS data_point_count, AVG(adjusted_close_price) AS avg_adjusted_close_price\nFROM financial_services.market_data\nGROUP BY source\nORDER BY source ASC;"}, {"role": "user", "content": "Filter the result to only include sources where the average adjusted close price is above 50."}, {"role": "assistant", "content": "SELECT source, COUNT(*) AS data_point_count, AVG(adjusted_close_price) AS avg_adjusted_close_price\nFROM financial_services.market_data\nGROUP BY source\nHAVING AVG(adjusted_close_price) > 50\nORDER BY source ASC;"}, {"role": "user", "content": "Also, only consider market data from the past 90 days."}, {"role": "assistant", "content": "SELECT source, COUNT(*) AS data_point_count, AVG(adjusted_close_price) AS avg_adjusted_close_price\nFROM financial_services.market_data\nWHERE data_timestamp >= CURRENT_DATE - INTERVAL '90 days'\nGROUP BY source\nHAVING AVG(adjusted_close_price) > 50\nORDER BY source ASC;"}]} {"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.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List reservations, including the reservation ID, check-in date, check-out date, property name, room type name, and room type base rate, for reservations with 3 or more adults."}, {"role": "assistant", "content": "SELECT T1.reservation_id, T1.check_in_date, T1.check_out_date, T2.property_name, T3.type_name, T3.base_rate FROM hospitality_technology.reservations AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id JOIN hospitality_technology.room_types AS T3 ON T1.room_type_id = T3.room_type_id WHERE T1.num_adults >= 3;"}, {"role": "user", "content": "Now, only include reservations made at properties with a star rating of 4 or higher and sort the results by check-in date."}, {"role": "assistant", "content": "SELECT T1.reservation_id, T1.check_in_date, T1.check_out_date, T2.property_name, T3.type_name, T3.base_rate FROM hospitality_technology.reservations AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id JOIN hospitality_technology.room_types AS T3 ON T1.room_type_id = T3.room_type_id WHERE T1.num_adults >= 3 AND T2.star_rating >= 4 ORDER BY T1.check_in_date;"}, {"role": "user", "content": "Further refine this list to include only reservations where the total amount is over 700, and limit the results to the top 15."}, {"role": "assistant", "content": "SELECT T1.reservation_id, T1.check_in_date, T1.check_out_date, T2.property_name, T3.type_name, T3.base_rate FROM hospitality_technology.reservations AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id JOIN hospitality_technology.room_types AS T3 ON T1.room_type_id = T3.room_type_id WHERE T1.num_adults >= 3 AND T2.star_rating >= 4 AND T1.total_amount > 700 ORDER BY T1.check_in_date LIMIT 15;"}]} {"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.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.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 )\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\n", "conversations": [{"role": "user", "content": "List the names of services available at service locations that are accessible and located in the state of 'California'."}, {"role": "assistant", "content": "SELECT T1.service_name, T2.location_name FROM government_services.services AS T1 JOIN government_services.service_locations AS T2 ON T1.agency_id = T2.agency_id WHERE T2.is_accessible = TRUE AND T2.state = 'California';"}, {"role": "user", "content": "Modify to only include services that are active."}, {"role": "assistant", "content": "SELECT T1.service_name, T2.location_name FROM government_services.services AS T1 JOIN government_services.service_locations AS T2 ON T1.agency_id = T2.agency_id WHERE T2.is_accessible = TRUE AND T2.state = 'California' AND T1.is_active = TRUE;"}]} {"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 text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "List the license number and specialty for all doctors who have a phone number on record."}, {"role": "assistant", "content": "SELECT license_number, specialty FROM healthcare.doctors WHERE phone_number IS NOT NULL;"}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "List all pairs of active services in the same category where one service\u2019s standard fee is higher than the other\u2019s. Display the category, the higher-fee service name with its fee, and the lower-fee service name with its fee."}, {"role": "assistant", "content": "SELECT\n s1.category,\n s1.service_name AS higher_service,\n s1.standard_fee AS higher_fee,\n s2.service_name AS lower_service,\n s2.standard_fee AS lower_fee\nFROM government_services.services s1\nJOIN government_services.services s2\n ON s1.category = s2.category\n AND s1.standard_fee > s2.standard_fee\nWHERE s1.is_active = TRUE\n AND s2.is_active = TRUE;"}]} {"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, username text, email text, password_hash text, registration_date timestamp with time zone, last_login timestamp with time zone, country_code text, status text, profile_data jsonb )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\n", "conversations": [{"role": "user", "content": "Retrieve the top 5 players by the number of distinct achievements unlocked. Show player_id and distinct_unlocks."}, {"role": "assistant", "content": "SELECT p.player_id, COUNT(DISTINCT pa.achievement_id) AS distinct_unlocks\nFROM gaming_technology.players p\nJOIN gaming_technology.player_achievements pa ON p.player_id = pa.player_id\nGROUP BY p.player_id\nORDER BY distinct_unlocks DESC\nLIMIT 5;"}, {"role": "user", "content": "Now limit the results to players whose status is 'active'."}, {"role": "assistant", "content": "SELECT p.player_id, COUNT(DISTINCT pa.achievement_id) AS distinct_unlocks\nFROM gaming_technology.players p\nJOIN gaming_technology.player_achievements pa ON p.player_id = pa.player_id\nWHERE p.status = 'active'\nGROUP BY p.player_id\nORDER BY distinct_unlocks DESC\nLIMIT 5;"}, {"role": "user", "content": "Sort the list by distinct_unlocks descending and then by player_id ascending."}, {"role": "assistant", "content": "SELECT p.player_id, COUNT(DISTINCT pa.achievement_id) AS distinct_unlocks\nFROM gaming_technology.players p\nJOIN gaming_technology.player_achievements pa ON p.player_id = pa.player_id\nWHERE p.status = 'active'\nGROUP BY p.player_id\nORDER BY distinct_unlocks DESC, p.player_id ASC\nLIMIT 5;"}, {"role": "user", "content": "Finally, limit the output to the top 3 entries."}, {"role": "assistant", "content": "SELECT p.player_id, COUNT(DISTINCT pa.achievement_id) AS distinct_unlocks\nFROM gaming_technology.players p\nJOIN gaming_technology.player_achievements pa ON p.player_id = pa.player_id\nWHERE p.status = 'active'\nGROUP BY p.player_id\nORDER BY distinct_unlocks DESC, p.player_id ASC\nLIMIT 3;"}]} {"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 trading_platform.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the number of users registered each month for 2024."}, {"role": "assistant", "content": "SELECT\n date_trunc('month', created_at) AS month,\n COUNT(*) AS user_count\nFROM trading_platform.users\nWHERE created_at >= '2024-01-01'\n AND created_at < '2025-01-01'\nGROUP BY month\nORDER BY month;"}]} {"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 )\nCREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, amount_paid numeric(12, 2) NOT NULL, payment_method character varying(50), transaction_reference character varying(128) UNIQUE, due_date date, payment_period_start date, payment_period_end date, status character varying(30) NOT NULL DEFAULT 'Completed', PRIMARY KEY (payment_id) )\n", "conversations": [{"role": "user", "content": "Show all policy numbers with their corresponding payment_id and amount_paid for payments made on or after January 1st, 2024."}, {"role": "assistant", "content": "SELECT p.policy_number, pp.payment_id, pp.amount_paid\nFROM insurance.premium_payments pp\nJOIN insurance.policies p ON pp.policy_id = p.policy_id\nWHERE pp.payment_date >= '2024-01-01';"}, {"role": "user", "content": "Include the payment_method and the due_date in the output as well."}, {"role": "assistant", "content": "SELECT p.policy_number, pp.payment_id, pp.amount_paid, pp.payment_method, pp.due_date\nFROM insurance.premium_payments pp\nJOIN insurance.policies p ON pp.policy_id = p.policy_id\nWHERE pp.payment_date >= '2024-01-01';"}]} {"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 social_media.comments (\n comment_id character varying(64) NOT NULL, -- unique identifier for the comment\n post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)\n user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)\n parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)\n content text NOT NULL, -- textual content of the comment\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit\n PRIMARY KEY (comment_id)\n)\nCREATE TABLE social_media.likes ( like_id text, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )\n", "conversations": [{"role": "user", "content": "Show me the content of all comments that have received at least one like."}, {"role": "assistant", "content": "SELECT DISTINCT T1.content FROM social_media.comments AS T1 JOIN social_media.likes AS T2 ON T1.comment_id = T2.comment_id;"}, {"role": "user", "content": "Also include the creation time of these comments and the user_id of the commenter?"}, {"role": "assistant", "content": "SELECT DISTINCT T1.comment_id, T1.content, T1.created_at, T1.user_id FROM social_media.comments AS T1 JOIN social_media.likes AS T2 ON T1.comment_id = T2.comment_id;"}, {"role": "user", "content": "Only show comments created before '2024-05-01'."}, {"role": "assistant", "content": "SELECT DISTINCT T1.comment_id, T1.content, T1.created_at, T1.user_id FROM social_media.comments AS T1 JOIN social_media.likes AS T2 ON T1.comment_id = T2.comment_id WHERE T1.created_at < '2024-05-01';"}]} {"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.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.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.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": "Show me the subjects and start times of all appointments along with the document names of any documents uploaded for the associated case."}, {"role": "assistant", "content": "SELECT a.subject, a.start_time, d.document_name\nFROM legal_services.appointments a\nJOIN legal_services.documents d ON a.case_id = d.case_id;"}]} {"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.game_sessions ( session_id uuid PRIMARY KEY, player_id uuid, game_id uuid, server_id uuid, start_time timestamptz, end_time timestamptz, duration_seconds int, score int, session_data jsonb )\n", "conversations": [{"role": "user", "content": "Can you show me the total number of sessions and the average score for each server and each game combination?"}, {"role": "assistant", "content": "SELECT server_id, game_id, COUNT(*) AS total_sessions, AVG(score) AS average_score FROM gaming_technology.game_sessions GROUP BY server_id, game_id;"}, {"role": "user", "content": "Could you filter this to only include combinations where the average score is above 200?"}, {"role": "assistant", "content": "SELECT server_id, game_id, COUNT(*) AS total_sessions, AVG(score) AS average_score FROM gaming_technology.game_sessions GROUP BY server_id, game_id HAVING AVG(score) > 200;"}, {"role": "user", "content": "Can you add the total duration in seconds for each combination as well?"}, {"role": "assistant", "content": "SELECT server_id, game_id, COUNT(*) AS total_sessions, AVG(score) AS average_score, SUM(duration_seconds) AS total_duration FROM gaming_technology.game_sessions GROUP BY server_id, game_id HAVING AVG(score) > 200;"}, {"role": "user", "content": "Now, only show combinations where the total duration exceeds 10,000 seconds."}, {"role": "assistant", "content": "SELECT server_id, game_id, COUNT(*) AS total_sessions, AVG(score) AS average_score, SUM(duration_seconds) AS total_duration FROM gaming_technology.game_sessions GROUP BY server_id, game_id HAVING AVG(score) > 200 AND SUM(duration_seconds) > 10000;"}]} {"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 cex_token_balance ( snapshot_time character varying(32) NOT NULL, chain character varying(128) NOT NULL, address character varying(128) NOT NULL, exchange character varying(512) NOT NULL, token_address character varying(128) NOT NULL, token_symbol character varying(512), balance numeric(38,10), usd_value numeric(38,14), price double precision )\n", "conversations": [{"role": "user", "content": "Show me the top 5 tokens by USD value held on the Binance Smart Chain, along with their average price and total balance."}, {"role": "assistant", "content": "SELECT token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Binance Smart Chain' GROUP BY token_symbol ORDER BY total_usd_value DESC LIMIT 5;"}, {"role": "user", "content": "Actually, I want to see this for the Polygon chain instead, and only include tokens with a total balance over 1000."}, {"role": "assistant", "content": "SELECT token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol HAVING SUM(balance) > 1000 ORDER BY total_usd_value DESC LIMIT 5;"}, {"role": "user", "content": "Can you add the exchange name to these results and filter to only show Binance holdings?"}, {"role": "assistant", "content": "SELECT exchange, token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND exchange = 'Binance' GROUP BY exchange, token_symbol HAVING SUM(balance) > 1000 ORDER BY total_usd_value DESC LIMIT 5;"}, {"role": "user", "content": "Now order these results by total balance instead of USD value."}, {"role": "assistant", "content": "SELECT exchange, token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND exchange = 'Binance' GROUP BY exchange, token_symbol HAVING SUM(balance) > 1000 ORDER BY total_balance DESC LIMIT 5;"}]} {"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 ( invoice_id text PRIMARY KEY, invoice_number text UNIQUE, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Compute the total invoiced amount and average payment delay (in days) by status for invoices issued between 2024-01-01 and 2024-06-30."}, {"role": "assistant", "content": "SELECT status,\n SUM(total_amount) AS total_invoiced,\n AVG(EXTRACT(day FROM (payment_date::date - issue_date))) AS avg_payment_delay_days\n FROM legal_services.invoices\n WHERE issue_date BETWEEN '2024-01-01' AND '2024-06-30'\n GROUP BY status;"}, {"role": "user", "content": "Also show the count of invoices per status."}, {"role": "assistant", "content": "SELECT status,\n SUM(total_amount) AS total_invoiced,\n AVG(EXTRACT(day FROM (payment_date::date - issue_date))) AS avg_payment_delay_days,\n COUNT(*) AS invoice_count\n FROM legal_services.invoices\n WHERE issue_date BETWEEN '2024-01-01' AND '2024-06-30'\n GROUP BY status;"}, {"role": "user", "content": "Exclude statuses where total_invoiced is less than 10000."}, {"role": "assistant", "content": "SELECT status,\n SUM(total_amount) AS total_invoiced,\n AVG(EXTRACT(day FROM (payment_date::date - issue_date))) AS avg_payment_delay_days,\n COUNT(*) AS invoice_count\n FROM legal_services.invoices\n WHERE issue_date BETWEEN '2024-01-01' AND '2024-06-30'\n GROUP BY status\nHAVING SUM(total_amount) >= 10000;"}, {"role": "user", "content": "Finally, order the results by avg_payment_delay_days ascending."}, {"role": "assistant", "content": "SELECT status,\n SUM(total_amount) AS total_invoiced,\n AVG(EXTRACT(day FROM (payment_date::date - issue_date))) AS avg_payment_delay_days,\n COUNT(*) AS invoice_count\n FROM legal_services.invoices\n WHERE issue_date BETWEEN '2024-01-01' AND '2024-06-30'\n GROUP BY status\nHAVING SUM(total_amount) >= 10000\n ORDER BY avg_payment_delay_days ASC;"}]} {"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\n// Use Hashes for ticket details. Key format: ticket:\n// HSET ticket:tkt_1a2b ticket_id \"tkt_1a2b\" booking_id \"book_zyx\" car_id \"car_abc\" seat_number \"12A\" ... is_checked_in 0 ...\n\n// To link tickets to bookings (optional):\n// SADD booking:book_zyx:tickets ticket:tkt_1a2b\n// Use Hashes for maintenance record details. Key format: maintenance_record:\n// HSET maintenance_record:maint_rec_001 record_id \"maint_rec_001\" asset_id \"train_789\" asset_type \"Train\" ... status \"Completed\"\n\n// To link records to assets (optional):\n// SADD train:train_789:maintenance maintenance_record:maint_rec_001\n// SADD platform:plat_123:maintenance maintenance_record:maint_rec_002\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0ID 'plat_123' \u306b\u95a2\u9023\u3059\u308b\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u8a18\u9332\u3092\u53d6\u5f97\u3059\u308b\u306e\u3092\u624b\u4f1d\u3063\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f\u307e\u305f\u3001\u8a18\u9332\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3082\u542b\u3081\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SMEMBERS platform:plat_123:maintenance\nHGETALL maintenance_record:"}, {"role": "user", "content": "\u30b9\u30c6\u30fc\u30bf\u30b9\u304c 'Completed' \u306e\u8a18\u9332\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS platform:plat_123:maintenance\nHGET maintenance_record: status\nHGETALL maintenance_record: (only if status = 'Completed')"}, {"role": "user", "content": "\u95a2\u9023\u3059\u308b\u8cc7\u7523\u30bf\u30a4\u30d7\u3082\u7d50\u679c\u306b\u542b\u3081\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS platform:plat_123:maintenance\nHGET maintenance_record: status\nHGETALL maintenance_record: (only if status = 'Completed')"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text PRIMARY KEY, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed int, prescription_date timestamp )\n", "conversations": [{"role": "user", "content": "Show me all patients who have received at least two different medications prescribed by doctors working at the same hospital. Include the patient full name, the medication names, and the shared hospital_affiliation_id."}, {"role": "assistant", "content": "SELECT DISTINCT p.patient_id, p.first_name, p.last_name, m1.medication_name AS medication1, m2.medication_name AS medication2, d.hospital_affiliation_id\nFROM healthcare.prescriptions pr1\nJOIN healthcare.prescriptions pr2 ON pr1.patient_id = pr2.patient_id AND pr1.medication_id <> pr2.medication_id\nJOIN healthcare.doctors d ON pr1.doctor_id = d.doctor_id AND pr2.doctor_id = d.doctor_id\nJOIN healthcare.patients p ON pr1.patient_id = p.patient_id\nJOIN healthcare.medications m1 ON pr1.medication_id = m1.medication_id\nJOIN healthcare.medications m2 ON pr2.medication_id = m2.medication_id\nWHERE d.hospital_affiliation_id IS NOT NULL;"}, {"role": "user", "content": "Can you only include records where both medications share the same generic name?"}, {"role": "assistant", "content": "SELECT DISTINCT p.patient_id, p.first_name, p.last_name, m1.medication_name AS medication1, m2.medication_name AS medication2, m1.generic_name, d.hospital_affiliation_id\nFROM healthcare.prescriptions pr1\nJOIN healthcare.prescriptions pr2 ON pr1.patient_id = pr2.patient_id AND pr1.medication_id <> pr2.medication_id\nJOIN healthcare.doctors d ON pr1.doctor_id = d.doctor_id AND pr2.doctor_id = d.doctor_id\nJOIN healthcare.patients p ON pr1.patient_id = p.patient_id\nJOIN healthcare.medications m1 ON pr1.medication_id = m1.medication_id\nJOIN healthcare.medications m2 ON pr2.medication_id = m2.medication_id\nWHERE d.hospital_affiliation_id IS NOT NULL AND m1.generic_name = m2.generic_name;"}, {"role": "user", "content": "Actually, only show those cases where the doctor specialty is 'Internal Medicine'."}, {"role": "assistant", "content": "SELECT DISTINCT p.patient_id, p.first_name, p.last_name, m1.medication_name AS medication1, m2.medication_name AS medication2, m1.generic_name, d.hospital_affiliation_id\nFROM healthcare.prescriptions pr1\nJOIN healthcare.prescriptions pr2 ON pr1.patient_id = pr2.patient_id AND pr1.medication_id <> pr2.medication_id\nJOIN healthcare.doctors d ON pr1.doctor_id = d.doctor_id AND pr2.doctor_id = d.doctor_id\nJOIN healthcare.patients p ON pr1.patient_id = p.patient_id\nJOIN healthcare.medications m1 ON pr1.medication_id = m1.medication_id\nJOIN healthcare.medications m2 ON pr2.medication_id = m2.medication_id\nWHERE d.hospital_affiliation_id IS NOT NULL AND m1.generic_name = m2.generic_name AND d.specialty = 'Internal Medicine';"}]} {"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.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.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.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.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": "Show the subject and start time for all appointments that are related to a case that also has an invoice. Include the case number and the invoice number."}, {"role": "assistant", "content": "SELECT T1.subject, T1.start_time, T2.case_number, T3.invoice_number FROM appointments AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id JOIN invoices AS T3 ON T2.case_id = T3.case_id;"}, {"role": "user", "content": "Only include appointments scheduled in the year 2024."}, {"role": "assistant", "content": "SELECT T1.subject, T1.start_time, T2.case_number, T3.invoice_number FROM appointments AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id JOIN invoices AS T3 ON T2.case_id = T3.case_id WHERE T1.start_time >= '2024-01-01' AND T1.start_time < '2025-01-01';"}]} {"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 social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the total number of likes made by each user, including the user_id and their like count."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS like_count FROM social_media.likes GROUP BY user_id;"}, {"role": "user", "content": "Only show users who have made more than 50 likes."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS like_count FROM social_media.likes GROUP BY user_id HAVING COUNT(*) > 50;"}]} {"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 social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )\nCREATE TABLE social_media.posts ( post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, visibility character varying(20) NOT NULL DEFAULT 'public', location_lat numeric(9,6), location_lon numeric(9,6), PRIMARY KEY (post_id) )\nCREATE TABLE social_media.comments ( comment_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, parent_comment_id character varying(64), content text NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (comment_id) )\nCREATE TABLE social_media.likes ( like_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, post_id character varying(64), comment_id character varying(64), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (like_id), CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, hashtag_id character varying(64) NOT NULL, PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) )\nCREATE TABLE social_media.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_read_at timestamp, PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) )\nCREATE TABLE social_media.user_settings ( setting_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL UNIQUE, theme character varying(20) DEFAULT 'light', email_notifications_enabled boolean DEFAULT true, push_notifications_enabled boolean DEFAULT true, private_profile boolean DEFAULT false, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (setting_id) )\n", "conversations": [{"role": "user", "content": "List all comment IDs and their content for comments made by users who have 'dark' as their theme."}, {"role": "assistant", "content": "SELECT c.comment_id, c.content\nFROM social_media.comments c\nJOIN social_media.user_settings s ON c.user_id = s.user_id\nWHERE s.theme = 'dark';"}, {"role": "user", "content": "Also include the usernames of these users."}, {"role": "assistant", "content": "SELECT c.comment_id, c.content, u.username\nFROM social_media.comments c\nJOIN social_media.user_settings s ON c.user_id = s.user_id\nJOIN social_media.users u ON c.user_id = u.user_id\nWHERE s.theme = 'dark';"}]} {"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.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": "Find all medical records associated with an appointment, and show the record_id, appointment_id, and the record_date."}, {"role": "assistant", "content": "SELECT record_id, appointment_id, record_date\nFROM healthcare.medical_records\nWHERE appointment_id IS NOT NULL;"}]} {"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.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, address_line1.text, city.text, state_province.text, postal_code.text, country_code.text, preferences.text, loyalty_member_id.text, communication_consent.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, 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 integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.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 (\n review_id character varying(64) NOT NULL, -- unique identifier for the review\n property_id character varying(64) NOT NULL, -- FK to properties table\n reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good)\n guest_id character varying(64) NOT NULL, -- FK to guests table\n rating_overall integer, -- overall score (e.g., 1-5 or 1-10)\n rating_cleanliness integer,\n rating_service integer,\n rating_location integer,\n rating_value integer,\n comment text, -- guest's written feedback\n review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com\n review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted\n is_public boolean DEFAULT true, -- whether the review is publicly visible\n staff_response text, -- official response from the property\n response_staff_id character varying(64), -- FK to staff (who responded)\n response_date timestamp with time zone, -- when the response was posted\n PRIMARY KEY (review_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Show the full names and emails of staff members who have delivered at least one service order."}, {"role": "assistant", "content": "SELECT DISTINCT s.first_name, s.last_name, s.work_email\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.service_orders so\n ON s.staff_id = so.staff_id_delivered;"}, {"role": "user", "content": "Only include staff members who have delivered more than 10 service orders."}, {"role": "assistant", "content": "SELECT s.first_name, s.last_name, s.work_email, COUNT(*) AS orders_delivered\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.service_orders so\n ON s.staff_id = so.staff_id_delivered\nGROUP BY s.staff_id, s.first_name, s.last_name, s.work_email\nHAVING COUNT(*) > 10\nORDER BY orders_delivered DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "List all insurance plans along with their provider, plan type, and the contact phone number. Also, for each plan, show how many doctors have their hospital affiliation ID matching the plan ID."}, {"role": "assistant", "content": "SELECT ip.plan_id, ip.plan_name, ip.insurance_provider, ip.plan_type, ip.contact_phone, COUNT(d.doctor_id) FROM healthcare.insurance_plans ip LEFT JOIN healthcare.doctors d ON ip.plan_id = d.hospital_affiliation_id GROUP BY ip.plan_id, ip.plan_name, ip.insurance_provider, ip.plan_type, ip.contact_phone"}]} {"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.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\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 text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all staff members showing their full name and position."}, {"role": "assistant", "content": "SELECT first_name || ' ' || last_name AS staff_full_name, position FROM hospitality_technology.staff;"}, {"role": "user", "content": "Now only include staff who are not currently active and were hired before 2020."}, {"role": "assistant", "content": "SELECT first_name || ' ' || last_name AS staff_full_name, position FROM hospitality_technology.staff WHERE is_active = false AND hire_date < '2020-01-01';"}]} {"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.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.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 need to get the count of appointments grouped by their status."}, {"role": "assistant", "content": "SELECT a.status, \n COUNT(*) AS appointment_count\nFROM legal_services.appointments a\nGROUP BY a.status;"}, {"role": "user", "content": "Only show counts for statuses 'Scheduled' and 'Completed'."}, {"role": "assistant", "content": "SELECT a.status, \n COUNT(*) AS appointment_count\nFROM legal_services.appointments a\nWHERE a.status IN ('Scheduled', 'Completed')\nGROUP BY a.status;"}, {"role": "user", "content": "Also restrict to appointments created after 2023-01-01."}, {"role": "assistant", "content": "SELECT a.status, \n COUNT(*) AS appointment_count\nFROM legal_services.appointments a\nWHERE a.status IN ('Scheduled', 'Completed')\n AND a.created_at >= '2023-01-01'\nGROUP BY a.status;"}, {"role": "user", "content": "Finally, order the groups by appointment_count in descending order."}, {"role": "assistant", "content": "SELECT a.status, \n COUNT(*) AS appointment_count\nFROM legal_services.appointments a\nWHERE a.status IN ('Scheduled', 'Completed')\n AND a.created_at >= '2023-01-01'\nGROUP BY a.status\nORDER BY appointment_count DESC;"}]} {"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.player_inventory (\n inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry\n player_id uuid NOT NULL, -- FK linking to the player owning the item\n item_id uuid NOT NULL, -- FK linking to the item definition\n quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items)\n acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired\n instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability)\n PRIMARY KEY (inventory_id),\n -- Optional unique constraint if items are non-stackable or unique instances\n -- UNIQUE (player_id, item_id) -- Use if quantity is always 1\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id)\n)\n", "conversations": [{"role": "user", "content": "What is the count of unique items acquired on each day?"}, {"role": "assistant", "content": "SELECT DATE(acquired_at) AS acquisition_date, COUNT(DISTINCT item_id) AS unique_item_count FROM gaming_technology.player_inventory GROUP BY DATE(acquired_at);"}, {"role": "user", "content": "Only show days where more than 10 unique items were acquired."}, {"role": "assistant", "content": "SELECT DATE(acquired_at) AS acquisition_date, COUNT(DISTINCT item_id) AS unique_item_count FROM gaming_technology.player_inventory GROUP BY DATE(acquired_at) HAVING COUNT(DISTINCT item_id) > 10;"}, {"role": "user", "content": "Also include the total quantity of items acquired on those days."}, {"role": "assistant", "content": "SELECT DATE(acquired_at) AS acquisition_date, COUNT(DISTINCT item_id) AS unique_item_count, SUM(quantity) AS total_quantity FROM gaming_technology.player_inventory GROUP BY DATE(acquired_at) HAVING COUNT(DISTINCT item_id) > 10;"}, {"role": "user", "content": "Order the results by the total quantity in descending order."}, {"role": "assistant", "content": "SELECT DATE(acquired_at) AS acquisition_date, COUNT(DISTINCT item_id) AS unique_item_count, SUM(quantity) AS total_quantity FROM gaming_technology.player_inventory GROUP BY DATE(acquired_at) HAVING COUNT(DISTINCT item_id) > 10 ORDER BY total_quantity DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id.text, patient_id.text, appointment_id.text, doctor_id.text, record_date.timestamp, chief_complaint.text, present_illness_history.text, past_medical_history.text, physical_examination_notes.text, assessment.text, treatment_plan.text, vitals.json, created_at.timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Retrieve the first and last names of all doctors who specialize in Cardiology."}, {"role": "assistant", "content": "SELECT first_name, last_name\nFROM healthcare.doctors\nWHERE specialty = 'Cardiology';"}]} {"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.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction 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.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the case number, client ID, and total amount for each case that has at least one invoice."}, {"role": "assistant", "content": "SELECT c.case_number, c.client_id, SUM(i.total_amount) AS total_invoice_amount\nFROM legal_services.cases c\nJOIN legal_services.invoices i ON c.case_id = i.case_id\nGROUP BY c.case_number, c.client_id;"}, {"role": "user", "content": "Only include cases where the total invoice amount exceeds 10,000."}, {"role": "assistant", "content": "SELECT c.case_number, c.client_id, SUM(i.total_amount) AS total_invoice_amount\nFROM legal_services.cases c\nJOIN legal_services.invoices i ON c.case_id = i.case_id\nGROUP BY c.case_number, c.client_id\nHAVING SUM(i.total_amount) > 10000;"}]} {"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.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.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.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": "Show the names of all services and the names of their corresponding agencies that are offered at accessible locations in 'Chicago'."}, {"role": "assistant", "content": "SELECT s.service_name, sl.agency_id \nFROM government_services.service_locations sl\nJOIN government_services.services s ON sl.agency_id = s.agency_id\nWHERE sl.city = 'Chicago' AND sl.is_accessible = TRUE;"}]} {"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 trading_platform.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp )\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )\nCREATE TABLE trading_platform.logs ( log_id.text, user_id.text, action.text, details.text, logged_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show all users who have no wallets yet."}, {"role": "assistant", "content": "SELECT DISTINCT k.user_id\nFROM trading_platform.kyc_audit k\nLEFT JOIN trading_platform.wallets w ON k.user_id = w.user_id\nWHERE w.wallet_id IS NULL;"}]} {"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 transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.locations ( location_id text, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text )\nCREATE TABLE transportation.bookings ( booking_id text, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )\n", "conversations": [{"role": "user", "content": "Which locations have received fuel logs greater than 300 liters in total? Please include the location name and city."}, {"role": "assistant", "content": "SELECT l.name AS location_name, l.city, SUM(f.quantity) AS total_quantity\nFROM transportation.fuel_logs f\nJOIN transportation.locations l ON f.location_id = l.location_id\nGROUP BY l.location_id, l.name, l.city\nHAVING SUM(f.quantity) > 300;"}, {"role": "user", "content": "Can you also include the number of times fuel was logged at each location?"}, {"role": "assistant", "content": "SELECT l.name AS location_name, l.city, COUNT(f.fuel_log_id) AS log_count, SUM(f.quantity) AS total_quantity\nFROM transportation.fuel_logs f\nJOIN transportation.locations l ON f.location_id = l.location_id\nGROUP BY l.location_id, l.name, l.city\nHAVING SUM(f.quantity) > 300;"}, {"role": "user", "content": "Actually, could you restrict it to only locations that are in 'New York' city?"}, {"role": "assistant", "content": "SELECT l.name AS location_name, l.city, COUNT(f.fuel_log_id) AS log_count, SUM(f.quantity) AS total_quantity\nFROM transportation.fuel_logs f\nJOIN transportation.locations l ON f.location_id = l.location_id\nWHERE l.city = 'New York'\nGROUP BY l.location_id, l.name, l.city\nHAVING SUM(f.quantity) > 300;"}, {"role": "user", "content": "I got an error about ambiguous column in GROUP BY, can you fix and show only the columns used in SELECT in the GROUP BY?"}, {"role": "assistant", "content": "SELECT l.name AS location_name, l.city, COUNT(f.fuel_log_id) AS log_count, SUM(f.quantity) AS total_quantity\nFROM transportation.fuel_logs f\nJOIN transportation.locations l ON f.location_id = l.location_id\nWHERE l.city = 'New York'\nGROUP BY l.name, l.city\nHAVING SUM(f.quantity) > 300;"}]} {"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 transportation.vehicles (\n vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle\n license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate\n vin character varying(17) UNIQUE, -- vehicle identification number\n make character varying(64) NOT NULL, -- manufacturer of the vehicle\n model character varying(64) NOT NULL, -- model of the vehicle\n year integer NOT NULL, -- manufacturing year\n type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)\n capacity integer, -- passenger or cargo capacity\n fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen\n status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned\n depot_id character varying(64), -- identifier of the home depot/base\n acquisition_date date, -- date the vehicle was acquired\n PRIMARY KEY (vehicle_id)\n)\nCREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.passengers ( passenger_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\nCREATE TABLE transportation.bookings ( booking_id character varying(64) NOT NULL, passenger_id character varying(64) NOT NULL, trip_id character varying(64) NOT NULL, seat_number character varying(16), booking_time timestamp with time zone NOT NULL, status character varying(32) NOT NULL, fare numeric(10, 2) NOT NULL, payment_transaction_id character varying(128), special_requests text, PRIMARY KEY (booking_id) )\n", "conversations": [{"role": "user", "content": "List all passengers who have made a booking for a trip on a route that covers more than 100 kilometers. Include the passenger's full name, email, the route number, and the distance in km."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, p.email, r.route_number, r.distance_km\nFROM transportation.bookings b\nJOIN transportation.passengers p ON b.passenger_id = p.passenger_id\nJOIN transportation.routes r ON b.trip_id = r.route_id\nWHERE r.distance_km > 100;"}]} {"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 transportation.drivers ( driver_id text PRIMARY KEY, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\n", "conversations": [{"role": "user", "content": "List the first and last names of all drivers with status 'Active' along with the route number and type of all Express routes."}, {"role": "assistant", "content": "SELECT d.first_name, d.last_name, r.route_number, r.type\nFROM transportation.drivers d\nCROSS JOIN transportation.routes r\nWHERE d.status = 'Active' AND r.type = 'Express';"}, {"role": "user", "content": "Now, only include drivers hired after '2023-01-01'."}, {"role": "assistant", "content": "SELECT d.first_name, d.last_name, r.route_number, r.type\nFROM transportation.drivers d\nCROSS JOIN transportation.routes r\nWHERE d.status = 'Active'\n AND r.type = 'Express'\n AND d.hire_date > '2023-01-01';"}]} {"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.game_sessions (\n session_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game session\n player_id uuid NOT NULL, -- FK linking to the players table\n game_id uuid NOT NULL, -- FK linking to the games table\n server_id uuid, -- FK linking to the servers table (nullable for single-player)\n start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the session began\n end_time timestamp with time zone, -- when the session ended (null if ongoing)\n duration_seconds integer, -- calculated duration of the session in seconds\n score integer, -- player's score for the session, if applicable\n session_data jsonb, -- flexible field for session-specific info (e.g., map played, character used)\n PRIMARY KEY (session_id)\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id),\n -- FOREIGN KEY (server_id) REFERENCES gaming_technology.servers(server_id)\n)\n", "conversations": [{"role": "user", "content": "Find the date (calendar day) with the highest total number of game sessions. Show the date and the total session count."}, {"role": "assistant", "content": "SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions\nFROM gaming_technology.game_sessions\nGROUP BY session_date\nORDER BY total_sessions DESC\nLIMIT 1;"}, {"role": "user", "content": "Also include the day with the second highest session count."}, {"role": "assistant", "content": "SELECT session_date, total_sessions FROM (\n SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY session_date\n) ranked\nWHERE rn <= 2\nORDER BY total_sessions DESC;"}, {"role": "user", "content": "Can you also add the total score across all sessions for each of those days?"}, {"role": "assistant", "content": "SELECT session_date, total_sessions, total_score FROM (\n SELECT CAST(start_time AS DATE) AS session_date,\n COUNT(*) AS total_sessions,\n SUM(score) AS total_score,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY session_date\n) ranked\nWHERE rn <= 2\nORDER BY total_sessions DESC;"}, {"role": "user", "content": "I got an error that session_date is not found, can you fix this SQL?"}, {"role": "assistant", "content": "SELECT sub.session_date, sub.total_sessions, sub.total_score FROM (\n SELECT CAST(start_time AS DATE) AS session_date,\n COUNT(*) AS total_sessions,\n SUM(score) AS total_score,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY CAST(start_time AS DATE)\n) AS sub\nWHERE sub.rn <= 2\nORDER BY sub.total_sessions DESC;"}]} {"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": "List all appointments that have a location specified and their status is not 'Cancelled'. Show the appointment ID, subject, and location."}, {"role": "assistant", "content": "SELECT appointment_id, subject, location FROM legal_services.appointments WHERE location IS NOT NULL AND status <> 'Cancelled';"}, {"role": "user", "content": "Also, include appointments that have a case ID assigned. Order the final list by start time ascending."}, {"role": "assistant", "content": "SELECT appointment_id, subject, location FROM legal_services.appointments WHERE (location IS NOT NULL AND status <> 'Cancelled') OR case_id IS NOT NULL ORDER BY start_time ASC;"}]} {"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 project_fundraising_record ( id character varying(32) NOT NULL, project_id character varying(32) NOT NULL, project_name character varying(128) NOT NULL, rounds_name character varying(32), investment_value numeric(38,14), investment_date character varying(128), introduction character varying(128), valuation numeric(38,14) )\nCREATE TABLE token_basic_info ( coin_id text, token_name text, token_symbol text, token_address text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, highest_price_24h numeric, lowest_price_24h numeric, market_cap numeric, market_cap_rank numeric, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank numeric )\n \"CREATE TABLE narrative_info (\",\n \"narrative character varying(512) NOT NULL, -- the id of narrative\",\n \"top_3_coins text, -- the top 3 tokens in the narrative\",\n \"price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour in the narrative\",\n \"price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours in the narrative\",\n \"price_change_percentage_7d double precision, -- change in value divided by the absolute price value of the original token price in 7 days in the narrative\",\n \"market_cap double precision, -- the market cap of the narrative\",\n \"volume_24h double precision, -- the trade volume of the narrative\",\n \"trend_rank bigint, -- the trending rank of the narrative, value 1 expresses the most popular narrative\",\n \"token_num bigint, -- total token number in the narrative\",\n \",PRIMARY KEY (narrative));\"\n\n \"CREATE TABLE cex_token_balance (\",\n \"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp\",\n \"chain character varying(128) NOT NULL, -- the chain that the token resides\",\n \"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX\",\n \"exchange character varying(512) NOT NULL, -- a centralized exchange name\",\n \"token_address character varying(128) NOT NULL, -- token contract address\",\n \"token_symbol character varying(512), --token symbol\",\n \"balance numeric(38,10), -- token balance\",\n \"usd_value numeric(38,14), -- value of the token held in USD\",\n \"price double precision, --price of the token in USD\",\n \",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));\"\n\nCREATE TABLE smart_money_profit ( address character varying(100) NOT NULL, -- the user's address rank INT, -- the rank of the address in trade performance, value 1 expresses the best address. profit numeric(38,6), -- the profit user made in a month roi numeric(38,2), -- the roi of the user in a month realized_ratio numeric(38,2), -- the percentage of the user's realized profit most_profit_token character varying(100), -- the token symbol of the user's most profitable trade last_trade_time character varying(100), -- the last trade time of the user chain character varying(100), -- the chain that the address resides PRIMARY KEY (address, chain) )\nCREATE TABLE smart_money_token_performance ( token_address text, token_symbol text, pnl numeric, net_flow numeric, avg_cost numeric, price numeric, realized_ratio numeric, roi numeric, chain text )\nCREATE TABLE smart_money_token_inflow ( token_address text, token_symbol text, token_amount numeric, usd_value numeric, avg_price numeric, type numeric, address_amount numeric, narrative text, chain text )\n", "conversations": [{"role": "user", "content": "What are the top 5 tokens by 7-day price change percentage? Show token_symbol, token_name, narrative, and chain, ordered by price_change_percentage_7d descending."}, {"role": "assistant", "content": "```sql\nSELECT\n token_symbol,\n token_name,\n narrative,\n chain\nFROM token_basic_info\nORDER BY price_change_percentage_7d DESC\nLIMIT 5;\n```"}]} {"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 smart_money_profit ( address character varying(100) NOT NULL, -- the user's address rank INT, -- the rank of the address in trade performance, value 1 expresses the best address. profit numeric(38,6), -- the profit user made in a month roi numeric(38,2), -- the roi of the user in a month realized_ratio numeric(38,2), -- the percentage of the user's realized profit most_profit_token character varying(100), -- the token symbol of the user's most profitable trade last_trade_time character varying(100), -- the last trade time of the user chain character varying(100), -- the chain that the address resides PRIMARY KEY (address, chain) )\n", "conversations": [{"role": "user", "content": "Show the top 3 addresses by ROI on the Polygon chain, including profit and the most profitable token."}, {"role": "assistant", "content": "SELECT address, roi, profit, most_profit_token FROM smart_money_profit WHERE chain = 'Polygon' ORDER BY roi DESC LIMIT 3;"}, {"role": "user", "content": "Now, also include addresses from Arbitrum and display the chain in the results."}, {"role": "assistant", "content": "SELECT address, chain, roi, profit, most_profit_token FROM smart_money_profit WHERE chain IN ('Polygon', 'Arbitrum') ORDER BY roi DESC LIMIT 3;"}, {"role": "user", "content": "I got repeated addresses from both chains. Please show the top 3 per chain separately."}, {"role": "assistant", "content": "SELECT address, chain, roi, profit, most_profit_token FROM ( SELECT address, chain, roi, profit, most_profit_token, ROW_NUMBER() OVER (PARTITION BY chain ORDER BY roi DESC) AS rn FROM smart_money_profit WHERE chain IN ('Polygon', 'Arbitrum') ) t WHERE rn <= 3 ORDER BY chain, roi DESC;"}, {"role": "user", "content": "Add the last_trade_time to your output."}, {"role": "assistant", "content": "SELECT address, chain, roi, profit, most_profit_token, last_trade_time FROM ( SELECT address, chain, roi, profit, most_profit_token, last_trade_time, ROW_NUMBER() OVER (PARTITION BY chain ORDER BY roi DESC) AS rn FROM smart_money_profit WHERE chain IN ('Polygon', 'Arbitrum') ) t WHERE rn <= 3 ORDER BY chain, roi DESC;"}]} {"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.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve all room types with a base_rate above 150 for each property."}, {"role": "assistant", "content": "SELECT property_id, type_name, base_rate\nFROM hospitality_technology.room_types\nWHERE base_rate > 150;"}, {"role": "user", "content": "Also filter to only include room types with max_occupancy >= 3."}, {"role": "assistant", "content": "SELECT property_id, type_name, base_rate\nFROM hospitality_technology.room_types\nWHERE base_rate > 150\n AND max_occupancy >= 3;"}, {"role": "user", "content": "Finally, show guest first and last names of guests created after '2023-01-01' who could book these room types."}, {"role": "assistant", "content": "SELECT g.first_name, g.last_name, rt.property_id, rt.type_name, rt.base_rate\nFROM hospitality_technology.room_types rt\nCROSS JOIN hospitality_technology.guests g\nWHERE rt.base_rate > 150\n AND rt.max_occupancy >= 3\n AND g.created_at > '2023-01-01';"}]} {"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.room_types ( room_type_id.text, property_id.text, type_name.text, description.text, base_rate.numeric, max_occupancy.integer, bed_type.text, area_sqft.numeric, amenities.text )\n", "conversations": [{"role": "user", "content": "Show all room types that offer 'WiFi' in their amenities."}, {"role": "assistant", "content": "SELECT room_type_id, property_id, type_name, amenities FROM hospitality_technology.room_types WHERE amenities LIKE '%WiFi%';"}, {"role": "user", "content": "Only include those with a base rate below 100 and return the results sorted by base_rate ascending."}, {"role": "assistant", "content": "SELECT room_type_id, property_id, type_name, amenities, base_rate FROM hospitality_technology.room_types WHERE amenities LIKE '%WiFi%' AND base_rate < 100 ORDER BY base_rate ASC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\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 (property_id)\n)\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.staff (\n staff_id character varying(64) NOT NULL, -- unique identifier for the staff member\n property_id character varying(64) NOT NULL, -- FK to properties table (primary property)\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge\n work_email character varying(255) UNIQUE, -- staff member's work email\n work_phone character varying(30),\n hire_date date NOT NULL,\n termination_date date, -- date employment ended (if applicable)\n is_active boolean NOT NULL DEFAULT true, -- currently employed flag\n access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin)\n manager_id character varying(64), -- FK to staff table (self-referencing for supervisor)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (staff_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id)\n)\nCREATE TABLE hospitality_technology.reviews (\n review_id character varying(64) NOT NULL, -- unique identifier for the review\n property_id character varying(64) NOT NULL, -- FK to properties table\n reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good)\n guest_id character varying(64) NOT NULL, -- FK to guests table\n rating_overall integer, -- overall score (e.g., 1-5 or 1-10)\n rating_cleanliness integer,\n rating_service integer,\n rating_location integer,\n rating_value integer,\n comment text, -- guest's written feedback\n review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com\n review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted\n is_public boolean DEFAULT true, -- whether the review is publicly visible\n staff_response text, -- official response from the property\n response_staff_id character varying(64), -- FK to staff (who responded)\n response_date timestamp with time zone, -- when the response was posted\n PRIMARY KEY (review_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Show the first name, last name, and position of all staff members who are not currently active."}, {"role": "assistant", "content": "SELECT first_name , last_name , position FROM hospitality_technology.staff WHERE is_active = false"}]} {"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.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, item_id uuid NOT NULL, quantity integer NOT NULL DEFAULT 1, acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, instance_data jsonb, PRIMARY KEY (inventory_id) )\n", "conversations": [{"role": "user", "content": "For each player, show the total quantity of all items they have ever acquired and their earliest acquisition date."}, {"role": "assistant", "content": "SELECT player_id, SUM(quantity) AS total_quantity, MIN(acquired_at) AS earliest_acquisition FROM gaming_technology.player_inventory GROUP BY player_id;"}, {"role": "user", "content": "Please only show players who have acquired more than 10 items in total."}, {"role": "assistant", "content": "SELECT player_id, SUM(quantity) AS total_quantity, MIN(acquired_at) AS earliest_acquisition FROM gaming_technology.player_inventory GROUP BY player_id HAVING SUM(quantity) > 10;"}, {"role": "user", "content": "Add to the results the most recent acquired_at timestamp for each player."}, {"role": "assistant", "content": "SELECT player_id, SUM(quantity) AS total_quantity, MIN(acquired_at) AS earliest_acquisition, MAX(acquired_at) AS latest_acquisition FROM gaming_technology.player_inventory GROUP BY player_id HAVING SUM(quantity) > 10;"}, {"role": "user", "content": "Order the output by total_quantity in descending order."}, {"role": "assistant", "content": "SELECT player_id, SUM(quantity) AS total_quantity, MIN(acquired_at) AS earliest_acquisition, MAX(acquired_at) AS latest_acquisition FROM gaming_technology.player_inventory GROUP BY player_id HAVING SUM(quantity) > 10 ORDER BY total_quantity DESC;"}]} {"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.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.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 text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.reviews ( 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": "List all future reservations (where check_in_date > current_date) including guest full name, room_id, property_id, and the number of days until check-in."}, {"role": "assistant", "content": "SELECT r.reservation_id, r.property_id, r.room_id, \n g.first_name || ' ' || g.last_name AS guest_name, \n (r.check_in_date - CURRENT_DATE) AS days_until_check_in\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.guests g ON r.guest_id = g.guest_id\nWHERE r.check_in_date > CURRENT_DATE;"}]} {"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, 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 (\n claim_id character varying(64) NOT NULL, -- unique identifier for the claim\n policy_id character varying(64) NOT NULL, -- identifier of the policy under which the claim is made (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the claim (FK to customers)\n incident_date timestamp NOT NULL, -- date and time of the incident leading to the claim\n reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the claim was reported\n description text NOT NULL, -- detailed description of the incident and claim\n estimated_loss numeric(15, 2), -- initial estimated cost of the loss\n status character varying(30) NOT NULL, -- e.g., Filed, Processing, Under Review, Approved, Denied, Settled\n settlement_amount numeric(15, 2), -- final amount paid out\n settlement_date date,\n claim_handler_id character varying(64), -- identifier for the employee handling the claim (FK to employees/adjusters)\n police_report_number character varying(100),\n PRIMARY KEY (claim_id)\n)\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, 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 (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment\n policy_id character varying(64) NOT NULL, -- identifier of the policy the payment is for (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the payment (FK to customers)\n payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the payment was received\n amount_paid numeric(12, 2) NOT NULL, -- amount of the payment\n payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check\n transaction_reference character varying(128) UNIQUE, -- reference from payment processor\n due_date date, -- due date for this payment installment\n payment_period_start date, -- start date of the period this payment covers\n payment_period_end date, -- end date of the period this payment covers\n status character varying(30) NOT NULL DEFAULT 'Completed', -- e.g., Completed, Pending, Failed, Refunded\n PRIMARY KEY (payment_id)\n)\nCREATE TABLE insurance.claim_documents ( document_id character varying(64) NOT NULL, claim_id character varying(64) NOT NULL, document_type character varying(50) NOT NULL, file_name character varying(255) NOT NULL, file_path character varying(512) NOT NULL, file_size_bytes integer, mime_type character varying(100), uploaded_by character varying(64), uploaded_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text, PRIMARY KEY (document_id) )\n", "conversations": [{"role": "user", "content": "List the first name, last name, and city for all customers who live in the state 'NY'."}, {"role": "assistant", "content": "SELECT first_name, last_name, city FROM insurance.customers WHERE state = 'NY';"}]} {"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 character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\n", "conversations": [{"role": "user", "content": "Show me all clients along with their email addresses who registered in the year 2023."}, {"role": "assistant", "content": "SELECT first_name, last_name, email FROM legal_services.clients WHERE EXTRACT(YEAR FROM date_registered) = 2023;"}, {"role": "user", "content": "Could you also show their current status and sort the list by the registration date in ascending order?"}, {"role": "assistant", "content": "SELECT first_name, last_name, email, status FROM legal_services.clients WHERE EXTRACT(YEAR FROM date_registered) = 2023 ORDER BY date_registered ASC;"}, {"role": "user", "content": "Additionally, only include those with a company name specified, and display the company name as well."}, {"role": "assistant", "content": "SELECT first_name, last_name, email, status, company_name FROM legal_services.clients WHERE EXTRACT(YEAR FROM date_registered) = 2023 AND company_name IS NOT NULL ORDER BY date_registered ASC;"}]} {"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.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\n", "conversations": [{"role": "user", "content": "Show me a list of all partners who were hired in 2021."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31';"}, {"role": "user", "content": "Include their professional email addresses as well."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n email,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31';"}, {"role": "user", "content": "Exclude any partners who haven't provided a phone number."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n email,\n phone,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31'\n AND phone IS NOT NULL;"}, {"role": "user", "content": "Finally, order the result by hire_date in descending order."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n email,\n phone,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31'\n AND phone IS NOT NULL\nORDER BY hire_date DESC;"}]} {"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.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid PRIMARY KEY, player_id uuid, game_id uuid, server_id uuid, start_time timestamptz, end_time timestamptz, duration_seconds int, score int, session_data jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, achievement_id uuid NOT NULL, unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id.uuid, player_id.uuid, item_id.uuid, quantity.integer, acquired_at.timestamptz, instance_data.jsonb )\n", "conversations": [{"role": "user", "content": "Show me all players who have acquired items from games that have running servers in the 'ap-northeast-1' region, and the item names they acquired."}, {"role": "assistant", "content": "SELECT DISTINCT pi.player_id, igi.item_name \nFROM gaming_technology.player_inventory pi\nJOIN gaming_technology.in_game_items igi ON pi.item_id = igi.item_id\nJOIN gaming_technology.servers s ON igi.game_id = s.game_id\nWHERE s.region = 'ap-northeast-1' AND s.status = 'online';"}, {"role": "user", "content": "Can you also include the server name and only show items of rarity 'Rare' or higher?"}, {"role": "assistant", "content": "SELECT DISTINCT pi.player_id, igi.item_name, s.server_name \nFROM gaming_technology.player_inventory pi\nJOIN gaming_technology.in_game_items igi ON pi.item_id = igi.item_id\nJOIN gaming_technology.servers s ON igi.game_id = s.game_id\nWHERE s.region = 'ap-northeast-1' \n AND s.status = 'online'\n AND igi.rarity IN ('Rare', 'Epic', 'Legendary');"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\n", "conversations": [{"role": "user", "content": "Show all policies that started in 2024, including the policy_id, customer_id, and start_date. Order the results by start_date ascending."}, {"role": "assistant", "content": "SELECT policy_id, customer_id, start_date\nFROM insurance.policies\nWHERE start_date >= '2024-01-01' AND start_date < '2025-01-01'\nORDER BY start_date ASC;"}, {"role": "user", "content": "Also, include the status of each policy and only show those with premium_amount over 3000."}, {"role": "assistant", "content": "SELECT policy_id, customer_id, start_date, status\nFROM insurance.policies\nWHERE start_date >= '2024-01-01' AND start_date < '2025-01-01'\n AND premium_amount > 3000\nORDER BY start_date ASC;"}]} {"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 smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )\n", "conversations": [{"role": "user", "content": "How many addresses on the Polygon chain have an ROI above 5?"}, {"role": "assistant", "content": "SELECT COUNT(*) AS address_count FROM smart_money_profit WHERE chain = 'Polygon' AND roi > 5;"}, {"role": "user", "content": "Also show the average profit of these addresses."}, {"role": "assistant", "content": "SELECT COUNT(*) AS address_count, AVG(profit) AS avg_profit FROM smart_money_profit WHERE chain = 'Polygon' AND roi > 5;"}]} {"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.doctors ( doctor_id text PRIMARY KEY, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments (\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 ( record_id.text, patient_id.text, appointment_id.text, doctor_id.text, record_date.timestamp, chief_complaint.text, present_illness_history.text, past_medical_history.text, physical_examination_notes.text, assessment.text, treatment_plan.text, vitals.json, created_at.timestamp )\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 text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "List all prescriptions with medication details. Return prescription_id, patient full name, medication_name, and prescription_date."}, {"role": "assistant", "content": "SELECT pr.prescription_id,\n p.first_name || ' ' || p.last_name AS patient_name,\n m.medication_name,\n pr.prescription_date\nFROM healthcare.prescriptions pr\nJOIN healthcare.patients p ON pr.patient_id = p.patient_id\nJOIN healthcare.medications m ON pr.medication_id = m.medication_id;"}, {"role": "user", "content": "Filter to only include prescriptions where the quantity_dispensed is greater than 30."}, {"role": "assistant", "content": "SELECT pr.prescription_id,\n p.first_name || ' ' || p.last_name AS patient_name,\n m.medication_name,\n pr.prescription_date\nFROM healthcare.prescriptions pr\nJOIN healthcare.patients p ON pr.patient_id = p.patient_id\nJOIN healthcare.medications m ON pr.medication_id = m.medication_id\nWHERE pr.quantity_dispensed > 30;"}]} {"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.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.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.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 the full name of lawyers who are the lead attorney on cases for clients registered in 2023. List each lawyer's full name and the client's registration date for such cases."}, {"role": "assistant", "content": "SELECT DISTINCT T1.first_name, T1.last_name, T3.date_registered FROM lawyers AS T1 JOIN cases AS T2 ON T1.lawyer_id = T2.lead_lawyer_id JOIN clients AS T3 ON T2.client_id = T3.client_id WHERE EXTRACT(YEAR FROM T3.date_registered) = 2023"}, {"role": "user", "content": "Now, only show lawyers whose specialization is 'Corporate Law'."}, {"role": "assistant", "content": "SELECT DISTINCT T1.first_name, T1.last_name, T3.date_registered FROM lawyers AS T1 JOIN cases AS T2 ON T1.lawyer_id = T2.lead_lawyer_id JOIN clients AS T3 ON T2.client_id = T3.client_id WHERE EXTRACT(YEAR FROM T3.date_registered) = 2023 AND T1.specialization = 'Corporate Law'"}, {"role": "user", "content": "Additionally, only include cases where the case status is 'Open'."}, {"role": "assistant", "content": "SELECT DISTINCT T1.first_name, T1.last_name, T3.date_registered FROM lawyers AS T1 JOIN cases AS T2 ON T1.lawyer_id = T2.lead_lawyer_id JOIN clients AS T3 ON T2.client_id = T3.client_id WHERE EXTRACT(YEAR FROM T3.date_registered) = 2023 AND T1.specialization = 'Corporate Law' AND T2.status = 'Open'"}]} {"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.games ( game_id uuid PRIMARY KEY, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text )\nCREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\n", "conversations": [{"role": "user", "content": "Show item_id, item_name, and the damage attribute extracted from attributes JSON for items of type 'Weapon'."}, {"role": "assistant", "content": "SELECT item_id,\n item_name,\n (attributes->>'damage')::numeric AS damage\nFROM gaming_technology.in_game_items\nWHERE item_type = 'Weapon'\n AND attributes ? 'damage';"}, {"role": "user", "content": "Include the healing attribute as well, showing it as healing, even if null."}, {"role": "assistant", "content": "SELECT item_id,\n item_name,\n (attributes->>'damage')::numeric AS damage,\n (attributes->>'healing')::numeric AS healing\nFROM gaming_technology.in_game_items\nWHERE item_type = 'Weapon'\n AND attributes ? 'damage';"}, {"role": "user", "content": "Group by item_type and calculate the average damage and maximum healing."}, {"role": "assistant", "content": "SELECT item_type,\n AVG((attributes->>'damage')::numeric) AS avg_damage,\n MAX((attributes->>'healing')::numeric) AS max_healing\nFROM gaming_technology.in_game_items\nWHERE attributes ? 'damage'\n AND attributes ? 'healing'\nGROUP BY item_type;"}, {"role": "user", "content": "Also show the total count of such items for each item_type."}, {"role": "assistant", "content": "SELECT item_type,\n COUNT(*) AS item_count,\n AVG((attributes->>'damage')::numeric) AS avg_damage,\n MAX((attributes->>'healing')::numeric) AS max_healing\nFROM gaming_technology.in_game_items\nWHERE attributes ? 'damage'\n AND attributes ? 'healing'\nGROUP BY item_type;"}]} {"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 project_fundraising_record ( id character varying(32) NOT NULL, -- fundraising record id project_id character varying(32) NOT NULL, -- the invested project's id project_name character varying(128) NOT NULL, -- name of the invested project rounds_name character varying(32), -- name of the fundraising round investment_value numeric(38,14), -- amount of the fundraising in USD investment_date character varying(128), -- the date of the investment happened introduction character varying(128), -- the introduction of the invested project valuation numeric(38,14), -- the valuation of the project in USD when invested )\nCREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, -- the id of the token token_name character varying(100) NOT NULL, -- the token's name token_symbol character varying(100) NOT NULL, -- the token's symbol token_address character varying(100) NOT NULL, -- the token's address chain text, -- the chain that the token resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours price_change_percentage_7d double precision, -- change in value divided by the absolute price value of the original token price in 7 days highest_price_24h double precision, -- the highest price of the token in 24 hours lowest_price_24h double precision, -- the lowest price of the token in 24 hours market_cap double precision, -- the market cap of the token market_cap_rank bigint, -- the rank of the token market cap in desc market_cap_change_percentage_24h text, -- the percentage of market cap changes in 24 hours total_volume text, -- the trade volum of the token both in decentralized exchange(DEX) and centralized exchange(CEX) narrative text, -- the category or narrative of the token trend_rank biging, -- the trending rank of the token, value 1 expresses the most popular token. ,PRIMARY KEY (coin_id, chain) )\nCREATE TABLE narrative_info ( narrative.text, top_3_coins.text, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, market_cap.numeric, volume_24h.numeric, trend_rank.numeric, token_num.numeric )\nCREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )\nCREATE TABLE smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )\nCREATE TABLE smart_money_token_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, chain.text )\nCREATE TABLE smart_money_token_inflow ( token_address.text, token_symbol.text, token_amount.numeric, usd_value.numeric, avg_price.numeric, type.numeric, address_amount.numeric, narrative.text, chain.text )\n", "conversations": [{"role": "user", "content": "List tokens in DEX pools with a 24-hour trading volume greater than $500,000 and a price less than $1. Show their symbol, chain, volume, and price."}, {"role": "assistant", "content": "SELECT token_symbol, chain, volume_24h, price FROM token_dexpool_info WHERE volume_24h > 500000 AND price < 1"}]} {"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 (\n client_id character varying(64) NOT NULL, -- unique identifier for the client\n first_name character varying(100) NOT NULL, -- client's first name\n last_name character varying(100) NOT NULL, -- client's last name\n company_name character varying(200), -- company name if applicable\n email character varying(128) UNIQUE NOT NULL, -- client's primary email\n phone character varying(32), -- client's contact phone number\n address text, -- client's full address\n date_registered timestamp NOT NULL, -- when the client was first registered\n status character varying(32) NOT NULL, -- client status (e.g., active, inactive, prospect)\n PRIMARY KEY (client_id)\n)\nCREATE TABLE legal_services.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\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)\nCREATE TABLE legal_services.time_entries ( entry_id.text, case_id.text, lawyer_id.text, date_worked.date, hours_spent.numeric, billing_rate.numeric, description.text, is_billable.boolean, is_billed.boolean, invoice_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the number of documents uploaded for each case, including the case number and the case name."}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, COUNT(d.document_id) AS document_count\nFROM legal_services.cases c\nJOIN legal_services.documents d ON c.case_id = d.case_id\nGROUP BY c.case_number, c.case_name;"}, {"role": "user", "content": "Actually, could you only include cases that have more than five documents uploaded?"}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, COUNT(d.document_id) AS document_count\nFROM legal_services.cases c\nJOIN legal_services.documents d ON c.case_id = d.case_id\nGROUP BY c.case_number, c.case_name\nHAVING COUNT(d.document_id) > 5;"}, {"role": "user", "content": "Also, can you sort the results by document_count descending?"}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, COUNT(d.document_id) AS document_count\nFROM legal_services.cases c\nJOIN legal_services.documents d ON c.case_id = d.case_id\nGROUP BY c.case_number, c.case_name\nHAVING COUNT(d.document_id) > 5\nORDER BY document_count DESC;"}]} {"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.trades ( trade_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, security_id character varying(64) NOT NULL, order_id character varying(64), trade_type character varying(10) NOT NULL, quantity numeric(19, 8) NOT NULL, price_per_unit numeric(19, 8) NOT NULL, total_amount numeric(19, 4) NOT NULL, commission numeric(10, 4), trade_timestamp timestamp NOT NULL, settlement_date date, status character varying(32) NOT NULL, execution_venue character varying(100), PRIMARY KEY (trade_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\n", "conversations": [{"role": "user", "content": "List each account number and the total quantity of shares traded through it."}, {"role": "assistant", "content": "SELECT T2.account_number, SUM(T1.quantity) FROM financial_services.trades AS T1 JOIN financial_services.accounts AS T2 ON T1.account_id = T2.account_id GROUP BY 1"}, {"role": "user", "content": "Only include accounts with total quantity traded greater than 1000, and order the results by total quantity descending."}, {"role": "assistant", "content": "SELECT T2.account_number, SUM(T1.quantity) AS total_traded_quantity FROM financial_services.trades AS T1 JOIN financial_services.accounts AS T2 ON T1.account_id = T2.account_id GROUP BY 1 HAVING SUM(T1.quantity) > 1000 ORDER BY total_traded_quantity DESC"}]} {"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.games ( game_id.uuid, title.text, developer_id.uuid, publisher_id.uuid, genre.text, release_date.date, description.text, platform.text, engine.text, website.text )\n", "conversations": [{"role": "user", "content": "I need a count of games per platform and the earliest release date on each platform."}, {"role": "assistant", "content": "SELECT platform, COUNT(*) AS game_count, MIN(release_date) AS first_release\nFROM gaming_technology.games\nGROUP BY platform;"}, {"role": "user", "content": "Actually, only include platforms with at least 5 games."}, {"role": "assistant", "content": "SELECT platform, COUNT(*) AS game_count, MIN(release_date) AS first_release\nFROM gaming_technology.games\nGROUP BY platform\nHAVING COUNT(*) >= 5;"}, {"role": "user", "content": "Also, order the results by first_release ascending."}, {"role": "assistant", "content": "SELECT platform, COUNT(*) AS game_count, MIN(release_date) AS first_release\nFROM gaming_technology.games\nGROUP BY platform\nHAVING COUNT(*) >= 5\nORDER BY first_release ASC;"}, {"role": "user", "content": "And please exclude any records where platform is null."}, {"role": "assistant", "content": "SELECT platform, COUNT(*) AS game_count, MIN(release_date) AS first_release\nFROM gaming_technology.games\nWHERE platform IS NOT NULL\nGROUP BY platform\nHAVING COUNT(*) >= 5\nORDER BY first_release ASC;"}]} {"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.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\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)\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": "List all appointments, including their subject and start time, along with the name and status of the case they are linked to."}, {"role": "assistant", "content": "SELECT T1.subject, T1.start_time, T2.case_name, T2.status FROM appointments AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id"}]} {"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.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_id) )\nCREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, submitted_at timestamp NOT NULL, status character varying(50) NOT NULL, last_updated_at timestamp NOT NULL, assigned_employee_id character varying(64), decision_date date, notes text, reference_number character varying(100) UNIQUE, PRIMARY KEY (application_id) )\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.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.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) )\n", "conversations": [{"role": "user", "content": "Which employees have verified more than 5 documents in the last 30 days? Return the employee's full name, department, and the number of verifications."}, {"role": "assistant", "content": "SELECT e.first_name || ' ' || e.last_name AS full_name, e.department, COUNT(d.document_id) AS verification_count\nFROM government_services.documents d\nJOIN government_services.employees e ON d.verified_by_employee_id = e.employee_id\nWHERE d.verification_status = 'Verified'\n AND d.verification_timestamp >= now() - interval '30 days'\nGROUP BY e.first_name, e.last_name, e.department\nHAVING COUNT(d.document_id) > 5;"}]} {"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.doctors (\n doctor_id character varying(64) NOT NULL, -- unique identifier for the doctor\n first_name character varying(100) NOT NULL, -- doctor's first name\n last_name character varying(100) NOT NULL, -- doctor's last name\n specialty character varying(100) NOT NULL, -- doctor's medical specialty\n license_number character varying(50) UNIQUE NOT NULL, -- doctor's medical license number\n phone_number character varying(20), -- doctor's contact phone\n email character varying(128) UNIQUE, -- doctor's contact email\n hospital_affiliation_id character varying(64), -- FK to hospitals table (optional)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (doctor_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)\nCREATE TABLE healthcare.medications (\n medication_id character varying(64) NOT NULL, -- unique identifier for the medication type\n medication_name character varying(255) NOT NULL, -- common or brand name\n generic_name character varying(255), -- generic chemical name\n manufacturer character varying(100), -- drug manufacturer\n ndc_code character varying(20) UNIQUE, -- National Drug Code (optional but useful)\n description text, -- description of the medication\n PRIMARY KEY (medication_id)\n)\nCREATE TABLE healthcare.insurance_plans (\n plan_id character varying(64) NOT NULL, -- unique identifier for the insurance plan\n plan_name character varying(200) NOT NULL, -- name of the insurance plan\n insurance_provider character varying(100) NOT NULL, -- name of the insurance company\n plan_type character varying(50), -- e.g., PPO, HMO, EPO\n contact_phone character varying(20), -- provider contact number\n website character varying(255), -- provider website\n PRIMARY KEY (plan_id)\n)\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "How many active insurance policies does each patient have? Return patient_id and active_policy_count."}, {"role": "assistant", "content": "SELECT patient_id,\n COUNT(*) AS active_policy_count\nFROM healthcare.patient_insurance\nWHERE expiration_date IS NULL\n OR expiration_date >= CURRENT_DATE\nGROUP BY patient_id;"}, {"role": "user", "content": "Actually, only include patients who have more than one active insurance policy."}, {"role": "assistant", "content": "SELECT patient_id,\n COUNT(*) AS active_policy_count\nFROM healthcare.patient_insurance\nWHERE expiration_date IS NULL\n OR expiration_date >= CURRENT_DATE\nGROUP BY patient_id\nHAVING COUNT(*) > 1;"}]} {"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 character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\nCREATE TABLE legal_services.lawyers ( lawyer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, bar_number character varying(64) UNIQUE NOT NULL, firm_id character varying(64), email character varying(128) UNIQUE NOT NULL, phone character varying(32), specialization text, hire_date timestamp NOT NULL, is_partner boolean DEFAULT false, PRIMARY KEY (lawyer_id) )\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) )\nCREATE TABLE legal_services.cases ( case_id character varying(64) NOT NULL, case_number character varying(100) UNIQUE, case_name text NOT NULL, client_id character varying(64) NOT NULL, lead_lawyer_id character varying(64) NOT NULL, case_type character varying(100) NOT NULL, status character varying(50) NOT NULL, date_opened timestamp NOT NULL, date_closed timestamp, description text, court_jurisdiction character varying(128), PRIMARY KEY (case_id) )\nCREATE TABLE legal_services.documents ( document_id character varying(64) NOT NULL, case_id character varying(64) NOT NULL, document_name character varying(255) NOT NULL, document_type character varying(100), storage_path text NOT NULL, uploaded_by_lawyer_id character varying(64), upload_timestamp timestamp NOT NULL, version integer DEFAULT 1, description text, PRIMARY KEY (document_id) )\nCREATE TABLE legal_services.time_entries ( entry_id character varying(64) NOT NULL, case_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, date_worked date NOT NULL, hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), billing_rate numeric(10, 2) NOT NULL, description text NOT NULL, is_billable boolean DEFAULT true, is_billed boolean DEFAULT false, invoice_id character varying(64), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (entry_id) )\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": "Retrieve the names and upload timestamps of all documents of type 'Contract' that were uploaded between '2024-03-01' and '2024-03-31'."}, {"role": "assistant", "content": "SELECT document_name, upload_timestamp\nFROM legal_services.documents\nWHERE document_type = 'Contract'\n AND upload_timestamp BETWEEN '2024-03-01' AND '2024-03-31';"}]} {"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 character varying(64) NOT NULL, national_id_number character varying(128) NOT NULL UNIQUE, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(20), primary_address text NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), registration_date timestamp NOT NULL, is_verified boolean DEFAULT false, PRIMARY KEY (citizen_id) )\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.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_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) )\n", "conversations": [{"role": "user", "content": "For each agency offering more than 5 active services, list the agency_name, jurisdiction_level, and the count of active services. Order the results by the count in descending order."}, {"role": "assistant", "content": "SELECT a.agency_name,\n a.jurisdiction_level,\n COUNT(s.service_id) AS active_service_count\nFROM government_services.agencies a\nJOIN government_services.services s\n ON a.agency_id = s.agency_id\nWHERE s.is_active = TRUE\nGROUP BY a.agency_name, a.jurisdiction_level\nHAVING COUNT(s.service_id) > 5\nORDER BY active_service_count DESC;"}]} {"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.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": "What is the total count of medical records created in the year 2023 where the assessment field is not empty?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM healthcare.medical_records mr WHERE (mr.assessment IS NOT NULL AND mr.assessment != '') AND EXTRACT(YEAR FROM mr.record_date) = 2023;"}, {"role": "user", "content": "Now, break down this count by the doctor who created the record. Show the doctor_id and the count."}, {"role": "assistant", "content": "SELECT mr.doctor_id, COUNT(*) FROM healthcare.medical_records mr WHERE (mr.assessment IS NOT NULL AND mr.assessment != '') AND EXTRACT(YEAR FROM mr.record_date) = 2023 GROUP BY mr.doctor_id;"}]} {"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.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, item_id uuid NOT NULL, quantity integer NOT NULL DEFAULT 1, acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, instance_data jsonb, PRIMARY KEY (inventory_id) )\n", "conversations": [{"role": "user", "content": "Show me, for each item, the total number of times it has been acquired and the earliest date it was acquired. Also, show the number of unique players who have acquired each item."}, {"role": "assistant", "content": "SELECT item_id, COUNT(*) AS total_acquisitions, MIN(acquired_at) AS earliest_acquired, COUNT(DISTINCT player_id) AS unique_players FROM gaming_technology.player_inventory GROUP BY item_id;"}, {"role": "user", "content": "Now, could you limit the results to only items that have been acquired by at least 3 unique players?"}, {"role": "assistant", "content": "SELECT item_id, COUNT(*) AS total_acquisitions, MIN(acquired_at) AS earliest_acquired, COUNT(DISTINCT player_id) AS unique_players FROM gaming_technology.player_inventory GROUP BY item_id HAVING COUNT(DISTINCT player_id) >= 3;"}, {"role": "user", "content": "Also, sort the results by total_acquisitions in descending order."}, {"role": "assistant", "content": "SELECT item_id, COUNT(*) AS total_acquisitions, MIN(acquired_at) AS earliest_acquired, COUNT(DISTINCT player_id) AS unique_players FROM gaming_technology.player_inventory GROUP BY item_id HAVING COUNT(DISTINCT player_id) >= 3 ORDER BY total_acquisitions DESC;"}, {"role": "user", "content": "Finally, limit the output to the top 5 items."}, {"role": "assistant", "content": "SELECT item_id, COUNT(*) AS total_acquisitions, MIN(acquired_at) AS earliest_acquired, COUNT(DISTINCT player_id) AS unique_players FROM gaming_technology.player_inventory GROUP BY item_id HAVING COUNT(DISTINCT player_id) >= 3 ORDER BY total_acquisitions DESC LIMIT 5;"}]} {"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 web3.events ( event_id character varying(64) NOT NULL, contract_id character varying(64) NOT NULL, event_name character varying(128) NOT NULL, data text NOT NULL, emitted_at timestamp NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (event_id) )\nCREATE TABLE web3.tokens (\n token_id character varying(64) NOT NULL, -- unique identifier for the token\n contract_address character varying(128) NOT NULL, -- address of the token contract\n token_name character varying(128) NOT NULL, -- name of the token\n token_symbol character varying(32) NOT NULL, -- symbol of the token\n decimals integer NOT NULL, -- number of decimals for the token\n total_supply numeric(38,14) NOT NULL, -- total supply of the token\n PRIMARY KEY (token_id)\n)\nCREATE TABLE web3.wallets (\n wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet\n user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet\n address character varying(128) NOT NULL, -- address of the wallet\n private_key text NOT NULL, -- private key of the wallet\n created_at timestamp NOT NULL, -- time when the wallet was created\n PRIMARY KEY (wallet_id)\n)\nCREATE TABLE web3.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(128) NOT NULL, -- username of the user\n email character varying(128) NOT NULL, -- email address of the user\n password_hash text NOT NULL, -- hashed password of the user\n created_at timestamp NOT NULL, -- time when the user account was created\n PRIMARY KEY (user_id)\n)\n", "conversations": [{"role": "user", "content": "Find users who have at least one wallet created before their user registration date. List their username and the address of any such wallet."}, {"role": "assistant", "content": "SELECT u.username, w.address AS wallet_address FROM web3.users AS u JOIN web3.wallets AS w ON u.user_id = w.user_id WHERE w.created_at < u.created_at;"}]} {"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.player_inventory ( inventory_id uuid, player_id uuid, item_id uuid, quantity integer, acquired_at timestamp with time zone, instance_data jsonb )\n", "conversations": [{"role": "user", "content": "Show me all unique player IDs who have at least one item in their inventory with a quantity greater than 10."}, {"role": "assistant", "content": "SELECT DISTINCT player_id FROM gaming_technology.player_inventory WHERE quantity > 10;"}]} {"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\n \"CREATE TABLE smart_money_token_inflow (\",\n \"token_address character varying(100) NOT NULL, -- the token's address\",\n \"token_symbol character varying(100), -- the tokens's symbol\",\n \"token_amount numeric(38,2), -- the absolute value of the amount if user bought minus the amount user sold of this token\",\n \"usd_value numeric(38,2), -- the absolute usd value of the bought token minus sold token\",\n \"avg_price numeric(38,6), -- the average cost price of user spent on this token\",\n \"type int, -- the direction of the trade on this token. 1 means buying, 2 means selling\",\n \"address_amount integer, -- the amount of the user bought this token\",\n \"narrative character varying(100), -- the category or narrative of the token\",\n \"chain character varying(100), -- the chain that the token resides\",\n \",PRIMARY KEY (token_address, chain)\",\n\n", "conversations": [{"role": "user", "content": "What are the top 3 narratives with the highest total USD buy value?"}, {"role": "assistant", "content": "SELECT narrative,\n SUM(usd_value) AS total_buy_usd\nFROM smart_money_token_inflow\nWHERE type = 1\nGROUP BY narrative\nORDER BY total_buy_usd DESC\nLIMIT 3;"}, {"role": "user", "content": "Please include the count of distinct token symbols for each narrative as token_count."}, {"role": "assistant", "content": "SELECT narrative,\n SUM(usd_value) AS total_buy_usd,\n COUNT(DISTINCT token_symbol) AS token_count\nFROM smart_money_token_inflow\nWHERE type = 1\nGROUP BY narrative\nORDER BY total_buy_usd DESC\nLIMIT 3;"}]} {"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 transportation.vehicles ( vehicle_id.text, license_plate.text, vin.text, make.text, model.text, year.integer, type.text, capacity.integer, fuel_type.text, status.text, depot_id.text, acquisition_date.date )\nCREATE TABLE transportation.drivers ( driver_id.text, employee_id.text, first_name.text, last_name.text, license_number.text, license_expiry_date.date, contact_number.text, email.text, hire_date.date, status.text )\nCREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.trips ( trip_id.text, route_id.text, vehicle_id.text, driver_id.text, scheduled_departure.timestamp, actual_departure.timestamp, scheduled_arrival.timestamp, actual_arrival.timestamp, origin_location_id.text, destination_location_id.text, status.text, passenger_count.integer, cargo_manifest_id.text )\nCREATE TABLE transportation.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\nCREATE TABLE transportation.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )\n", "conversations": [{"role": "user", "content": "Show the vehicle ID and the total number of fuel logs recorded for each vehicle."}, {"role": "assistant", "content": "SELECT vehicle_id , count(*) FROM transportation.fuel_logs GROUP BY vehicle_id"}, {"role": "user", "content": "Filter this list to only show vehicles with more than 5 fuel log entries."}, {"role": "assistant", "content": "SELECT vehicle_id , count(*) FROM transportation.fuel_logs GROUP BY vehicle_id HAVING count(*) > 5"}]} {"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.game_sessions ( session_id.uuid, player_id.uuid, game_id.uuid, server_id.uuid, start_time.timestamptz, end_time.timestamptz, duration_seconds.integer, score.integer, session_data.jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\n", "conversations": [{"role": "user", "content": "What is the total session duration and total score across all sessions for each server status?"}, {"role": "assistant", "content": "SELECT\n s.status,\n SUM(gs.duration_seconds) AS total_duration_seconds,\n SUM(gs.score) AS total_score\nFROM gaming_technology.game_sessions AS gs\nJOIN gaming_technology.servers AS s\n ON gs.server_id = s.server_id\nGROUP BY\n s.status;"}, {"role": "user", "content": "Only include statuses that have a total session duration greater than 1000000 seconds and handle potential null scores by treating them as 0."}, {"role": "assistant", "content": "SELECT\n s.status,\n SUM(gs.duration_seconds) AS total_duration_seconds,\n SUM(COALESCE(gs.score, 0)) AS total_score\nFROM gaming_technology.game_sessions AS gs\nJOIN gaming_technology.servers AS s\n ON gs.server_id = s.server_id\nGROUP BY\n s.status\nHAVING\n SUM(gs.duration_seconds) > 1000000;"}, {"role": "user", "content": "Order the results by total session duration in descending order."}, {"role": "assistant", "content": "SELECT\n s.status,\n SUM(gs.duration_seconds) AS total_duration_seconds,\n SUM(COALESCE(gs.score, 0)) AS total_score\nFROM gaming_technology.game_sessions AS gs\nJOIN gaming_technology.servers AS s\n ON gs.server_id = s.server_id\nGROUP BY\n s.status\nHAVING\n SUM(gs.duration_seconds) > 1000000\nORDER BY\n total_duration_seconds DESC;"}]} {"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 web3.token_transfers (\n transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer\n token_id character varying(64) NOT NULL, -- identifier of the token being transferred\n from_address character varying(128) NOT NULL, -- address of the sender\n to_address character varying(128) NOT NULL, -- address of the receiver\n value numeric(38,14) NOT NULL, -- amount of tokens transferred\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer\n log_index integer NOT NULL, -- index of the transfer log in the transaction\n PRIMARY KEY (transfer_id)\n)\n", "conversations": [{"role": "user", "content": "Find all addresses that have both sent and received tokens. For each, show the address, the total value sent, and the total value received."}, {"role": "assistant", "content": "SELECT s.address, s.total_sent, r.total_received\nFROM (\n SELECT from_address AS address, SUM(value) AS total_sent\n FROM web3.token_transfers\n GROUP BY from_address\n) s\nJOIN (\n SELECT to_address AS address, SUM(value) AS total_received\n FROM web3.token_transfers\n GROUP BY to_address\n) r\n ON s.address = r.address;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "Show me the medication_id, medication_name, and manufacturer for all medications where the generic_name contains the word 'azole'."}, {"role": "assistant", "content": "SELECT medication_id, medication_name, manufacturer FROM healthcare.medications WHERE generic_name ILIKE '%azole%';"}, {"role": "user", "content": "Can you also include the ndc_code and only show medications where the manufacturer field is not null?"}, {"role": "assistant", "content": "SELECT medication_id, medication_name, manufacturer, ndc_code FROM healthcare.medications WHERE generic_name ILIKE '%azole%' AND manufacturer IS NOT NULL;"}]} {"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;"}]} {"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 erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text )\nCREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )\nCREATE TABLE sui_coins_metadata ( object_id varchar, coin_type varchar, status varchar, decimals bigint, description varchar, icon_url varchar, symbol varchar, name varchar )\nCREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar )\nCREATE TABLE nft_collections (\n blockchain varchar NOT NULL, -- blockchain fields for the functionType in contract\n contract_address varchar NOT NULL, -- Contract address(with bloom filter)\n name varchar NOT NULL, -- name fields for the functionType in contract\n symbol varchar NOT NULL, -- symbol fields for the functionType in contract\n deploy_block_number bigint NOT NULL, -- deploy_block_number fields for the functionType in contract\n deploy_block_time bigint NOT NULL, -- deploy_block_time fields for the functionType in contract\n erc_type varchar NOT NULL, -- The type of token\n owner varchar NOT NULL, -- owner fields for the functionType in contract\n traits varchar NOT NULL, -- traits fields for the functionType in contract\n description varchar NOT NULL, -- description fields for the functionType in contract\n slug varchar NOT NULL, -- slug fields for the functionType in contract\n media_info varchar NOT NULL, -- media_info fields for the functionType in contract\n image_url varchar NOT NULL, -- image_url fields for the functionType in contract\n banner_image_url varchar NOT NULL, -- banner_image_url fields for the functionType in contract\n updated_at bigint NOT NULL, -- updated_at fields for the functionType in contract\n banner varchar NOT NULL, -- banner fields for the functionType in contract\n token_count bigint NOT NULL, -- token_count fields for the functionType in contract\n floor_price varchar NOT NULL, -- floor_price fields for the functionType in contract\n floor_price_symbol varchar NOT NULL, -- floor_price_symbol fields for the functionType in contract\n floor_price_contract varchar NOT NULL, -- floor_price_contract fields for the functionType in contract\n pk integer NOT NULL -- Partition key for the table(floor(deploy_block_time / 1000 / 86400 / 30))\n)\nCREATE TABLE token_prices ( uuid varchar, blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )\nCREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer )\nCREATE TABLE token_info (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar NOT NULL, -- Token tick\n max_supply decimal(38,0) NOT NULL, -- Max supply\n lim decimal(38,0) NOT NULL, -- Limit of each mint\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table)\n)\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\n", "conversations": [{"role": "user", "content": "For each NFT collection deployed on Ethereum, count the number of distinct wallets that have ever held any token from that collection."}, {"role": "assistant", "content": "SELECT\n nc.contract_address,\n nc.name,\n COUNT(DISTINCT nh.wallet_address) AS holder_count\nFROM nft_collections nc\nJOIN nft_holder_historical nh\n ON nc.contract_address = nh.contract_address\nWHERE nc.blockchain = 'Ethereum'\nGROUP BY nc.contract_address, nc.name;"}, {"role": "user", "content": "Include each collection's token_count and floor_price from nft_collections."}, {"role": "assistant", "content": "SELECT\n nc.contract_address,\n nc.name,\n nc.token_count,\n nc.floor_price,\n COUNT(DISTINCT nh.wallet_address) AS holder_count\nFROM nft_collections nc\nJOIN nft_holder_historical nh\n ON nc.contract_address = nh.contract_address\nWHERE nc.blockchain = 'Ethereum'\nGROUP BY\n nc.contract_address,\n nc.name,\n nc.token_count,\n nc.floor_price;"}]} {"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": "List all document IDs, file names, and uploaded timestamps for documents that were uploaded on a weekend."}, {"role": "assistant", "content": "SELECT document_id, file_name, uploaded_at FROM insurance.claim_documents WHERE EXTRACT(DOW FROM uploaded_at) IN (0, 6);"}]} {"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.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\n", "conversations": [{"role": "user", "content": "List all room types that have a King bed and include their maximum occupancy and amenities."}, {"role": "assistant", "content": "SELECT type_name, max_occupancy, amenities FROM hospitality_technology.room_types WHERE bed_type = 'King';"}, {"role": "user", "content": "Please sort them by maximum occupancy in ascending order."}, {"role": "assistant", "content": "SELECT type_name, max_occupancy, amenities FROM hospitality_technology.room_types WHERE bed_type = 'King' ORDER BY max_occupancy ASC;"}]} {"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.trades ( trade_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, security_id character varying(64) NOT NULL, order_id character varying(64), trade_type character varying(10) NOT NULL, quantity numeric(19, 8) NOT NULL, price_per_unit numeric(19, 8) NOT NULL, total_amount numeric(19, 4) NOT NULL, commission numeric(10, 4), trade_timestamp timestamp NOT NULL, settlement_date date, status character varying(32) NOT NULL, execution_venue character varying(100), PRIMARY KEY (trade_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.loans ( loan_id text, account_id text, loan_type text, principal_amount numeric, current_principal_balance numeric, interest_rate numeric, term_months integer, origination_date date, maturity_date date, monthly_payment numeric, collateral_description text, status text )\n", "conversations": [{"role": "user", "content": "Show me all trades (trade_id, security_id, total_amount) where the trade_type is 'Buy' and the execution_venue is 'NYSE', along with the loan details (loan_type, principal_amount) for accounts that have both trades and loans."}, {"role": "assistant", "content": "SELECT t.trade_id, t.security_id, t.total_amount, l.loan_type, l.principal_amount FROM financial_services.trades t JOIN financial_services.loans l ON t.account_id = l.account_id WHERE t.trade_type = 'Buy' AND t.execution_venue = 'NYSE';"}, {"role": "user", "content": "Now modify the query to only include trades with a total_amount greater than $10,000 and loans with a principal_amount greater than $50,000, sorted by total_amount in descending order."}, {"role": "assistant", "content": "SELECT t.trade_id, t.security_id, t.total_amount, l.loan_type, l.principal_amount FROM financial_services.trades t JOIN financial_services.loans l ON t.account_id = l.account_id WHERE t.trade_type = 'Buy' AND t.execution_venue = 'NYSE' AND t.total_amount > 10000 AND l.principal_amount > 50000 ORDER BY t.total_amount DESC;"}]} {"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 character varying(64) NOT NULL, national_id_number character varying(128) NOT NULL UNIQUE, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(20), primary_address text NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), registration_date timestamp NOT NULL, is_verified boolean DEFAULT false, PRIMARY KEY (citizen_id) )\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.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_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) )\n", "conversations": [{"role": "user", "content": "Retrieve the citizen_id, full name, and registration_date of all citizens born before 1980-01-01 who are not verified."}, {"role": "assistant", "content": "SELECT citizen_id,\n first_name || ' ' || last_name AS full_name,\n registration_date\nFROM government_services.citizens\nWHERE date_of_birth < '1980-01-01'\n AND is_verified = FALSE;"}]} {"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 trading_platform.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )\nCREATE TABLE trading_platform.orders ( order_id text, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.assets ( asset_id text, name text, symbol text, type text )\nCREATE TABLE trading_platform.dapps ( dapp_id text, name text, description text, url text )\nCREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) )\nCREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )\nCREATE TABLE trading_platform.notifications ( notification_id text, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "For each user, show their username and the number of unique IP addresses from the peers table where the port is less than 2000."}, {"role": "assistant", "content": "SELECT u.username, COUNT(DISTINCT p.ip_address) AS unique_ip_count\nFROM trading_platform.users u\nJOIN trading_platform.peers p ON u.user_id = p.peer_id\nWHERE p.port < 2000\nGROUP BY u.username;"}, {"role": "user", "content": "This query isn't working because peer_id and user_id don't always match. Could you just show the total number of unique IPs with port < 2000 in the peers table, excluding user data?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT ip_address) AS unique_ip_count\nFROM trading_platform.peers\nWHERE port < 2000;"}, {"role": "user", "content": "Now, for each port number below 2000, show the count of unique IP addresses using that port."}, {"role": "assistant", "content": "SELECT port, COUNT(DISTINCT ip_address) AS unique_ip_count\nFROM trading_platform.peers\nWHERE port < 2000\nGROUP BY port;"}, {"role": "user", "content": "Actually, only show ports where more than one unique IP address exists."}, {"role": "assistant", "content": "SELECT port, COUNT(DISTINCT ip_address) AS unique_ip_count\nFROM trading_platform.peers\nWHERE port < 2000\nGROUP BY port\nHAVING COUNT(DISTINCT ip_address) > 1;"}]} {"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\nCollection 'inspections'. Document structure: { _id: , inspection_id: String, build_id: String (reference), component_id: String (reference, optional), step_id: String (reference, optional), inspection_type: String, inspector_employee_id: String (reference), inspection_timestamp: ISODate, result: String, remarks: String }. Required: inspection_id, build_id, inspection_type, inspector_employee_id, inspection_timestamp, result. Indexes on build_id, component_id, step_id, inspector_employee_id, result.\n", "conversations": [{"role": "user", "content": "Can you help me retrieve all inspection records for a specific build ID, including the inspection type, result, and the timestamp of the inspection, along with the associated component ID if available?"}, {"role": "assistant", "content": "db.inspections.find({ build_id: 'specific_build_id' }, { inspection_type: 1, result: 1, inspection_timestamp: 1, component_id: 1, _id: 0 })"}, {"role": "user", "content": "Can you modify the query to include only inspections that occurred after a specific date, say January 1, 2022?"}, {"role": "assistant", "content": "db.inspections.find({ build_id: 'specific_build_id', inspection_timestamp: { $gt: ISODate('2022-01-01T00:00:00Z') } }, { inspection_type: 1, result: 1, inspection_timestamp: 1, component_id: 1, _id: 0 })"}, {"role": "user", "content": "What if I want to further filter the results to show only inspections with a 'Pass' result?"}, {"role": "assistant", "content": "db.inspections.find({ build_id: 'specific_build_id', inspection_timestamp: { $gt: ISODate('2022-01-01T00:00:00Z') }, result: 'Pass' }, { inspection_type: 1, result: 1, inspection_timestamp: 1, component_id: 1, _id: 0 })"}, {"role": "user", "content": "Can you also sort the results by inspection timestamp in descending order?"}, {"role": "assistant", "content": "db.inspections.find({ build_id: 'specific_build_id', inspection_timestamp: { $gt: ISODate('2022-01-01T00:00:00Z') }, result: 'Pass' }, { inspection_type: 1, result: 1, inspection_timestamp: 1, component_id: 1, _id: 0 }).sort({ inspection_timestamp: -1 })"}]} {"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 transportation.vehicles ( vehicle_id text, license_plate text, vin text, make text, model text, year integer, type text, capacity integer, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.passengers ( passenger_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\nCREATE TABLE transportation.bookings ( booking_id text, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )\n", "conversations": [{"role": "user", "content": "Show each passenger's first_name, last_name, and the total number of bookings they have made."}, {"role": "assistant", "content": "SELECT p.passenger_id, p.first_name, p.last_name, COUNT(b.booking_id) AS booking_count\nFROM transportation.passengers p\nLEFT JOIN transportation.bookings b ON p.passenger_id = b.passenger_id\nGROUP BY p.passenger_id, p.first_name, p.last_name;"}, {"role": "user", "content": "Filter to only include passengers who have made more than 3 bookings."}, {"role": "assistant", "content": "SELECT p.passenger_id, p.first_name, p.last_name, COUNT(b.booking_id) AS booking_count\nFROM transportation.passengers p\nLEFT JOIN transportation.bookings b ON p.passenger_id = b.passenger_id\nGROUP BY p.passenger_id, p.first_name, p.last_name\nHAVING COUNT(b.booking_id) > 3;"}, {"role": "user", "content": "Also include the average fare for these passengers and order by booking_count descending."}, {"role": "assistant", "content": "SELECT p.passenger_id, p.first_name, p.last_name, COUNT(b.booking_id) AS booking_count, AVG(b.fare) AS avg_fare\nFROM transportation.passengers p\nLEFT JOIN transportation.bookings b ON p.passenger_id = b.passenger_id\nGROUP BY p.passenger_id, p.first_name, p.last_name\nHAVING COUNT(b.booking_id) > 3\nORDER BY booking_count DESC;"}]} {"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.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": "How many beneficiaries exist for each relationship type in the policy_beneficiaries table? Return relationship and beneficiary_count, ordered by count descending."}, {"role": "assistant", "content": "SELECT relationship, COUNT(*) AS beneficiary_count\nFROM insurance.policy_beneficiaries\nGROUP BY relationship\nORDER BY beneficiary_count DESC;"}]} {"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 )\nCREATE TABLE financial_services.accounts (\n account_id character varying(64) NOT NULL, -- unique identifier for the account\n customer_id character varying(64) NOT NULL, -- foreign key linking to the customer\n account_number character varying(128) NOT NULL UNIQUE, -- unique account number visible to customer\n account_type character varying(50) NOT NULL, -- e.g., Checking, Savings, Investment, Loan, Credit Card\n balance numeric(19, 4) NOT NULL DEFAULT 0.00, -- current account balance\n currency character varying(3) NOT NULL, -- currency code (e.g., USD, EUR)\n opened_date date NOT NULL, -- date the account was opened\n status character varying(32) NOT NULL, -- e.g., Open, Closed, Frozen\n interest_rate numeric(5, 4), -- annual interest rate, if applicable\n last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last account update\n PRIMARY KEY (account_id),\n FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id)\n)\nCREATE TABLE financial_services.securities ( security_id text PRIMARY KEY, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )\nCREATE TABLE financial_services.employees ( employee_id text PRIMARY KEY, first_name text, last_name text, job_title text, department text, branch_id text, email text, phone_extension text, hire_date date, termination_date date, manager_id text, status text )\n", "conversations": [{"role": "user", "content": "List all customers along with any employees who have the same last name. For each pair, display customer_id, customer full name, employee_id, employee full name, and their respective emails."}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_full_name,\n c.email AS customer_email,\n e.employee_id,\n e.first_name || ' ' || e.last_name AS employee_full_name,\n e.email AS employee_email\nFROM financial_services.customers c\nJOIN financial_services.employees e ON c.last_name = e.last_name;"}, {"role": "user", "content": "Only show results for customers and employees who have non-null emails."}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_full_name,\n c.email AS customer_email,\n e.employee_id,\n e.first_name || ' ' || e.last_name AS employee_full_name,\n e.email AS employee_email\nFROM financial_services.customers c\nJOIN financial_services.employees e ON c.last_name = e.last_name\nWHERE c.email IS NOT NULL AND e.email IS NOT NULL;"}, {"role": "user", "content": "Can you also add the city for the customer and the department for the employee?"}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_full_name,\n c.city AS customer_city,\n c.email AS customer_email,\n e.employee_id,\n e.first_name || ' ' || e.last_name AS employee_full_name,\n e.department AS employee_department,\n e.email AS employee_email\nFROM financial_services.customers c\nJOIN financial_services.employees e ON c.last_name = e.last_name\nWHERE c.email IS NOT NULL AND e.email IS NOT NULL;"}]} {"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 transportation.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text )\n", "conversations": [{"role": "user", "content": "How many fuel logs were created for each unit of measurement? Show the unit and the corresponding count."}, {"role": "assistant", "content": "SELECT unit, COUNT(*) as log_count\nFROM transportation.fuel_logs\nGROUP BY unit;"}, {"role": "user", "content": "Please include only units where more than 10 logs exist and order the results by log_count descending."}, {"role": "assistant", "content": "SELECT unit, COUNT(*) as log_count\nFROM transportation.fuel_logs\nGROUP BY unit\nHAVING COUNT(*) > 10\nORDER BY log_count DESC;"}]} {"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 trading_platform.assets ( asset_id text PRIMARY KEY, name text, symbol text, type text )\nCREATE TABLE trading_platform.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean )\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.metadata (\n metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata\n asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with\n key character varying(128) NOT NULL, -- key of the metadata\n value text NOT NULL, -- value of the metadata\n PRIMARY KEY (metadata_id)\n)\nCREATE TABLE trading_platform.kyc_audit (\n kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit\n user_id character varying(64) NOT NULL, -- identifier of the user being audited\n status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)\n reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed\n PRIMARY KEY (kyc_audit_id)\n)\nCREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the number of UTXOs associated with each unique address in the system."}, {"role": "assistant", "content": "SELECT address, COUNT(utxo_id) FROM trading_platform.utxos GROUP BY address;"}]} {"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.loans (\n loan_id character varying(64) NOT NULL, -- unique identifier for the loan, could be same as account_id\n account_id character varying(64) NOT NULL UNIQUE, -- link to the general account record\n loan_type character varying(50) NOT NULL, -- e.g., Mortgage, Personal, Auto, Student\n principal_amount numeric(19, 4) NOT NULL, -- original loan amount\n current_principal_balance numeric(19, 4) NOT NULL, -- remaining principal\n interest_rate numeric(6, 4) NOT NULL, -- annual interest rate\n term_months integer NOT NULL, -- loan term in months\n origination_date date NOT NULL, -- date the loan was disbursed\n maturity_date date NOT NULL, -- date the loan is due to be fully repaid\n monthly_payment numeric(12, 4), -- scheduled monthly payment amount\n collateral_description text, -- description of collateral, if secured loan\n status character varying(32) NOT NULL, -- e.g., Active, Paid Off, Defaulted\n PRIMARY KEY (loan_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id)\n)\n", "conversations": [{"role": "user", "content": "I need a report that shows, for each account status and loan type, how many loans there are and the average principal amount."}, {"role": "assistant", "content": "SELECT a.status,\n l.loan_type,\n COUNT(*) AS total_loans,\n AVG(l.principal_amount) AS average_principal\nFROM financial_services.loans l\nJOIN financial_services.accounts a ON l.account_id = a.account_id\nGROUP BY a.status, l.loan_type;"}, {"role": "user", "content": "Actually, include only loans whose status is 'Active'."}, {"role": "assistant", "content": "SELECT a.status,\n l.loan_type,\n COUNT(*) AS total_loans,\n AVG(l.principal_amount) AS average_principal\nFROM financial_services.loans l\nJOIN financial_services.accounts a ON l.account_id = a.account_id\nWHERE l.status = 'Active'\nGROUP BY a.status, l.loan_type;"}, {"role": "user", "content": "Also exclude any loan_type groups that have fewer than 5 loans."}, {"role": "assistant", "content": "SELECT a.status,\n l.loan_type,\n COUNT(*) AS total_loans,\n AVG(l.principal_amount) AS average_principal\nFROM financial_services.loans l\nJOIN financial_services.accounts a ON l.account_id = a.account_id\nWHERE l.status = 'Active'\nGROUP BY a.status, l.loan_type\nHAVING COUNT(*) >= 5;"}, {"role": "user", "content": "Finally, sort the output by average_principal in descending order."}, {"role": "assistant", "content": "SELECT a.status,\n l.loan_type,\n COUNT(*) AS total_loans,\n AVG(l.principal_amount) AS average_principal\nFROM financial_services.loans l\nJOIN financial_services.accounts a ON l.account_id = a.account_id\nWHERE l.status = 'Active'\nGROUP BY a.status, l.loan_type\nHAVING COUNT(*) >= 5\nORDER BY average_principal DESC;"}]} {"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 trading_platform.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\nCREATE TABLE trading_platform.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )\nCREATE TABLE trading_platform.orders ( order_id text PRIMARY KEY, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades (\n trade_id character varying(64) NOT NULL, -- unique identifier for the trade\n order_id character varying(64) NOT NULL, -- identifier of the order that led to the trade\n buyer_id character varying(64) NOT NULL, -- identifier of the buyer\n seller_id character varying(64) NOT NULL, -- identifier of the seller\n asset_id character varying(64) NOT NULL, -- identifier of the asset being traded\n quantity numeric(38,14) NOT NULL, -- quantity of the asset in the trade\n price numeric(38,14) NOT NULL, -- price per unit of the asset\n traded_at timestamp NOT NULL, -- time when the trade was executed\n PRIMARY KEY (trade_id)\n)\nCREATE TABLE trading_platform.assets ( asset_id text PRIMARY KEY, name text, symbol text, type text )\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.metadata (\n metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata\n asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with\n key character varying(128) NOT NULL, -- key of the metadata\n value text NOT NULL, -- value of the metadata\n PRIMARY KEY (metadata_id)\n)\nCREATE TABLE trading_platform.kyc_audit (\n kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit\n user_id character varying(64) NOT NULL, -- identifier of the user being audited\n status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)\n reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed\n PRIMARY KEY (kyc_audit_id)\n)\nCREATE TABLE trading_platform.logs (\n log_id character varying(64) NOT NULL, -- unique identifier for the log entry\n user_id character varying(64), -- identifier of the user associated with the log entry\n action character varying(128) NOT NULL, -- action performed\n details text NOT NULL, -- details of the action\n logged_at timestamp NOT NULL, -- time when the log entry was created\n PRIMARY KEY (log_id)\n)\nCREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "Which users have registered but never created a wallet? Show their user_id, username, and email."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, u.email\nFROM trading_platform.users u\nLEFT JOIN trading_platform.wallets w ON u.user_id = w.user_id\nWHERE w.wallet_id IS NULL;"}]} {"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 character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\n", "conversations": [{"role": "user", "content": "List each client along with another client who shares the same status."}, {"role": "assistant", "content": "SELECT c1.client_id AS client1_id, c1.first_name AS client1_first_name, c1.last_name AS client1_last_name, c2.client_id AS client2_id, c2.first_name AS client2_first_name, c2.last_name AS client2_last_name, c1.status FROM legal_services.clients c1 JOIN legal_services.clients c2 ON c1.status = c2.status AND c1.client_id <> c2.client_id;"}, {"role": "user", "content": "Actually, I only want pairs where the status is 'prospect'."}, {"role": "assistant", "content": "SELECT c1.client_id AS client1_id, c1.first_name AS client1_first_name, c1.last_name AS client1_last_name, c2.client_id AS client2_id, c2.first_name AS client2_first_name, c2.last_name AS client2_last_name, c1.status FROM legal_services.clients c1 JOIN legal_services.clients c2 ON c1.status = c2.status AND c1.client_id <> c2.client_id WHERE c1.status = 'prospect';"}, {"role": "user", "content": "And only include pairs where both clients have provided a phone number."}, {"role": "assistant", "content": "SELECT c1.client_id AS client1_id, c1.first_name AS client1_first_name, c1.last_name AS client1_last_name, c2.client_id AS client2_id, c2.first_name AS client2_first_name, c2.last_name AS client2_last_name, c1.status FROM legal_services.clients c1 JOIN legal_services.clients c2 ON c1.status = c2.status AND c1.client_id <> c2.client_id WHERE c1.status = 'prospect' AND c1.phone IS NOT NULL AND c2.phone IS NOT NULL;"}]} {"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.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\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 )\n", "conversations": [{"role": "user", "content": "List all documents, including their name and upload timestamp, along with the first and last name of the client associated with the case they belong to."}, {"role": "assistant", "content": "SELECT d.document_name, d.upload_timestamp, c.first_name AS client_first_name, c.last_name AS client_last_name FROM documents AS d JOIN cases AS cs ON d.case_id = cs.case_id JOIN clients AS c ON cs.client_id = c.client_id;"}]} {"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.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve the first name, last name, and email for all guests."}, {"role": "assistant", "content": "SELECT first_name, last_name, email FROM hospitality_technology.guests;"}, {"role": "user", "content": "Can you also include their loyalty member ID and whether they have given communication consent?"}, {"role": "assistant", "content": "SELECT first_name, last_name, email, loyalty_member_id, communication_consent FROM hospitality_technology.guests;"}, {"role": "user", "content": "Filter this list to only include guests who have a loyalty member ID, have consented to communication, and were created in 2023. Order the results by their last name."}, {"role": "assistant", "content": "SELECT first_name, last_name, email, loyalty_member_id, communication_consent FROM hospitality_technology.guests WHERE loyalty_member_id IS NOT NULL AND communication_consent = TRUE AND created_at >= '2023-01-01' AND created_at < '2024-01-01' ORDER BY last_name;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text PRIMARY KEY, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes int, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\n", "conversations": [{"role": "user", "content": "I need to get a list of all patients who had an appointment in the last 30 days, including patient ID, first and last name, appointment_time, and any associated diagnosis description."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n a.appointment_time,\n d.description\nFROM healthcare.appointments a\nJOIN healthcare.patients p\n ON a.patient_id = p.patient_id\nLEFT JOIN healthcare.medical_records mr\n ON a.appointment_id = mr.appointment_id\nLEFT JOIN healthcare.diagnoses d\n ON mr.record_id = d.record_id\nWHERE a.appointment_time >= current_timestamp - INTERVAL '30 days';"}, {"role": "user", "content": "Exclude any appointments with status 'Cancelled'."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n a.appointment_time,\n d.description\nFROM healthcare.appointments a\nJOIN healthcare.patients p\n ON a.patient_id = p.patient_id\nLEFT JOIN healthcare.medical_records mr\n ON a.appointment_id = mr.appointment_id\nLEFT JOIN healthcare.diagnoses d\n ON mr.record_id = d.record_id\nWHERE a.appointment_time >= current_timestamp - INTERVAL '30 days'\n AND a.status <> 'Cancelled';"}, {"role": "user", "content": "Also, sort the results by appointment_time descending."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n a.appointment_time,\n d.description\nFROM healthcare.appointments a\nJOIN healthcare.patients p\n ON a.patient_id = p.patient_id\nLEFT JOIN healthcare.medical_records mr\n ON a.appointment_id = mr.appointment_id\nLEFT JOIN healthcare.diagnoses d\n ON mr.record_id = d.record_id\nWHERE a.appointment_time >= current_timestamp - INTERVAL '30 days'\n AND a.status <> 'Cancelled'\nORDER BY a.appointment_time DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "List all appointments, showing the appointment ID, appointment time, patient's insurance plan name, and status."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.appointment_time, ip.plan_name, a.status FROM healthcare.appointments a LEFT JOIN healthcare.patient_insurance pi ON a.patient_id = pi.patient_id AND pi.is_primary = TRUE LEFT JOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id;"}, {"role": "user", "content": "Only show appointments where the status is 'Scheduled'."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.appointment_time, ip.plan_name, a.status FROM healthcare.appointments a LEFT JOIN healthcare.patient_insurance pi ON a.patient_id = pi.patient_id AND pi.is_primary = TRUE LEFT JOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id WHERE a.status = 'Scheduled';"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id 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) )\n", "conversations": [{"role": "user", "content": "List the doctor ID, last name, and the date they were updated, for all doctors updated in the year 2024."}, {"role": "assistant", "content": "SELECT doctor_id, last_name, updated_at FROM healthcare.doctors WHERE updated_at >= '2024-01-01' AND updated_at < '2025-01-01';"}, {"role": "user", "content": "Sort this list by their update date, with the most recently updated doctors appearing first."}, {"role": "assistant", "content": "SELECT doctor_id, last_name, updated_at FROM healthcare.doctors WHERE updated_at >= '2024-01-01' AND updated_at < '2025-01-01' ORDER BY updated_at DESC;"}]} {"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.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\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)\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)\n", "conversations": [{"role": "user", "content": "Show the total hours spent by each lawyer across all their time entries. Display the lawyer's first name, last name, and the total hours."}, {"role": "assistant", "content": "SELECT l.first_name, l.last_name, SUM(te.hours_spent) AS total_hours FROM legal_services.time_entries te JOIN legal_services.lawyers l ON te.lawyer_id = l.lawyer_id GROUP BY l.lawyer_id, l.first_name, l.last_name ORDER BY total_hours DESC;"}, {"role": "user", "content": "Modify the previous query to only include time entries that are marked as billable."}, {"role": "assistant", "content": "SELECT l.first_name, l.last_name, SUM(te.hours_spent) AS total_billable_hours FROM legal_services.time_entries te JOIN legal_services.lawyers l ON te.lawyer_id = l.lawyer_id WHERE te.is_billable = true GROUP BY l.lawyer_id, l.first_name, l.last_name ORDER BY total_billable_hours DESC;"}, {"role": "user", "content": "Now, filter the results to only show lawyers who are partners and have logged more than 100 billable hours in total."}, {"role": "assistant", "content": "SELECT l.first_name, l.last_name, SUM(te.hours_spent) AS total_billable_hours FROM legal_services.time_entries te JOIN legal_services.lawyers l ON te.lawyer_id = l.lawyer_id WHERE te.is_billable = true AND l.is_partner = true GROUP BY l.lawyer_id, l.first_name, l.last_name HAVING SUM(te.hours_spent) > 100 ORDER BY total_billable_hours DESC;"}]} {"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.applications ( application_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, submitted_at timestamp NOT NULL, status character varying(50) NOT NULL, last_updated_at timestamp NOT NULL, assigned_employee_id character varying(64), decision_date date, notes text, reference_number character varying(100) UNIQUE, PRIMARY KEY (application_id) )\n", "conversations": [{"role": "user", "content": "List the reference number and status for applications where the notes contain the keyword 'urgent'."}, {"role": "assistant", "content": "SELECT reference_number, status FROM government_services.applications WHERE notes ILIKE '%urgent%';"}, {"role": "user", "content": "Among those, show only the applications with a status of 'Pending'."}, {"role": "assistant", "content": "SELECT reference_number, status FROM government_services.applications WHERE notes ILIKE '%urgent%' AND status = 'Pending';"}]} {"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 token_metas ( block_timestamp.timestamp, block_number.bigint, transaction_hash.text, transaction_index.bigint, from_address.text, contract_address.text, symbol.text, total_supply.text, name.text, decimals.bigint, is_erc20.integer, is_erc721.integer, is_erc1155.integer, is_proxy.integer, extra_info.text, pk.integer )\nCREATE TABLE erc1155_approval_for_all ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text )\nCREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text )\nCREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )\nCREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )\nCREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )\nCREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )\nCREATE TABLE nft_metadata ( blockchain.text, contract_address.text, token_id.text, contract_name.text, erc_type.text, amount.bigint, minter.text, owner.text, mint_block_number.bigint, mint_time.bigint, mint_transaction_hash.text, mint_price.text, token_uri.text, metadata.text, name.text, image_uri.text, traits.text, updated_at.bigint, status.text, rarity_score.real, rarity_rank.integer, unique_attribute_count.integer, pk.integer )\nCREATE TABLE nft_collections ( blockchain.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer )\nCREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE mud_holesky_redstone ( address.text, table_id.text, key_bytes.text, key0.text, key1.text, static_data.text, encoded_lengths.text, dynamic_data.text, is_deleted.boolean, block_number.bigint, log_index.bigint )\nCREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )\nCREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )\n", "conversations": [{"role": "user", "content": "List all NFTs on the 'Ethereum' blockchain with a rarity score above 85. Show their name, contract address, token ID, and rarity score."}, {"role": "assistant", "content": "SELECT name, contract_address, token_id, rarity_score FROM nft_metadata WHERE blockchain = 'Ethereum' AND rarity_score > 85;"}, {"role": "user", "content": "For those NFTs on Ethereum with rarity score above 85, can you add their collection name and only show those that are 'ERC721' type? Also, order them by rarity score descending and limit to 10."}, {"role": "assistant", "content": "SELECT nm.name, nm.contract_address, nm.token_id, nm.rarity_score, nc.name AS collection_name FROM nft_metadata AS nm JOIN nft_collections AS nc ON nm.contract_address = nc.contract_address WHERE nm.blockchain = 'Ethereum' AND nm.rarity_score > 85 AND nm.erc_type = 'ERC721' ORDER BY nm.rarity_score DESC LIMIT 10;"}, {"role": "user", "content": "Actually, instead of ERC721, show me the 'ERC1155' type NFTs from the same list. And sort them by rarity rank ascending instead."}, {"role": "assistant", "content": "SELECT nm.name, nm.contract_address, nm.token_id, nm.rarity_score, nc.name AS collection_name FROM nft_metadata AS nm JOIN nft_collections AS nc ON nm.contract_address = nc.contract_address WHERE nm.blockchain = 'Ethereum' AND nm.rarity_score > 85 AND nm.erc_type = 'ERC1155' ORDER BY nm.rarity_rank ASC LIMIT 10;"}, {"role": "user", "content": "Show me the top 5 'ERC1155' NFTs from that list (Ethereum, rarity score > 85), ordered by rarity rank ascending, but also include the token URI."}, {"role": "assistant", "content": "SELECT nm.name, nm.contract_address, nm.token_id, nm.rarity_score, nc.name AS collection_name, nm.token_uri FROM nft_metadata AS nm JOIN nft_collections AS nc ON nm.contract_address = nc.contract_address WHERE nm.blockchain = 'Ethereum' AND nm.rarity_score > 85 AND nm.erc_type = 'ERC1155' ORDER BY nm.rarity_rank ASC LIMIT 5;"}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "Show me the first name, last name, and job title of employees along with the first name and last name of their managers."}, {"role": "assistant", "content": "SELECT e.first_name AS employee_first_name, e.last_name AS employee_last_name, e.job_title, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM government_services.employees e\nLEFT JOIN government_services.employees m\n ON e.manager_employee_id = m.employee_id;"}, {"role": "user", "content": "Can you filter this to only show employees who report to a manager whose job_title is 'Supervisor'?"}, {"role": "assistant", "content": "SELECT e.first_name AS employee_first_name, e.last_name AS employee_last_name, e.job_title, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM government_services.employees e\nJOIN government_services.employees m\n ON e.manager_employee_id = m.employee_id\nWHERE m.job_title = 'Supervisor';"}]} {"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\n// Node Label: :Station\n// Properties:\n// station_id: String (Constraint: UNIQUE)\n// station_name: String\n// city: String (Index recommended)\n// state_province: String\n// country_code: String\n// address: String\n// timezone: String\n// number_of_platforms: Integer\n// created_at: DateTime\n// last_updated_at: DateTime\n// Example Cypher CREATE:\n// CREATE (:Station {station_id: 'station_xyz', station_name: 'Grand Central Terminal', city: 'New York', ...})\n// Node Label: :Platform\n// Properties:\n// platform_id: String (Constraint: UNIQUE)\n// platform_number: String\n// track_number: String\n// status: String\n// length_meters: Float\n// accessible: Boolean\n// Relationship: (:Platform)-[:LOCATED_AT]->(:Station)\n// Example Cypher CREATE:\n// MATCH (s:Station {station_id: 'station_xyz'})\n// CREATE (p:Platform {platform_id: 'plat_123', ...})-[:LOCATED_AT]->(s)\n// Node Label: :Train\n// Properties:\n// train_id: String (Constraint: UNIQUE)\n// train_number: String (Constraint: UNIQUE)\n// model: String\n// manufacturer: String\n// year_manufactured: Integer\n// capacity: Integer\n// status: String\n// last_maintenance_date: Date\n// next_maintenance_date: Date\n// Example Cypher CREATE:\n// CREATE (:Train {train_id: 'train_789', train_number: 'Acela 2151', ...})\n// Node Label: :TrainCar\n// Properties:\n// car_id: String (Constraint: UNIQUE)\n// car_number: String\n// car_type: String\n// class: String\n// capacity: Integer\n// features: String (Or List if driver supports)\n// Relationship: (:TrainCar)-[:PART_OF_TRAIN]->(:Train)\n// Example Cypher CREATE:\n// MATCH (t:Train {train_id: 'train_789'})\n// CREATE (c:TrainCar {car_id: 'car_abc', ...})-[:PART_OF_TRAIN]->(t)\n// Node Label: :Route\n// Properties:\n// route_id: String (Constraint: UNIQUE)\n// route_name: String\n// description: String\n// is_active: Boolean\n// Relationships:\n// (:Route)-[:STARTS_AT]->(:Station)\n// (:Route)-[:ENDS_AT]->(:Station)\n// Example Cypher CREATE:\n// MATCH (origin:Station {station_id: 'station_bos'}), (dest:Station {station_id: 'station_was'})\n// CREATE (r:Route {route_id: 'route_ne_corr', ...})-[:STARTS_AT]->(origin), (r)-[:ENDS_AT]->(dest)\n// Relationship: (:Route)-[rel:HAS_STOP]->(:Station)\n// Relationship Properties on :HAS_STOP:\n// sequence_order: Integer\n// distance_from_previous_km: Float\n// typical_stop_duration_minutes: Integer\n// Example Cypher CREATE:\n// MATCH (r:Route {route_id: 'route_ne_corr'}), (s:Station {station_id: 'station_pvd'})\n// CREATE (r)-[:HAS_STOP {sequence_order: 2, distance_from_previous_km: 70.5, ...}]->(s)\n// Node Label: :ScheduledTrip (or just :Trip)\n// Properties:\n// schedule_id: String (Constraint: UNIQUE)\n// departure_datetime: DateTime\n// arrival_datetime: DateTime\n// status: String\n// notes: String\n// Relationships:\n// (:ScheduledTrip)-[:USES_TRAIN]->(:Train)\n// (:ScheduledTrip)-[:FOLLOWS_ROUTE]->(:Route)\n// Example Cypher CREATE:\n// MATCH (t:Train {train_id: 'train_789'}), (r:Route {route_id: 'route_ne_corr'})\n// CREATE (sched:ScheduledTrip {schedule_id: 'sched_1122', ...})-[:USES_TRAIN]->(t), (sched)-[:FOLLOWS_ROUTE]->(r)\n// Relationship: (:ScheduledTrip)-[rel:SCHEDULED_STOP]->(:Station)\n// Relationship Properties on :SCHEDULED_STOP:\n// sequence_order: Integer\n// platform_id: String (references Platform node if modeled, or just store ID)\n// scheduled_arrival_time: DateTime\n// scheduled_departure_time: DateTime\n// actual_arrival_time: DateTime\n// actual_departure_time: DateTime\n// status: String\n// Example Cypher CREATE:\n// MATCH (sched:ScheduledTrip {schedule_id: 'sched_1122'}), (s:Station {station_id: 'station_pvd'})\n// CREATE (sched)-[:SCHEDULED_STOP {sequence_order: 2, platform_id: 'plat_pvd_1', ...}]->(s)\n// Node Label: :Passenger\n// Properties:\n// passenger_id: String (Constraint: UNIQUE)\n// first_name: String\n// last_name: String\n// email: String (Constraint: UNIQUE, if not null)\n// phone_number: String (Constraint: UNIQUE, if not null)\n// date_of_birth: Date\n// loyalty_program_id: String\n// created_at: DateTime\n// Example Cypher CREATE:\n// CREATE (:Passenger {passenger_id: 'pass_pqr', first_name: 'Alice', ...})\n// Node Label: :Booking\n// Properties:\n// booking_id: String (Constraint: UNIQUE)\n// booking_datetime: DateTime\n// status: String\n// total_price: Float\n// currency_code: String\n// special_requests: String\n// Relationships:\n// (:Passenger)-[:MADE_BOOKING]->(:Booking)\n// (:Booking)-[:FOR_TRIP]->(:ScheduledTrip)\n// Example Cypher CREATE:\n// MATCH (p:Passenger {passenger_id: 'pass_pqr'}), (sched:ScheduledTrip {schedule_id: 'sched_1122'})\n// CREATE (p)-[:MADE_BOOKING]->(b:Booking {booking_id: 'book_zyx', ...})-[:FOR_TRIP]->(sched)\n// Node Label: :Ticket\n// Properties:\n// ticket_id: String (Constraint: UNIQUE)\n// seat_number: String\n// ticket_type: String\n// price: Float\n// is_checked_in: Boolean\n// qr_code_data: String\n// Relationships:\n// (:Ticket)-[:PART_OF_BOOKING]->(:Booking)\n// (:Ticket)-[:ASSIGNED_TO_CAR]->(:TrainCar)\n// Example Cypher CREATE:\n// MATCH (b:Booking {booking_id: 'book_zyx'}), (c:TrainCar {car_id: 'car_abc'})\n// CREATE (t:Ticket {ticket_id: 'tkt_1a2b', ...})-[:PART_OF_BOOKING]->(b), (t)-[:ASSIGNED_TO_CAR]->(c)\n// Node Label: :Staff\n// Properties:\n// staff_id: String (Constraint: UNIQUE)\n// first_name: String\n// last_name: String\n// role: String\n// employee_number: String (Constraint: UNIQUE)\n// hire_date: Date\n// contact_email: String (Constraint: UNIQUE, if not null)\n// contact_phone: String\n// is_active: Boolean\n// Relationship (Optional):\n// (:Staff)-[:BASED_AT]->(:Station)\n// Example Cypher CREATE:\n// CREATE (:Staff {staff_id: 'staff_mno', first_name: 'Bob', ...})\n// OPTIONAL MATCH (s:Station {station_id: 'station_xyz'}) // If primary_station_id exists\n// WITH s, staff_mno // Need to get the created staff node reference\n// WHERE s IS NOT NULL\n// CREATE (staff_mno)-[:BASED_AT]->(s)\n", "conversations": [{"role": "user", "content": "\u80fd\u5426\u5e2e\u6211\u7edf\u8ba1\u7279\u5b9a\u8f66\u7ad9(station_id \u4e3a 'station_xyz')\u7684\u6240\u6709\u5de5\u4f5c\u4eba\u5458\u6570\u91cf\uff1f"}, {"role": "assistant", "content": "MATCH (s:Station {station_id: 'station_xyz'})<-[:BASED_AT]-(staff:Staff)\nRETURN COUNT(staff) AS total_staff"}]} {"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.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Get the total number of appointments grouped by status."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS appointment_count\nFROM healthcare.appointments\nGROUP BY status;"}, {"role": "user", "content": "Now filter to include only statuses with more than 50 appointments."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS appointment_count\nFROM healthcare.appointments\nGROUP BY status\nHAVING COUNT(*) > 50;"}]} {"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;"}]} {"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) )\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) )\n", "conversations": [{"role": "user", "content": "List all document IDs and their corresponding location names for documents that are associated with applications assigned to a service location in the city of 'Los Angeles'."}, {"role": "assistant", "content": "SELECT d.document_id, sl.location_name\nFROM government_services.documents d\nJOIN government_services.service_locations sl\n ON d.application_id = sl.location_id\nWHERE sl.city = 'Los Angeles';"}]} {"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 )\nCREATE TABLE financial_services.trades ( trade_id text, account_id text, security_id text, order_id text, trade_type text, quantity numeric, price_per_unit numeric, total_amount numeric, commission numeric, trade_timestamp timestamp, settlement_date date, status text, execution_venue text )\n", "conversations": [{"role": "user", "content": "List all customers who share an address with another customer. Show both customer IDs, their full names, and the shared address."}, {"role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, a.first_name AS first_name_a, a.last_name AS last_name_a, \n b.customer_id AS customer_id_b, b.first_name AS first_name_b, b.last_name AS last_name_b, \n a.address\nFROM financial_services.customers a\nJOIN financial_services.customers b ON a.address = b.address AND a.customer_id <> b.customer_id;"}, {"role": "user", "content": "Only include pairs where both customers are in the same city and state."}, {"role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, a.first_name AS first_name_a, a.last_name AS last_name_a, \n b.customer_id AS customer_id_b, b.first_name AS first_name_b, b.last_name AS last_name_b, \n a.address, a.city, a.state\nFROM financial_services.customers a\nJOIN financial_services.customers b ON a.address = b.address AND a.city = b.city AND a.state = b.state AND a.customer_id <> b.customer_id;"}, {"role": "user", "content": "Now, show only unique unordered pairs (i.e., only one (A,B) or (B,A) per pair) and order by address ascending."}, {"role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, a.first_name AS first_name_a, a.last_name AS last_name_a, \n b.customer_id AS customer_id_b, b.first_name AS first_name_b, b.last_name AS last_name_b, \n a.address, a.city, a.state\nFROM financial_services.customers a\nJOIN financial_services.customers b ON a.address = b.address AND a.city = b.city AND a.state = b.state AND a.customer_id < b.customer_id\nORDER BY a.address ASC;"}]} {"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.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.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 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": "For each service location, show the location name, city, and the number of appointments scheduled at that location."}, {"role": "assistant", "content": "SELECT sl.location_name, sl.city, COUNT(a.appointment_id) AS appointment_count\nFROM government_services.service_locations sl\nLEFT JOIN government_services.appointments a ON sl.location_id = a.location_id\nGROUP BY sl.location_name, sl.city;"}]} {"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\n// Use Hashes to store station details. Key format: station:\n// Example:\n// HSET station:station_xyz station_id \"station_xyz\" station_name \"Grand Central Terminal\" city \"New York\" state_province \"NY\" country_code \"USA\" address \"89 E 42nd St...\" timezone \"America/New_York\" number_of_platforms 44 created_at \"2023-01-15T10:00:00Z\" last_updated_at \"2023-10-28T15:30:00Z\"\n\n// To quickly find stations by city (optional index):\n// SADD stations:city:NewYork station:station_xyz\n// Use Hashes for platform details. Key format: platform:\n// HSET platform:plat_123 platform_id \"plat_123\" station_id \"station_xyz\" platform_number \"1A\" track_number \"T1\" status \"Operational\" length_meters 250.50 accessible 1\n\n// To link platforms to stations (optional):\n// SADD station:station_xyz:platforms platform:plat_123 platform:plat_456\n// Use Hashes for train details. Key format: train:\n// HSET train:train_789 train_id \"train_789\" train_number \"Acela 2151\" model \"Siemens Velaro\" ... status \"Active\" ...\n\n// To find train by train_number (optional index):\n// SET train_number:\"Acela 2151\" train:train_789\n// Use Hashes for car details. Key format: car:\n// HSET car:car_abc car_id \"car_abc\" train_id \"train_789\" car_number \"C3\" car_type \"Passenger\" class \"Business\" capacity 60 features \"WiFi,Power Outlet\"\n\n// To link cars to trains (optional):\n// SADD train:train_789:cars car:car_abc car:car_def\n// Use Hashes for route details. Key format: route:\n// HSET route:route_ne_corr route_id \"route_ne_corr\" route_name \"Northeast Corridor\" ... origin_station_id \"station_bos\" ... is_active 1\n// Use Hashes for details. Key format: route_station:\n// HSET route_station:rs_ne_1 route_station_id \"rs_ne_1\" route_id \"route_ne_corr\" station_id \"station_bos\" sequence_order 1 ...\n\n// To find stops for a route, use a Sorted Set (score by sequence_order):\n// ZADD route:route_ne_corr:stops 1 route_station:rs_ne_1\n// ZADD route:route_ne_corr:stops 2 route_station:rs_ne_2\n// Use Hashes for passenger details. Key format: passenger:\n// HSET passenger:pass_pqr passenger_id \"pass_pqr\" first_name \"Alice\" last_name \"Smith\" email \"alice.smith@example.com\" ...\n\n// To find passenger by email (optional index):\n// SET passenger_email:\"alice.smith@example.com\" passenger:pass_pqr\n// Use Hashes for booking details. Key format: booking:\n// HSET booking:book_zyx booking_id \"book_zyx\" passenger_id \"pass_pqr\" schedule_id \"sched_1122\" ... status \"Confirmed\" ...\n\n// To link bookings to passengers/schedules (optional):\n// SADD passenger:pass_pqr:bookings booking:book_zyx\n// SADD schedule:sched_1122:bookings booking:book_zyx\n// Use Hashes for ticket details. Key format: ticket:\n// HSET ticket:tkt_1a2b ticket_id \"tkt_1a2b\" booking_id \"book_zyx\" car_id \"car_abc\" seat_number \"12A\" ... is_checked_in 0 ...\n\n// To link tickets to bookings (optional):\n// SADD booking:book_zyx:tickets ticket:tkt_1a2b\n", "conversations": [{"role": "user", "content": "\u80fd\u5426\u5e2e\u6211\u67e5\u8be2\u7279\u5b9a\u5217\u8f66(train_id \u4e3a 'train_789')\u4e0a\u7684\u6240\u6709\u8f66\u8f86\u4fe1\u606f\uff0c\u5e76\u5173\u8054\u5230\u8be5\u5217\u8f66\u6240\u5728\u7684\u8def\u7ebf\u4fe1\u606f\uff1f"}, {"role": "assistant", "content": "SMEMBERS train:train_789:cars\nHGETALL car: for each car_id in result\nHGETALL train:train_789\nSMEMBERS schedule:sched_1122:bookings\nHGETALL booking: for each booking_id in result\nHGETALL route: for route_id associated with schedule"}, {"role": "user", "content": "\u80fd\u5426\u5c06\u67e5\u8be2\u7ed3\u679c\u9650\u5236\u5728\u8f66\u8f86\u7c7b\u578b\u4e3a\u2018Passenger\u2019\u7684\u8f66\u8f86\u4e0a\uff1f"}, {"role": "assistant", "content": "SMEMBERS train:train_789:cars\nHGETALL car: for each car_id in result where car_type='Passenger'\nHGETALL train:train_789\nSMEMBERS schedule:sched_1122:bookings\nHGETALL booking: for each booking_id in result\nHGETALL route: for route_id associated with schedule"}, {"role": "user", "content": "\u80fd\u5426\u518d\u52a0\u5165\u8f66\u8f86\u7684\u5ea7\u4f4d\u5bb9\u91cf\u4fe1\u606f\uff0c\u5e76\u6309\u7167\u5bb9\u91cf\u4ece\u5927\u5230\u5c0f\u6392\u5e8f\uff1f"}, {"role": "assistant", "content": "SMEMBERS train:train_789:cars\nHGETALL car: for each car_id in result where car_type='Passenger'\nSORT car: BY capacity DESC\nHGETALL train:train_789\nSMEMBERS schedule:sched_1122:bookings\nHGETALL booking: for each booking_id in result\nHGETALL route: for route_id associated with schedule"}, {"role": "user", "content": "\u80fd\u5426\u4e5f\u628a\u8def\u7ebf\u7684\u8d77\u70b9\u7ad9\u548c\u7ec8\u70b9\u7ad9\u4fe1\u606f\u52a0\u5165\u5230\u7ed3\u679c\u4e2d\uff1f"}, {"role": "assistant", "content": "SMEMBERS train:train_789:cars\nHGETALL car: for each car_id in result where car_type='Passenger'\nSORT car: BY capacity DESC\nHGETALL train:train_789\nSMEMBERS schedule:sched_1122:bookings\nHGETALL booking: for each booking_id in result\nHGETALL route: for route_id associated with schedule\nZRANGE route::stops 0 0 for origin_station_id\nZRANGE route::stops -1 -1 for destination_station_id\nHGETALL station:\nHGETALL station:"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "List all patients who have had appointments with doctors specializing in 'Oncology', showing patient ID, patient first name, patient last name, doctor ID, doctor first name, and doctor last name."}, {"role": "assistant", "content": "SELECT\n p.patient_id,\n p.first_name AS patient_first_name,\n p.last_name AS patient_last_name,\n d.doctor_id,\n d.first_name AS doctor_first_name,\n d.last_name AS doctor_last_name\nFROM healthcare.patients AS p\nJOIN healthcare.appointments AS a\n ON p.patient_id = a.patient_id\nJOIN healthcare.doctors AS d\n ON a.doctor_id = d.doctor_id\nWHERE\n d.specialty = 'Oncology';"}, {"role": "user", "content": "From this list, only include appointments that occurred in the year 2024."}, {"role": "assistant", "content": "SELECT\n p.patient_id,\n p.first_name AS patient_first_name,\n p.last_name AS patient_last_name,\n d.doctor_id,\n d.first_name AS doctor_first_name,\n d.last_name AS doctor_last_name\nFROM healthcare.patients AS p\nJOIN healthcare.appointments AS a\n ON p.patient_id = a.patient_id\nJOIN healthcare.doctors AS d\n ON a.doctor_id = d.doctor_id\nWHERE\n d.specialty = 'Oncology' AND a.appointment_time >= '2024-01-01 00:00:00' AND a.appointment_time < '2025-01-01 00:00:00';"}, {"role": "user", "content": "Now, only show patients who have had at least 2 such appointments with Oncology doctors in 2024. Display patient ID, patient full name, and the count of these appointments."}, {"role": "assistant", "content": "SELECT\n p.patient_id,\n p.first_name,\n p.last_name,\n COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients AS p\nJOIN healthcare.appointments AS a\n ON p.patient_id = a.patient_id\nJOIN healthcare.doctors AS d\n ON a.doctor_id = d.doctor_id\nWHERE\n d.specialty = 'Oncology' AND a.appointment_time >= '2024-01-01 00:00:00' AND a.appointment_time < '2025-01-01 00:00:00'\nGROUP BY\n p.patient_id,\n p.first_name,\n p.last_name\nHAVING\n COUNT(a.appointment_id) >= 2;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the payment amount and the name of the property associated with each payment record."}, {"role": "assistant", "content": "SELECT\n p.amount,\n prop.property_name\nFROM hospitality_technology.payments AS p\nJOIN hospitality_technology.reservations AS r ON p.reservation_id = r.reservation_id -- Assuming reservations links payments and properties\nJOIN hospitality_technology.properties AS prop ON r.property_id = prop.property_id;"}, {"role": "user", "content": "Now, filter this list to only include payments with a status of 'Succeeded' and sort by payment amount in descending order."}, {"role": "assistant", "content": "SELECT\n p.amount,\n prop.property_name\nFROM hospitality_technology.payments AS p\nJOIN hospitality_technology.reservations AS r ON p.reservation_id = r.reservation_id\nJOIN hospitality_technology.properties AS prop ON r.property_id = prop.property_id\nWHERE\n p.status = 'Succeeded'\nORDER BY\n p.amount DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, 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 integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\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 )\nCREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, 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 me all service orders for spa services in the last month, including the guest name and staff who delivered the service."}, {"role": "assistant", "content": "SELECT so.order_id, g.first_name, g.last_name, s.service_name, st.first_name AS staff_first_name, st.last_name AS staff_last_name, so.order_timestamp FROM hospitality_technology.service_orders so JOIN hospitality_technology.guests g ON so.guest_id = g.guest_id JOIN hospitality_technology.services s ON so.service_id = s.service_id JOIN hospitality_technology.staff st ON so.staff_id_delivered = st.staff_id WHERE s.category = 'spa' AND so.order_timestamp >= NOW() - INTERVAL '1 month';"}, {"role": "user", "content": "Now, include only orders with a total price over $100."}, {"role": "assistant", "content": "SELECT so.order_id, g.first_name, g.last_name, s.service_name, st.first_name AS staff_first_name, st.last_name AS staff_last_name, so.order_timestamp, so.total_price FROM hospitality_technology.service_orders so JOIN hospitality_technology.guests g ON so.guest_id = g.guest_id JOIN hospitality_technology.services s ON so.service_id = s.service_id JOIN hospitality_technology.staff st ON so.staff_id_delivered = st.staff_id WHERE s.category = 'spa' AND so.order_timestamp >= NOW() - INTERVAL '1 month' AND so.total_price > 100;"}, {"role": "user", "content": "The query is missing the property name. Can you include that as well?"}, {"role": "assistant", "content": "SELECT so.order_id, g.first_name, g.last_name, p.property_name, s.service_name, st.first_name AS staff_first_name, st.last_name AS staff_last_name, so.order_timestamp, so.total_price FROM hospitality_technology.service_orders so JOIN hospitality_technology.guests g ON so.guest_id = g.guest_id JOIN hospitality_technology.services s ON so.service_id = s.service_id JOIN hospitality_technology.staff st ON so.staff_id_delivered = st.staff_id JOIN hospitality_technology.properties p ON so.property_id = p.property_id WHERE s.category = 'spa' AND so.order_timestamp >= NOW() - INTERVAL '1 month' AND so.total_price > 100;"}, {"role": "user", "content": "Actually, I need to see the reservation ID and check-in date for these orders too, and order by total price in descending order."}, {"role": "assistant", "content": "SELECT so.order_id, g.first_name, g.last_name, p.property_name, s.service_name, st.first_name AS staff_first_name, st.last_name AS staff_last_name, r.reservation_id, r.check_in_date, so.order_timestamp, so.total_price FROM hospitality_technology.service_orders so JOIN hospitality_technology.guests g ON so.guest_id = g.guest_id JOIN hospitality_technology.services s ON so.service_id = s.service_id JOIN hospitality_technology.staff st ON so.staff_id_delivered = st.staff_id JOIN hospitality_technology.properties p ON so.property_id = p.property_id JOIN hospitality_technology.reservations r ON so.reservation_id = r.reservation_id WHERE s.category = 'spa' AND so.order_timestamp >= NOW() - INTERVAL '1 month' AND so.total_price > 100 ORDER BY so.total_price DESC;"}]} {"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 social_media.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(50) NOT NULL UNIQUE, -- user's unique handle\n email character varying(128) NOT NULL UNIQUE, -- user's email address\n password_hash text NOT NULL, -- hashed password\n full_name character varying(100), -- user's full name\n profile_picture_url text, -- URL to the profile picture\n bio text, -- short user biography\n location character varying(100), -- user's location\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update\n is_verified boolean NOT NULL DEFAULT false, -- verification status\n PRIMARY KEY (user_id)\n)\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )\nCREATE TABLE social_media.conversation_participants (\n participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry\n conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)\n user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)\n joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation\n last_read_at timestamp, -- timestamp indicating up to when the user has read messages\n PRIMARY KEY (participant_id),\n CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times\n)\n", "conversations": [{"role": "user", "content": "Which users joined conversations that are NOT group chats after May 1, 2024? Return their usernames and the conversation IDs."}, {"role": "assistant", "content": "SELECT u.username, cp.conversation_id\nFROM social_media.conversation_participants cp\nJOIN social_media.users u ON cp.user_id = u.user_id\nJOIN social_media.conversations c ON cp.conversation_id = c.conversation_id\nWHERE c.is_group_chat = false AND cp.joined_at > '2024-05-01';"}, {"role": "user", "content": "Now, also include the time they joined and the full name of the user."}, {"role": "assistant", "content": "SELECT u.username, u.full_name, cp.conversation_id, cp.joined_at\nFROM social_media.conversation_participants cp\nJOIN social_media.users u ON cp.user_id = u.user_id\nJOIN social_media.conversations c ON cp.conversation_id = c.conversation_id\nWHERE c.is_group_chat = false AND cp.joined_at > '2024-05-01';"}, {"role": "user", "content": "Only show users whose email ends with '.org' and order the results by joined_at descending."}, {"role": "assistant", "content": "SELECT u.username, u.full_name, cp.conversation_id, cp.joined_at\nFROM social_media.conversation_participants cp\nJOIN social_media.users u ON cp.user_id = u.user_id\nJOIN social_media.conversations c ON cp.conversation_id = c.conversation_id\nWHERE c.is_group_chat = false AND cp.joined_at > '2024-05-01' AND u.email LIKE '%.org'\nORDER BY cp.joined_at DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "For each property, list the property name and the count of payments processed."}, {"role": "assistant", "content": "SELECT\n prop.property_name,\n COUNT(p.payment_id) AS payment_count\nFROM hospitality_technology.properties AS prop\nJOIN hospitality_technology.reservations AS r ON prop.property_id = r.property_id -- Assuming reservations links properties and payments\nJOIN hospitality_technology.payments AS p ON r.reservation_id = p.reservation_id\nGROUP BY\n prop.property_name\nORDER BY\n payment_count DESC;"}, {"role": "user", "content": "Filter the list to only include properties that have processed more than 20 payments."}, {"role": "assistant", "content": "SELECT\n prop.property_name,\n COUNT(p.payment_id) AS payment_count\nFROM hospitality_technology.properties AS prop\nJOIN hospitality_technology.reservations AS r ON prop.property_id = r.property_id\nJOIN hospitality_technology.payments AS p ON r.reservation_id = p.reservation_id\nGROUP BY\n prop.property_name\nHAVING\n COUNT(p.payment_id) > 20\nORDER BY\n payment_count DESC;"}, {"role": "user", "content": "Actually, instead of the count, show the average payment amount for these properties, still limited to properties with more than 20 payments."}, {"role": "assistant", "content": "SELECT\n prop.property_name,\n AVG(p.amount) AS average_payment_amount\nFROM hospitality_technology.properties AS prop\nJOIN hospitality_technology.reservations AS r ON prop.property_id = r.property_id\nJOIN hospitality_technology.payments AS p ON r.reservation_id = p.reservation_id\nGROUP BY\n prop.property_name\nHAVING\n COUNT(p.payment_id) > 20\nORDER BY\n average_payment_amount DESC;"}]} {"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.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": "For each overall rating level (1-5), count how many reviews received that rating."}, {"role": "assistant", "content": "SELECT rating_overall, COUNT(*) FROM reviews GROUP BY rating_overall ORDER BY rating_overall;"}, {"role": "user", "content": "Only show ratings with more than 100 reviews and sort by the count descending."}, {"role": "assistant", "content": "SELECT rating_overall, COUNT(*) FROM reviews GROUP BY rating_overall HAVING COUNT(*) > 100 ORDER BY COUNT(*) DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Show me the number of primary insurance policies per insurance provider, including the provider name and the count."}, {"role": "assistant", "content": "SELECT ip.insurance_provider, COUNT(*) AS primary_policy_count\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = TRUE\nGROUP BY ip.insurance_provider;"}, {"role": "user", "content": "Can you also show the breakdown by plan type within each insurance provider?"}, {"role": "assistant", "content": "SELECT ip.insurance_provider, ip.plan_type, COUNT(*) AS primary_policy_count\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = TRUE\nGROUP BY ip.insurance_provider, ip.plan_type;"}, {"role": "user", "content": "Actually, only include insurance providers where the total number of primary policies is greater than 5."}, {"role": "assistant", "content": "SELECT provider_stats.insurance_provider, ip.plan_type, COUNT(*) AS primary_policy_count\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nJOIN (\n SELECT ip2.insurance_provider\n FROM healthcare.patient_insurance pi2\n JOIN healthcare.insurance_plans ip2 ON pi2.plan_id = ip2.plan_id\n WHERE pi2.is_primary = TRUE\n GROUP BY ip2.insurance_provider\n HAVING COUNT(*) > 5\n) AS provider_stats ON ip.insurance_provider = provider_stats.insurance_provider\nWHERE pi.is_primary = TRUE\nGROUP BY provider_stats.insurance_provider, ip.plan_type;"}, {"role": "user", "content": "Instead, only include primary policies that have not expired yet (expiration_date IS NULL or expiration_date > CURRENT_DATE)."}, {"role": "assistant", "content": "SELECT provider_stats.insurance_provider, ip.plan_type, COUNT(*) AS primary_policy_count\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nJOIN (\n SELECT ip2.insurance_provider\n FROM healthcare.patient_insurance pi2\n JOIN healthcare.insurance_plans ip2 ON pi2.plan_id = ip2.plan_id\n WHERE pi2.is_primary = TRUE AND (pi2.expiration_date IS NULL OR pi2.expiration_date > CURRENT_DATE)\n GROUP BY ip2.insurance_provider\n HAVING COUNT(*) > 5\n) AS provider_stats ON ip.insurance_provider = provider_stats.insurance_provider\nWHERE pi.is_primary = TRUE AND (pi.expiration_date IS NULL OR pi.expiration_date > CURRENT_DATE)\nGROUP BY provider_stats.insurance_provider, ip.plan_type;"}]} {"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 the total number of time entries for each case."}, {"role": "assistant", "content": "SELECT case_id, COUNT(*) AS entry_count\nFROM legal_services.time_entries\nGROUP BY case_id;"}, {"role": "user", "content": "Only include cases where the total is greater than 10."}, {"role": "assistant", "content": "SELECT case_id, COUNT(*) AS entry_count\nFROM legal_services.time_entries\nGROUP BY case_id\nHAVING COUNT(*) > 10;"}]} {"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 )\n", "conversations": [{"role": "user", "content": "Show me the first and last names of citizens along with their dates of birth and contact emails for all citizens who registered after January 1, 2023."}, {"role": "assistant", "content": "SELECT first_name, last_name, date_of_birth, contact_email FROM government_services.citizens WHERE registration_date > '2023-01-01';"}, {"role": "user", "content": "Only include citizens whose accounts are verified."}, {"role": "assistant", "content": "SELECT first_name, last_name, date_of_birth, contact_email FROM government_services.citizens WHERE registration_date > '2023-01-01' AND is_verified = true;"}]} {"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. 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 train_station_management.platforms ( platform_id text, station_id text, platform_number text, track_number text, status text, length_meters numeric, accessible boolean )\n", "conversations": [{"role": "user", "content": "What is the maintenance schedule for platform 3 at station DEF for the next month?"}, {"role": "assistant", "content": "I'm sorry, but I don't have access to the maintenance schedule for platforms. The data I have only includes static information about platform details such as ID, station, number, track, status, length, and accessibility. For maintenance schedules, you may need to consult the station management or relevant department."}]} {"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 transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.drivers ( driver_id text PRIMARY KEY, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text PRIMARY KEY, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes int, type text )\nCREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text )\nCREATE TABLE transportation.locations ( location_id text PRIMARY KEY, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\nCREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id text PRIMARY KEY, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading int, location_id text )\nCREATE TABLE transportation.bookings ( booking_id text PRIMARY KEY, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )\n", "conversations": [{"role": "user", "content": "Retrieve the vehicle_id, make, model, and the next_service_due_date for each vehicle based on the most recent maintenance log."}, {"role": "assistant", "content": "SELECT DISTINCT ON (ml.vehicle_id) v.vehicle_id, v.make, v.model, ml.next_service_due_date FROM transportation.maintenance_logs ml JOIN transportation.vehicles v ON v.vehicle_id = ml.vehicle_id ORDER BY ml.vehicle_id, ml.service_date DESC;"}, {"role": "user", "content": "Now, only include vehicles with status 'Active' and whose next_service_due_date is within the next 30 days, ordering by next_service_due_date ascending."}, {"role": "assistant", "content": "SELECT v.vehicle_id, v.make, v.model, ml.next_service_due_date FROM transportation.vehicles v JOIN (SELECT DISTINCT ON (vehicle_id) vehicle_id, next_service_due_date FROM transportation.maintenance_logs ORDER BY vehicle_id, service_date DESC) ml ON v.vehicle_id = ml.vehicle_id WHERE v.status = 'Active' AND ml.next_service_due_date BETWEEN current_date AND current_date + INTERVAL '30 days' ORDER BY ml.next_service_due_date ASC;"}]} {"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 (\n staff_id character varying(64) NOT NULL, -- unique identifier for the staff member\n property_id character varying(64) NOT NULL, -- FK to properties table (primary property)\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge\n work_email character varying(255) UNIQUE, -- staff member's work email\n work_phone character varying(30),\n hire_date date NOT NULL,\n termination_date date, -- date employment ended (if applicable)\n is_active boolean NOT NULL DEFAULT true, -- currently employed flag\n access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin)\n manager_id character varying(64), -- FK to staff table (self-referencing for supervisor)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (staff_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "List all staff who report directly to a manager with access_level 5. Include staff full name, position, and the name of their manager."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name AS staff_first_name, s.last_name AS staff_last_name, s.position, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.staff m ON s.manager_id = m.staff_id\nWHERE m.access_level = 5;"}, {"role": "user", "content": "Show only those staff who were hired after 2023-01-01."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name AS staff_first_name, s.last_name AS staff_last_name, s.position, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.staff m ON s.manager_id = m.staff_id\nWHERE m.access_level = 5 AND s.hire_date > '2023-01-01';"}, {"role": "user", "content": "Also add their work_email in the results, and sort by staff last_name alphabetically."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name AS staff_first_name, s.last_name AS staff_last_name, s.position, s.work_email, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.staff m ON s.manager_id = m.staff_id\nWHERE m.access_level = 5 AND s.hire_date > '2023-01-01'\nORDER BY s.last_name ASC;"}]} {"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.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)\n", "conversations": [{"role": "user", "content": "List all appointments that were marked as 'No-show'. Show appointment ID, patient ID, and appointment time."}, {"role": "assistant", "content": "SELECT appointment_id, patient_id, appointment_time FROM healthcare.appointments WHERE status = 'No-show';"}]} {"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 trading_platform.trades ( trade_id character varying(64) NOT NULL, order_id character varying(64) NOT NULL, buyer_id character varying(64) NOT NULL, seller_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, traded_at timestamp NOT NULL, PRIMARY KEY (trade_id) )\n", "conversations": [{"role": "user", "content": "Calculate the total quantity traded for each day in the dataset."}, {"role": "assistant", "content": "SELECT DATE_TRUNC('day', traded_at) AS trade_day, SUM(quantity) AS total_daily_quantity FROM trading_platform.trades GROUP BY DATE_TRUNC('day', traded_at) ORDER BY trade_day;"}, {"role": "user", "content": "Could you also include the total trade value (quantity * price) for each day in that report?"}, {"role": "assistant", "content": "SELECT DATE_TRUNC('day', traded_at) AS trade_day, SUM(quantity) AS total_daily_quantity, SUM(quantity * price) AS total_daily_value FROM trading_platform.trades GROUP BY DATE_TRUNC('day', traded_at) ORDER BY trade_day;"}, {"role": "user", "content": "Now, for each day, show how the total quantity compares to the overall average daily quantity across all days in the dataset."}, {"role": "assistant", "content": "WITH DailySummary AS (SELECT DATE_TRUNC('day', traded_at) AS trade_day, SUM(quantity) AS total_daily_quantity FROM trading_platform.trades GROUP BY DATE_TRUNC('day', traded_at)) SELECT trade_day, total_daily_quantity, total_daily_quantity - AVG(total_daily_quantity) OVER () AS quantity_difference_from_average FROM DailySummary ORDER BY trade_day;"}, {"role": "user", "content": "Finally, only show the days where the total quantity was higher than the overall average daily quantity."}, {"role": "assistant", "content": "WITH DailySummary AS (SELECT DATE_TRUNC('day', traded_at) AS trade_day, SUM(quantity) AS total_daily_quantity FROM trading_platform.trades GROUP BY DATE_TRUNC('day', traded_at)) SELECT trade_day, total_daily_quantity FROM DailySummary WHERE total_daily_quantity > (SELECT AVG(total_daily_quantity) FROM DailySummary) ORDER BY trade_day;"}]} {"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 web3.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )\n", "conversations": [{"role": "user", "content": "Can you show me all wallet address pairs that are owned by the same user but have different private keys, along with their wallet_ids and user_id?"}, {"role": "assistant", "content": "SELECT w1.user_id, w1.wallet_id AS wallet_id_1, w1.address AS address_1, w1.private_key AS private_key_1, w2.wallet_id AS wallet_id_2, w2.address AS address_2, w2.private_key AS private_key_2\nFROM web3.wallets w1\nJOIN web3.wallets w2 ON w1.user_id = w2.user_id AND w1.wallet_id < w2.wallet_id\nWHERE w1.private_key <> w2.private_key;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.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 (\n review_id character varying(64) NOT NULL, -- unique identifier for the review\n property_id character varying(64) NOT NULL, -- FK to properties table\n reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good)\n guest_id character varying(64) NOT NULL, -- FK to guests table\n rating_overall integer, -- overall score (e.g., 1-5 or 1-10)\n rating_cleanliness integer,\n rating_service integer,\n rating_location integer,\n rating_value integer,\n comment text, -- guest's written feedback\n review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com\n review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted\n is_public boolean DEFAULT true, -- whether the review is publicly visible\n staff_response text, -- official response from the property\n response_staff_id character varying(64), -- FK to staff (who responded)\n response_date timestamp with time zone, -- when the response was posted\n PRIMARY KEY (review_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "List all service orders, including the service name and quantity, along with the full name of the staff member who placed the order."}, {"role": "assistant", "content": "SELECT so.order_id, s.service_name, so.quantity, st.first_name, st.last_name FROM hospitality_technology.service_orders AS so JOIN hospitality_technology.services AS s ON so.service_id = s.service_id JOIN hospitality_technology.staff AS st ON so.staff_id_ordered = st.staff_id;"}, {"role": "user", "content": "Filter this list to only include orders placed by staff members with position 'Concierge'."}, {"role": "assistant", "content": "SELECT so.order_id, s.service_name, so.quantity, st.first_name, st.last_name FROM hospitality_technology.service_orders AS so JOIN hospitality_technology.services AS s ON so.service_id = s.service_id JOIN hospitality_technology.staff AS st ON so.staff_id_ordered = st.staff_id WHERE st.position = 'Concierge';"}]} {"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 text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\n", "conversations": [{"role": "user", "content": "Find law firms that share the same managing partner. Show the names of both firms and the managing_partner_id."}, {"role": "assistant", "content": "SELECT a.firm_name AS firm1, b.firm_name AS firm2, a.managing_partner_id\nFROM legal_services.law_firms a\nJOIN legal_services.law_firms b\n ON a.managing_partner_id = b.managing_partner_id\n AND a.firm_id < b.firm_id;"}, {"role": "user", "content": "Exclude any pairs where the managing_partner_id is null."}, {"role": "assistant", "content": "SELECT a.firm_name AS firm1, b.firm_name AS firm2, a.managing_partner_id\nFROM legal_services.law_firms a\nJOIN legal_services.law_firms b\n ON a.managing_partner_id = b.managing_partner_id\n AND a.firm_id < b.firm_id\nWHERE a.managing_partner_id IS NOT NULL;"}, {"role": "user", "content": "Also, sort the results by managing_partner_id and then by the first firm's name."}, {"role": "assistant", "content": "SELECT a.firm_name AS firm1, b.firm_name AS firm2, a.managing_partner_id\nFROM legal_services.law_firms a\nJOIN legal_services.law_firms b\n ON a.managing_partner_id = b.managing_partner_id\n AND a.firm_id < b.firm_id\nWHERE a.managing_partner_id IS NOT NULL\nORDER BY a.managing_partner_id, a.firm_name;"}]} {"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.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )\n", "conversations": [{"role": "user", "content": "I need a list showing each patient along with their current primary insurance policy number and their immediately previous primary policy number."}, {"role": "assistant", "content": "SELECT ci.patient_id,\n ci.policy_number AS current_policy,\n pi.policy_number AS previous_policy\nFROM healthcare.patient_insurance ci\nLEFT JOIN healthcare.patient_insurance pi\n ON ci.patient_id = pi.patient_id\n AND pi.is_primary = TRUE\n AND pi.effective_date < ci.effective_date\nWHERE ci.is_primary = TRUE\n AND (ci.expiration_date IS NULL OR ci.expiration_date > CURRENT_DATE)\n AND pi.effective_date = (\n SELECT MAX(pii.effective_date)\n FROM healthcare.patient_insurance pii\n WHERE pii.patient_id = ci.patient_id\n AND pii.is_primary = TRUE\n AND pii.effective_date < ci.effective_date\n );"}, {"role": "user", "content": "Actually, I only want to include previous policies that have an expiration_date set."}, {"role": "assistant", "content": "SELECT ci.patient_id,\n ci.policy_number AS current_policy,\n pi.policy_number AS previous_policy\nFROM healthcare.patient_insurance ci\nLEFT JOIN healthcare.patient_insurance pi\n ON ci.patient_id = pi.patient_id\n AND pi.is_primary = TRUE\n AND pi.expiration_date IS NOT NULL\n AND pi.effective_date = (\n SELECT MAX(pii.effective_date)\n FROM healthcare.patient_insurance pii\n WHERE pii.patient_id = ci.patient_id\n AND pii.is_primary = TRUE\n AND pii.expiration_date IS NOT NULL\n AND pii.effective_date < ci.effective_date\n )\nWHERE ci.is_primary = TRUE\n AND (ci.expiration_date IS NULL OR ci.expiration_date > CURRENT_DATE);"}]} {"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 social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_read_at timestamp, PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Get the total number of participants per conversation along with the number of participants who have private profiles."}, {"role": "assistant", "content": "SELECT cp.conversation_id, COUNT(cp.user_id) AS total_participants, SUM(CASE WHEN us.private_profile THEN 1 ELSE 0 END) AS private_profile_count FROM social_media.conversation_participants cp LEFT JOIN social_media.user_settings us ON cp.user_id = us.user_id GROUP BY cp.conversation_id;"}, {"role": "user", "content": "Exclude conversations with fewer than 3 private profile participants."}, {"role": "assistant", "content": "SELECT cp.conversation_id, COUNT(cp.user_id) AS total_participants, SUM(CASE WHEN us.private_profile THEN 1 ELSE 0 END) AS private_profile_count FROM social_media.conversation_participants cp LEFT JOIN social_media.user_settings us ON cp.user_id = us.user_id GROUP BY cp.conversation_id HAVING SUM(CASE WHEN us.private_profile THEN 1 ELSE 0 END) >= 3;"}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "How many agencies exist at each jurisdiction level?"}, {"role": "assistant", "content": "SELECT jurisdiction_level, COUNT(*) AS agency_count\nFROM government_services.agencies\nGROUP BY jurisdiction_level;"}, {"role": "user", "content": "Now exclude jurisdiction levels that have fewer than 5 agencies."}, {"role": "assistant", "content": "SELECT jurisdiction_level, COUNT(*) AS agency_count\nFROM government_services.agencies\nGROUP BY jurisdiction_level\nHAVING COUNT(*) >= 5;"}, {"role": "user", "content": "Also, show me the average establishment year for those jurisdiction levels."}, {"role": "assistant", "content": "SELECT jurisdiction_level,\n COUNT(*) AS agency_count,\n AVG(EXTRACT(YEAR FROM established_date)) AS avg_established_year\nFROM government_services.agencies\nGROUP BY jurisdiction_level\nHAVING COUNT(*) >= 5;"}, {"role": "user", "content": "Sort the results by agency_count descending and limit to 3."}, {"role": "assistant", "content": "SELECT jurisdiction_level,\n COUNT(*) AS agency_count,\n AVG(EXTRACT(YEAR FROM established_date)) AS avg_established_year\nFROM government_services.agencies\nGROUP BY jurisdiction_level\nHAVING COUNT(*) >= 5\nORDER BY agency_count DESC\nLIMIT 3;"}]} {"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) )\nCREATE TABLE gaming_technology.games ( game_id uuid PRIMARY KEY, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text )\nCREATE TABLE gaming_technology.developers ( developer_id.uuid, name.text, country.text, founded_year.integer, website.text, created_at.timestamptz )\nCREATE TABLE gaming_technology.servers ( server_id uuid PRIMARY KEY, game_id uuid, server_name text, region text, ip_address text, port int, current_players int, max_players int, status text, last_heartbeat timestamptz )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid PRIMARY KEY, player_id uuid, achievement_id uuid, unlocked_at timestamptz )\n", "conversations": [{"role": "user", "content": "Show me all servers, the title of the game they host, and the name of the game's developer."}, {"role": "assistant", "content": "SELECT s.server_name, g.title AS game_title, d.name AS developer_name FROM gaming_technology.servers s JOIN gaming_technology.games g ON s.game_id = g.game_id JOIN gaming_technology.developers d ON g.developer_id = d.developer_id;"}, {"role": "user", "content": "Now filter this list to only include servers that are currently 'online'."}, {"role": "assistant", "content": "SELECT s.server_name, g.title AS game_title, d.name AS developer_name FROM gaming_technology.servers s JOIN gaming_technology.games g ON s.game_id = g.game_id JOIN gaming_technology.developers d ON g.developer_id = d.developer_id WHERE s.status = 'online';"}]} {"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, 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.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.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.text, 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.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": "Retrieve the service name and the count of applications currently in 'Under Review' status for each service."}, {"role": "assistant", "content": "SELECT s.service_name, COUNT(a.application_id) AS under_review_count\nFROM government_services.services s\nLEFT JOIN government_services.applications a ON s.service_id = a.service_id AND a.status = 'Under Review'\nGROUP BY s.service_name;"}]} {"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 web3.contracts ( contract_id.text, address.text, abi.text, bytecode.text, deployer_address.text, deployed_at.timestamp, network_id.text, status.text )\nCREATE TABLE web3.events ( event_id.text, contract_id.text, event_name.text, data.text, emitted_at.timestamp, transaction_id.text, log_index.integer )\nCREATE TABLE web3.token_transfers ( transfer_id.text, token_id.text, from_address.text, to_address.text, value.numeric, transaction_id.text, log_index.integer )\nCREATE TABLE web3.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp )\nCREATE TABLE web3.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Find the usernames of users who have deployed contracts and list the address of the contract they deployed."}, {"role": "assistant", "content": "SELECT T1.username, T3.address FROM web3.users AS T1 JOIN web3.wallets AS T2 ON T1.user_id = T2.user_id JOIN web3.contracts AS T3 ON T2.address = T3.deployer_address;"}]} {"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.servers ( server_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, server_name character varying(150), region character varying(50) NOT NULL, ip_address character varying(45), port integer, current_players integer NOT NULL DEFAULT 0, max_players integer NOT NULL, status character varying(30) NOT NULL DEFAULT 'offline', last_heartbeat timestamp with time zone, PRIMARY KEY (server_id) )\n", "conversations": [{"role": "user", "content": "Find pairs of servers in the same region where one server's last heartbeat was recorded within the last hour, and the other server's last heartbeat was recorded between 1 and 2 hours ago. Show the server names, regions, and last heartbeat timestamps for both servers in each pair."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.region, s1.last_heartbeat AS server1_heartbeat, s2.last_heartbeat AS server2_heartbeat FROM gaming_technology.servers AS s1 JOIN gaming_technology.servers AS s2 ON s1.region = s2.region AND s1.server_id != s2.server_id WHERE s1.last_heartbeat IS NOT NULL AND s2.last_heartbeat IS NOT NULL AND s1.last_heartbeat > NOW() - INTERVAL '1 hour' AND s2.last_heartbeat <= NOW() - INTERVAL '1 hour' AND s2.last_heartbeat > NOW() - INTERVAL '2 hours';"}, {"role": "user", "content": "Only include pairs where both servers are currently online."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.region, s1.last_heartbeat AS server1_heartbeat, s2.last_heartbeat AS server2_heartbeat FROM gaming_technology.servers AS s1 JOIN gaming_technology.servers AS s2 ON s1.region = s2.region AND s1.server_id != s2.server_id WHERE s1.last_heartbeat IS NOT NULL AND s2.last_heartbeat IS NOT NULL AND s1.last_heartbeat > NOW() - INTERVAL '1 hour' AND s2.last_heartbeat <= NOW() - INTERVAL '1 hour' AND s2.last_heartbeat > NOW() - INTERVAL '2 hours' AND s1.status = 'online' AND s2.status = 'online';"}, {"role": "user", "content": "Could you also filter the list to only show pairs from regions starting with 'us-'?"}, {"role": "assistant", "content": "SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.region, s1.last_heartbeat AS server1_heartbeat, s2.last_heartbeat AS server2_heartbeat FROM gaming_technology.servers AS s1 JOIN gaming_technology.servers AS s2 ON s1.region = s2.region AND s1.server_id != s2.server_id WHERE s1.last_heartbeat IS NOT NULL AND s2.last_heartbeat IS NOT NULL AND s1.last_heartbeat > NOW() - INTERVAL '1 hour' AND s2.last_heartbeat <= NOW() - INTERVAL '1 hour' AND s2.last_heartbeat > NOW() - INTERVAL '2 hours' AND s1.status = 'online' AND s2.status = 'online' AND s1.region LIKE 'us-%';"}, {"role": "user", "content": "Order the results by the region ascending, then by the earlier heartbeat timestamp ascending."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.region, s1.last_heartbeat AS server1_heartbeat, s2.last_heartbeat AS server2_heartbeat FROM gaming_technology.servers AS s1 JOIN gaming_technology.servers AS s2 ON s1.region = s2.region AND s1.server_id != s2.server_id WHERE s1.last_heartbeat IS NOT NULL AND s2.last_heartbeat IS NOT NULL AND s1.last_heartbeat > NOW() - INTERVAL '1 hour' AND s2.last_heartbeat <= NOW() - INTERVAL '1 hour' AND s2.last_heartbeat > NOW() - INTERVAL '2 hours' AND s1.status = 'online' AND s2.status = 'online' AND s1.region LIKE 'us-%' ORDER BY s1.region ASC, s2.last_heartbeat ASC;"}]} {"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.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, 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 integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\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, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, 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 me the count of rooms by status."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS room_count\nFROM hospitality_technology.rooms\nGROUP BY status;"}, {"role": "user", "content": "Actually, I need that breakdown by property as well."}, {"role": "assistant", "content": "SELECT property_id,\n status,\n COUNT(*) AS room_count\nFROM hospitality_technology.rooms\nGROUP BY property_id, status\nORDER BY property_id, status;"}]} {"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 erc1155_approval_for_all (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction\n transaction_index integer NOT NULL, -- Index of the transaction within the block\n transaction_hash varchar(66) NOT NULL, -- Transaction hash\n log_index integer NOT NULL, -- Log index\n contract_address varchar(42) NOT NULL -- Event contract address\n)\nCREATE TABLE erc20_balances ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk varchar )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata (\n object_id varchar NOT NULL, -- object id of the coin metadata object\n coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN\n status varchar NOT NULL, -- coin status, eg. exists, deleted\n decimals bigint NOT NULL, -- decimals of the coin\n description varchar NOT NULL, -- description of the coin\n icon_url varchar NOT NULL, -- icon url of the coin\n symbol varchar NOT NULL, -- symbol of the coin\n name varchar NOT NULL -- name of the coin\n)\nCREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )\nCREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )\nCREATE TABLE token_balances (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar NOT NULL, -- Token tick\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply decimal(38,0) NOT NULL, -- Max supply\n amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE mud_holesky_redstone ( address text, table_id text, key_bytes text, key0 text, key1 text, static_data text, encoded_lengths text, dynamic_data text, is_deleted boolean, block_number bigint, log_index bigint )\nCREATE TABLE token_balances_bitcoin (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply varchar NOT NULL, -- Max supply: Set max supply of the inscription\n amount varchar NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE token_balances_avalanche (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar(20) NOT NULL, -- Ticker: Identifier of the inscription\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription\n amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )\n", "conversations": [{"role": "user", "content": "Which ERC1155 NFT contracts have received approval-for-all events, and for each contract, how many total approval events were recorded?"}, {"role": "assistant", "content": "SELECT contract_address, COUNT(*) AS approval_count FROM erc1155_approval_for_all GROUP BY contract_address;"}, {"role": "user", "content": "Can you also show how many unique wallet addresses currently hold NFTs from each of these contracts?"}, {"role": "assistant", "content": "SELECT ea.contract_address, COUNT(*) AS approval_count, COUNT(DISTINCT nh.wallet_address) AS holder_count FROM erc1155_approval_for_all ea LEFT JOIN nft_holders nh ON ea.contract_address = nh.contract_address GROUP BY ea.contract_address;"}, {"role": "user", "content": "Only include contracts where the holder count is greater than 10, sorted by approval_count descending."}, {"role": "assistant", "content": "SELECT ea.contract_address, COUNT(*) AS approval_count, COUNT(DISTINCT nh.wallet_address) AS holder_count FROM erc1155_approval_for_all ea LEFT JOIN nft_holders nh ON ea.contract_address = nh.contract_address GROUP BY ea.contract_address HAVING COUNT(DISTINCT nh.wallet_address) > 10 ORDER BY approval_count DESC;"}, {"role": "user", "content": "Add a limit to return only the top 10 contracts."}, {"role": "assistant", "content": "SELECT ea.contract_address, COUNT(*) AS approval_count, COUNT(DISTINCT nh.wallet_address) AS holder_count FROM erc1155_approval_for_all ea LEFT JOIN nft_holders nh ON ea.contract_address = nh.contract_address GROUP BY ea.contract_address HAVING COUNT(DISTINCT nh.wallet_address) > 10 ORDER BY approval_count DESC LIMIT 10;"}]} {"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 character varying(64) NOT NULL, national_id_number character varying(128) NOT NULL UNIQUE, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(20), primary_address text NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), registration_date timestamp NOT NULL, is_verified boolean DEFAULT false, PRIMARY KEY (citizen_id) )\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.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_id) )\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.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 ( 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": "List the names of active services offered by agencies with at least one accessible service location in the state of 'New York'. Show the service name, category, agency name, and the location name."}, {"role": "assistant", "content": "SELECT T1.service_name, T1.category, T2.agency_name, T3.location_name FROM government_services.services AS T1 JOIN government_services.agencies AS T2 ON T1.agency_id = T2.agency_id JOIN government_services.service_locations AS T3 ON T2.agency_id = T3.agency_id WHERE T1.is_active IS TRUE AND T3.is_accessible IS TRUE AND T3.state = 'New York';"}]} {"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 PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\n", "conversations": [{"role": "user", "content": "List all service orders with quantity greater than 3, showing the order ID, total price, and the staff member who placed the order."}, {"role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered\nFROM hospitality_technology.service_orders\nWHERE quantity > 3;"}, {"role": "user", "content": "Please add the delivery timestamp, and only show orders that were actually delivered (delivery_timestamp is not null)."}, {"role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered, delivery_timestamp\nFROM hospitality_technology.service_orders\nWHERE quantity > 3\n AND delivery_timestamp IS NOT NULL;"}, {"role": "user", "content": "Now, show only those orders where the delivered staff is different from the ordered staff, and sort by delivery timestamp ascending."}, {"role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered, staff_id_delivered, delivery_timestamp\nFROM hospitality_technology.service_orders\nWHERE quantity > 3\n AND delivery_timestamp IS NOT NULL\n AND staff_id_ordered <> staff_id_delivered\nORDER BY delivery_timestamp ASC;"}]} {"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 web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "For each user, what is the average time difference in days between their wallet creations? Return user_id and avg_diff_days."}, {"role": "assistant", "content": "WITH diffs AS (\n SELECT\n user_id,\n EXTRACT(EPOCH FROM (created_at - LAG(created_at) OVER (PARTITION BY user_id ORDER BY created_at))) / 86400 AS diff_days\n FROM web3.wallets\n)\nSELECT\n user_id,\n AVG(diff_days) AS avg_diff_days\nFROM diffs\nWHERE diff_days IS NOT NULL\nGROUP BY user_id;"}, {"role": "user", "content": "Actually, only include users who have created more than 2 wallets."}, {"role": "assistant", "content": "WITH diffs AS (\n SELECT\n user_id,\n EXTRACT(EPOCH FROM (created_at - LAG(created_at) OVER (PARTITION BY user_id ORDER BY created_at))) / 86400 AS diff_days\n FROM web3.wallets\n)\nSELECT\n user_id,\n AVG(diff_days) AS avg_diff_days\nFROM diffs\nWHERE diff_days IS NOT NULL\nGROUP BY user_id\nHAVING COUNT(diff_days) > 1;"}]} {"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.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\n", "conversations": [{"role": "user", "content": "Show me all servers in the same region that have different statuses. I want to see the server names, regions, and their statuses for each pair."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1, s2.server_name AS server2, s1.region, s1.status AS status1, s2.status AS status2\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\n AND s1.server_id <> s2.server_id\n AND s1.status <> s2.status;"}, {"role": "user", "content": "Please also include the current_players of both servers in the result."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1, s2.server_name AS server2, s1.region, s1.status AS status1, s2.status AS status2, s1.current_players AS server1_current_players, s2.current_players AS server2_current_players\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\n AND s1.server_id <> s2.server_id\n AND s1.status <> s2.status;"}]} {"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 transportation.vehicles ( vehicle_id.text, license_plate.text, vin.text, make.text, model.text, year.integer, type.text, capacity.integer, fuel_type.text, status.text, depot_id.text, acquisition_date.date )\nCREATE TABLE transportation.trips ( trip_id.text, route_id.text, vehicle_id.text, driver_id.text, scheduled_departure.timestamp, actual_departure.timestamp, scheduled_arrival.timestamp, actual_arrival.timestamp, origin_location_id.text, destination_location_id.text, status.text, passenger_count.integer, cargo_manifest_id.text )\nCREATE TABLE transportation.locations ( location_id.text, name.text, type.text, address_line1.text, city.text, state_province.text, postal_code.text, country.text, latitude.numeric, longitude.numeric, timezone.text )\nCREATE TABLE transportation.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Calculate the total fuel quantity and total cost consumed for each trip where passenger_count > 50. List trip_id, total_quantity, and total_cost."}, {"role": "assistant", "content": "SELECT f.trip_id,\n SUM(f.quantity) AS total_quantity,\n SUM(f.total_cost) AS total_cost\nFROM transportation.fuel_logs f\nJOIN transportation.trips t\n ON f.trip_id = t.trip_id\nWHERE t.passenger_count > 50\nGROUP BY f.trip_id;"}, {"role": "user", "content": "Also include the vehicle make and model for each trip, and order by total_cost descending."}, {"role": "assistant", "content": "SELECT f.trip_id,\n SUM(f.quantity) AS total_quantity,\n SUM(f.total_cost) AS total_cost,\n v.make,\n v.model\nFROM transportation.fuel_logs f\nJOIN transportation.trips t\n ON f.trip_id = t.trip_id\nJOIN transportation.vehicles v\n ON t.vehicle_id = v.vehicle_id\nWHERE t.passenger_count > 50\nGROUP BY f.trip_id, v.make, v.model\nORDER BY total_cost DESC;"}]} {"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.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\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)\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)\n", "conversations": [{"role": "user", "content": "Find all invoices with status 'Paid' where the total amount is between 2000 and 5000. Show invoice number, total amount, issue date, and due date. Sort the results by issue date descending."}, {"role": "assistant", "content": "SELECT invoice_number, total_amount, issue_date, due_date FROM legal_services.invoices WHERE status = 'Paid' AND total_amount BETWEEN 2000 AND 5000 ORDER BY issue_date DESC;"}]} {"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 token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc1155_approval_for_all (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction\n transaction_index integer NOT NULL, -- Index of the transaction within the block\n transaction_hash varchar(66) NOT NULL, -- Transaction hash\n log_index integer NOT NULL, -- Log index\n contract_address varchar(42) NOT NULL -- Event contract address\n)\nCREATE TABLE erc20_balances_historical (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract\n amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height\n pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))\n)\nCREATE TABLE nft_holders ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk varchar )\nCREATE TABLE sui_coins ( object_id varchar, status varchar, coin_type varchar, balance varchar, owner varchar )\nCREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_balances (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar NOT NULL, -- Token tick\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply decimal(38,0) NOT NULL, -- Max supply\n amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_info_avalanche (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar(20) NOT NULL, -- Ticker: Identifier of the inscription\n max_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription\n lim decimal(38,0) NOT NULL, -- Mint limit: limit per inscription\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL, -- Address originating the inscription (matches from_address in transactions table)\n minted decimal(38,0) NOT NULL, -- Sum of minted amount\n holders decimal(38,0) NOT NULL, -- Count of holders\n txs decimal(38,0) NOT NULL, -- Count of transactions\n updated_timestamp timestamp(3) NOT NULL, -- Timestamp of update\n completed_timestamp timestamp(3) NOT NULL, -- Timestamp of minted completed\n id varchar(255) NOT NULL -- id fields for the functionType in contract asc20\n)\n", "conversations": [{"role": "user", "content": "Show me the total balance and number of distinct holders for each Avalanche token, including its tick and creator address."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, SUM(tb.amount) AS total_balance, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nGROUP BY ti.tick, ti.creator;"}, {"role": "user", "content": "I also want to see the max_supply for each token in the result."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, ti.max_supply, SUM(tb.amount) AS total_balance, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nGROUP BY ti.tick, ti.creator, ti.max_supply;"}, {"role": "user", "content": "Only include tokens where max_supply is greater than 10000 and sort by total_balance descending."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, ti.max_supply, SUM(tb.amount) AS total_balance, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nWHERE ti.max_supply > 10000\nGROUP BY ti.tick, ti.creator, ti.max_supply\nORDER BY total_balance DESC;"}, {"role": "user", "content": "Add a column for the difference between max_supply and total_balance, call it available_supply."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, ti.max_supply, SUM(tb.amount) AS total_balance, (ti.max_supply - SUM(tb.amount)) AS available_supply, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nWHERE ti.max_supply > 10000\nGROUP BY ti.tick, ti.creator, ti.max_supply\nORDER BY total_balance DESC;"}]} {"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 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, ssn_hash character varying(128), address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state character varying(50) NOT NULL, zip_code character varying(20) NOT NULL, country character varying(50) NOT NULL DEFAULT 'USA', phone_number character varying(30), email character varying(128) UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, status character varying(20) NOT NULL DEFAULT 'Active', PRIMARY KEY (customer_id) )\n", "conversations": [{"role": "user", "content": "How many customers are there in each state?"}, {"role": "assistant", "content": "SELECT state, COUNT(*) AS customer_count\nFROM insurance.customers\nGROUP BY state;"}]} {"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 project_fundraising_record ( id character varying(32) NOT NULL, -- fundraising record id project_id character varying(32) NOT NULL, -- the invested project's id project_name character varying(128) NOT NULL, -- name of the invested project rounds_name character varying(32), -- name of the fundraising round investment_value numeric(38,14), -- amount of the fundraising in USD investment_date character varying(128), -- the date of the investment happened introduction character varying(128), -- the introduction of the invested project valuation numeric(38,14), -- the valuation of the project in USD when invested )\nCREATE TABLE token_basic_info ( coin_id text, token_name text, token_symbol text, token_address text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, highest_price_24h numeric, lowest_price_24h numeric, market_cap numeric, market_cap_rank numeric, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank numeric )\nCREATE TABLE token_dexpool_info ( pair_address text, token_name text, token_symbol text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_6h numeric, price_change_percentage_24h numeric, makers_24h numeric, volume_24h numeric, liquidity numeric, market_cap numeric, trend_rank numeric )\n \"CREATE TABLE cex_token_balance (\",\n \"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp\",\n \"chain character varying(128) NOT NULL, -- the chain that the token resides\",\n \"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX\",\n \"exchange character varying(512) NOT NULL, -- a centralized exchange name\",\n \"token_address character varying(128) NOT NULL, -- token contract address\",\n \"token_symbol character varying(512), --token symbol\",\n \"balance numeric(38,10), -- token balance\",\n \"usd_value numeric(38,14), -- value of the token held in USD\",\n \"price double precision, --price of the token in USD\",\n \",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));\"\n\n", "conversations": [{"role": "user", "content": "List projects that have raised funds and also have an associated token, showing their name, fundraising amount, and current token price."}, {"role": "assistant", "content": "SELECT T1.project_name, T1.investment_value, T2.price FROM project_fundraising_record AS T1 INNER JOIN token_basic_info AS T2 ON T1.project_name = T2.token_symbol"}, {"role": "user", "content": "Only show results for projects that raised funds in 2023, and also include the token's market cap."}, {"role": "assistant", "content": "SELECT T1.project_name, T1.investment_value, T2.price, T2.market_cap FROM project_fundraising_record AS T1 INNER JOIN token_basic_info AS T2 ON T1.project_name = T2.token_symbol WHERE T1.investment_date LIKE '%2023%'"}, {"role": "user", "content": "Order the results by investment amount descending and show the top 10."}, {"role": "assistant", "content": "SELECT T1.project_name, T1.investment_value, T2.price, T2.market_cap FROM project_fundraising_record AS T1 INNER JOIN token_basic_info AS T2 ON T1.project_name = T2.token_symbol WHERE T1.investment_date LIKE '%2023%' ORDER BY T1.investment_value DESC LIMIT 10"}, {"role": "user", "content": "Filter to only include tokens on the 'Ethereum' chain."}, {"role": "assistant", "content": "SELECT T1.project_name, T1.investment_value, T2.price, T2.market_cap FROM project_fundraising_record AS T1 INNER JOIN token_basic_info AS T2 ON T1.project_name = T2.token_symbol WHERE T1.investment_date LIKE '%2023%' AND T2.chain = 'Ethereum' ORDER BY T1.investment_value DESC LIMIT 10"}]} {"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.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)\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "Can you show me the details of all medical records for patients that had their vitals recorded with a temperature above 38 degrees Celsius, along with any medication descriptions that mention 'antipyretic'?"}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.treatment_plan, m.medication_name, m.description\nFROM healthcare.medical_records mr\nJOIN healthcare.medications m ON mr.treatment_plan ILIKE '%' || m.medication_name || '%'\nWHERE (mr.vitals->>'Temp')::numeric > 38 AND m.description ILIKE '%antipyretic%';"}, {"role": "user", "content": "Refine the query to only include records created after January 1st, 2024."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.treatment_plan, m.medication_name, m.description\nFROM healthcare.medical_records mr\nJOIN healthcare.medications m ON mr.treatment_plan ILIKE '%' || m.medication_name || '%'\nWHERE (mr.vitals->>'Temp')::numeric > 38\n AND m.description ILIKE '%antipyretic%'\n AND mr.record_date >= '2024-01-01';"}, {"role": "user", "content": "Actually, could you also include the doctor's ID who created each medical record?"}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.doctor_id, mr.record_date, mr.chief_complaint, mr.treatment_plan, m.medication_name, m.description\nFROM healthcare.medical_records mr\nJOIN healthcare.medications m ON mr.treatment_plan ILIKE '%' || m.medication_name || '%'\nWHERE (mr.vitals->>'Temp')::numeric > 38\n AND m.description ILIKE '%antipyretic%'\n AND mr.record_date >= '2024-01-01';"}]} {"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.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.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": "List the full name, specialization, and firm name for all lawyers who are not partners."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.specialization, T2.firm_name FROM lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id WHERE T1.is_partner = 0;"}, {"role": "user", "content": "Could you narrow it down to only those whose specialization is 'Criminal Defense'?"}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.specialization, T2.firm_name FROM lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id WHERE T1.is_partner = 0 AND T1.specialization = 'Criminal Defense';"}, {"role": "user", "content": "Also include their hire date and only show those hired after '2022-01-01'."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.specialization, T2.firm_name, T1.hire_date FROM lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id WHERE T1.is_partner = 0 AND T1.specialization = 'Criminal Defense' AND T1.hire_date > '2022-01-01';"}]} {"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 smart_money_profit ( address character varying(100) NOT NULL, -- the user's address rank INT, -- the rank of the address in trade performance, value 1 expresses the best address. profit numeric(38,6), -- the profit user made in a month roi numeric(38,2), -- the roi of the user in a month realized_ratio numeric(38,2), -- the percentage of the user's realized profit most_profit_token character varying(100), -- the token symbol of the user's most profitable trade last_trade_time character varying(100), -- the last trade time of the user chain character varying(100), -- the chain that the address resides PRIMARY KEY (address, chain) )\n", "conversations": [{"role": "user", "content": "How many distinct addresses achieved a realized_ratio higher than 0.9 last month?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT address) FROM smart_money_profit WHERE realized_ratio > 0.9;"}, {"role": "user", "content": "Can you also break down the count by chain?"}, {"role": "assistant", "content": "SELECT chain, COUNT(DISTINCT address) AS address_count FROM smart_money_profit WHERE realized_ratio > 0.9 GROUP BY chain;"}]} {"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.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the names of law firms founded after 2010, along with the full name of their managing partner."}, {"role": "assistant", "content": "SELECT f.firm_name, l.first_name, l.last_name FROM legal_services.law_firms AS f JOIN legal_services.lawyers AS l ON f.managing_partner_id = l.lawyer_id WHERE f.founded_date > '2010-12-31';"}]} {"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.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 ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.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 )\n", "conversations": [{"role": "user", "content": "List the full name (first and last) and specialization of all lawyers who work for law firms founded before the year 2000."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.specialization FROM lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id WHERE T2.founded_date < '2000-01-01'"}, {"role": "user", "content": "From that list, could you only show those lawyers whose specialization is 'Environmental Law'?"}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.specialization FROM lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id WHERE T2.founded_date < '2000-01-01' AND T1.specialization = 'Environmental Law'"}, {"role": "user", "content": "Also include their hire date and order the results by specialization then hire date."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.specialization, T1.hire_date FROM lawyers AS T1 JOIN law_firms AS T2 ON T1.firm_id = T2.firm_id WHERE T2.founded_date < '2000-01-01' AND T1.specialization = 'Environmental Law' ORDER BY T1.specialization, T1.hire_date"}]} {"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 social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )\nCREATE TABLE social_media.comments ( comment_id text, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id text, tag_name text, created_at timestamp )\nCREATE TABLE social_media.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)\n sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)\n notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')\n target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)\n target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created\n read_at timestamp, -- timestamp notification was marked as read\n PRIMARY KEY (notification_id)\n)\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the usernames and email addresses of users who have commented on their own posts."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, u.email\nFROM social_media.comments c\nJOIN social_media.users u ON c.user_id = u.user_id\nJOIN social_media.posts p ON c.post_id = p.post_id\nWHERE c.user_id = p.user_id;"}, {"role": "user", "content": "Please also include the total number of such comments each user made."}, {"role": "assistant", "content": "SELECT u.username, u.email, COUNT(*) AS comment_count\nFROM social_media.comments c\nJOIN social_media.users u ON c.user_id = u.user_id\nJOIN social_media.posts p ON c.post_id = p.post_id\nWHERE c.user_id = p.user_id\nGROUP BY u.username, u.email;"}]} {"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. 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 manufacturing.component_inventory (\n inventory_record_id character varying(64) NOT NULL, -- unique ID for this inventory record/batch\n component_id character varying(64) NOT NULL, -- FK to the component\n quantity integer NOT NULL, -- number of units of this component in stock for this batch\n location_warehouse character varying(100), -- warehouse identifier\n location_bin character varying(100), -- specific bin or shelf location\n received_date timestamp NOT NULL, -- when this batch was received\n expiry_date date, -- expiry date if applicable (e.g., for sealants, adhesives)\n batch_number character varying(100), -- supplier batch number\n last_updated timestamp NOT NULL, -- timestamp of the last update to this record\n PRIMARY KEY (inventory_record_id)\n)\n", "conversations": [{"role": "user", "content": "What is the purchase price of the components in a specific batch with batch_number 'BATCH123'?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide information on the purchase price of components as this data is not stored in the component_inventory table. If you have other questions or need assistance with data available in the table, such as quantity or location, I'm happy to help."}]} {"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\nNode Label ':Component'. Properties: { component_id: String (Constraint: UNIQUE), part_number: String (Constraint: UNIQUE), component_name: String, description: String, weight_kg: Float, cost_usd: Float, criticality_level: String }. Relationships: (:Component)-[:MADE_OF]->(:Material {material_id}), (:Component)-[:SUPPLIED_BY]->(:Supplier {supplier_id}). Index on component_id, part_number.\nNode Label ':Supplier'. Properties: { supplier_id: String (Constraint: UNIQUE), supplier_name: String, address: String, country: String, contact_person: String, contact_email: String, quality_rating: Float, certified_date: Date }. Index on supplier_id.\nNode Label ':Material'. Properties: { material_id: String (Constraint: UNIQUE), material_name: String, specification: String, description: String, density_kg_m3: Float, tensile_strength_mpa: Integer }. Index on material_id.\nNode Label ':AssemblyLine'. Properties: { line_id: String (Constraint: UNIQUE), line_name: String, location_building: String, location_area: String, capacity_units_per_month: Integer, status: String }. Relationship: (:AssemblyLine)-[:BUILDS_MODEL]->(:AircraftModel {model_id}). Index on line_id.\nNode Label ':AssemblyStep'. Properties: { step_id: String (Constraint: UNIQUE), step_number: Integer, step_name: String, description: String, standard_duration_hours: Float, required_skill_level: String, workstation: String }. Relationship: (:AssemblyLine {line_id})-[:HAS_STEP {sequence: }]->(:AssemblyStep). Index on step_id.\nNode Label ':AircraftBuild'. Properties: { build_id: String (Constraint: UNIQUE), serial_number: String (Constraint: UNIQUE), build_start_date: Datetime, estimated_completion_date: Date, actual_completion_date: Datetime, current_status: String, customer_order_id: String }. Relationships: (:AircraftBuild)-[:IS_MODEL]->(:AircraftModel {model_id}), (:AircraftBuild)-[:ASSEMBLED_ON]->(:AssemblyLine {line_id}). Index on build_id, serial_number, current_status.\nNode Label ':Inspection'. Properties: { inspection_id: String (Constraint: UNIQUE), inspection_type: String, inspection_timestamp: Datetime, result: String, remarks: String }. Relationships: (:AircraftBuild {build_id})-[:UNDERWENT]->(:Inspection), (:Inspection)-[:PERFORMED_BY]->(:Employee {employee_id}), (:Inspection)-[:INSPECTED_COMPONENT]->(:Component {component_id}) (optional), (:Inspection)-[:FOLLOWED_STEP]->(:AssemblyStep {step_id}) (optional). Index on inspection_id.\nNode Label ':Employee'. Properties: { employee_id: String (Constraint: UNIQUE), first_name: String, last_name: String, job_title: String, skill_certifications: String[], hire_date: Date, employment_status: String }. Relationships: (:Employee)-[:ASSIGNED_TO]->(:AssemblyLine {line_id}), (:Employee)-[:REPORTS_TO]->(:Employee {employee_id as supervisor_id}). Index on employee_id.\nNode Label ':InventoryBatch'. Properties: { inventory_record_id: String (Constraint: UNIQUE), quantity: Integer, location_warehouse: String, location_bin: String, received_date: Datetime, expiry_date: Date, batch_number: String, last_updated: Datetime }. Relationship: (:InventoryBatch)-[:IS_INSTANCE_OF]->(:Component {component_id}). Index on inventory_record_id, component_id.\n", "conversations": [{"role": "user", "content": "I need to check the inventory status of components, including their batch details and warehouse location."}, {"role": "assistant", "content": "MATCH (i:InventoryBatch)-[:IS_INSTANCE_OF]->(c:Component)\nRETURN c.component_id, c.component_name, i.inventory_record_id, i.quantity, i.location_warehouse, i.location_bin, i.received_date, i.batch_number"}, {"role": "user", "content": "Can you filter this to show only batches with a quantity less than 50?"}, {"role": "assistant", "content": "MATCH (i:InventoryBatch)-[:IS_INSTANCE_OF]->(c:Component)\nWHERE i.quantity < 50\nRETURN c.component_id, c.component_name, i.inventory_record_id, i.quantity, i.location_warehouse, i.location_bin, i.received_date, i.batch_number"}, {"role": "user", "content": "What if I want to exclude batches with an expiry date before 2024?"}, {"role": "assistant", "content": "MATCH (i:InventoryBatch)-[:IS_INSTANCE_OF]->(c:Component)\nWHERE i.quantity < 50 AND i.expiry_date >= date('2024-01-01')\nRETURN c.component_id, c.component_name, i.inventory_record_id, i.quantity, i.location_warehouse, i.location_bin, i.received_date, i.batch_number"}, {"role": "user", "content": "Can you order the results by received date in descending order?"}, {"role": "assistant", "content": "MATCH (i:InventoryBatch)-[:IS_INSTANCE_OF]->(c:Component)\nWHERE i.quantity < 50 AND i.expiry_date >= date('2024-01-01')\nRETURN c.component_id, c.component_name, i.inventory_record_id, i.quantity, i.location_warehouse, i.location_bin, i.received_date, i.batch_number\nORDER BY i.received_date DESC"}]} {"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 PRIMARY KEY, 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 )\nCREATE TABLE financial_services.accounts ( account_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, account_number character varying(128) NOT NULL UNIQUE, account_type character varying(50) NOT NULL, balance numeric(19, 4) NOT NULL DEFAULT 0.00, currency character varying(3) NOT NULL, opened_date date NOT NULL, status character varying(32) NOT NULL, interest_rate numeric(5, 4), last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (account_id), FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id) )\nCREATE TABLE financial_services.transactions ( transaction_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, related_account_id character varying(64), transaction_type character varying(50) NOT NULL, amount numeric(19, 4) NOT NULL, currency character varying(3) NOT NULL, transaction_date timestamp NOT NULL, effective_date date NOT NULL, description text, status character varying(32) NOT NULL, reference_number character varying(128), PRIMARY KEY (transaction_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (related_account_id) REFERENCES financial_services.accounts(account_id) )\nCREATE TABLE financial_services.trades ( trade_id text PRIMARY KEY, account_id text, security_id text, order_id text, trade_type text, quantity numeric, price_per_unit numeric, total_amount numeric, commission numeric, trade_timestamp timestamp, settlement_date date, status text, execution_venue text )\nCREATE TABLE financial_services.market_data (\n data_point_id bigserial NOT NULL, -- auto-incrementing primary key\n security_id character varying(64) NOT NULL, -- identifier for the security\n data_timestamp timestamp NOT NULL, -- timestamp for the data point (e.g., end of day, intraday)\n open_price numeric(19, 8), -- opening price for the period\n high_price numeric(19, 8), -- highest price during the period\n low_price numeric(19, 8), -- lowest price during the period\n close_price numeric(19, 8) NOT NULL, -- closing price for the period\n adjusted_close_price numeric(19, 8), -- closing price adjusted for dividends and splits\n volume bigint, -- trading volume during the period\n source character varying(50), -- source of the market data (e.g., Bloomberg, Refinitiv)\n PRIMARY KEY (data_point_id),\n UNIQUE (security_id, data_timestamp), -- Ensure unique data point per security per time\n FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id)\n)\nCREATE TABLE financial_services.loans ( loan_id.text, account_id.text, loan_type.text, principal_amount.numeric, current_principal_balance.numeric, interest_rate.numeric, term_months.integer, origination_date.date, maturity_date.date, monthly_payment.numeric, collateral_description.text, status.text )\n", "conversations": [{"role": "user", "content": "For each account, show the account number, currency, and the sum of all incoming transaction amounts, where an incoming transaction is one where the account appears as related_account_id."}, {"role": "assistant", "content": "SELECT a.account_number, a.currency, COALESCE(SUM(t.amount), 0) AS total_incoming\nFROM financial_services.accounts a\nLEFT JOIN financial_services.transactions t ON a.account_id = t.related_account_id\nGROUP BY a.account_id, a.account_number, a.currency;"}, {"role": "user", "content": "Only include accounts with total incoming over 2000 and show the account type as well. Please order by total_incoming descending."}, {"role": "assistant", "content": "SELECT a.account_number, a.currency, a.account_type, COALESCE(SUM(t.amount), 0) AS total_incoming\nFROM financial_services.accounts a\nLEFT JOIN financial_services.transactions t ON a.account_id = t.related_account_id\nGROUP BY a.account_id, a.account_number, a.currency, a.account_type\nHAVING COALESCE(SUM(t.amount), 0) > 2000\nORDER BY total_incoming DESC;"}]} {"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 web3.transactions ( transaction_id text PRIMARY KEY, from_address text, to_address text, value numeric, gas_used int, gas_price numeric, block_number int, timestamp timestamp, input_data text, status text, nonce int )\n", "conversations": [{"role": "user", "content": "List all transactions that have a value less than 0.1 Ether, returning the transaction_id, from_address, to_address, value, and block_number."}, {"role": "assistant", "content": "SELECT transaction_id, from_address, to_address, value, block_number\nFROM web3.transactions\nWHERE value < 0.1;"}, {"role": "user", "content": "Actually, only show those where the status is 'failed'."}, {"role": "assistant", "content": "SELECT transaction_id, from_address, to_address, value, block_number\nFROM web3.transactions\nWHERE value < 0.1 AND status = 'failed';"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "Can you list all patients along with the insurance plan names they are enrolled in? Please include patient ID, first name, last name, and plan name."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, ip.plan_name\nFROM healthcare.patients p\nJOIN healthcare.patient_insurance pi ON p.patient_id = pi.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id;"}, {"role": "user", "content": "Show only patients who have more than one insurance plan."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, ip.plan_name\nFROM healthcare.patients p\nJOIN healthcare.patient_insurance pi ON p.patient_id = pi.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE p.patient_id IN (\n SELECT patient_id FROM healthcare.patient_insurance GROUP BY patient_id HAVING COUNT(DISTINCT plan_id) > 1\n);"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, address_line1.text, city.text, state_province.text, postal_code.text, country_code.text, preferences.text, loyalty_member_id.text, communication_consent.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, 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 integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.reviews (\n review_id character varying(64) NOT NULL, -- unique identifier for the review\n property_id character varying(64) NOT NULL, -- FK to properties table\n reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good)\n guest_id character varying(64) NOT NULL, -- FK to guests table\n rating_overall integer, -- overall score (e.g., 1-5 or 1-10)\n rating_cleanliness integer,\n rating_service integer,\n rating_location integer,\n rating_value integer,\n comment text, -- guest's written feedback\n review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com\n review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted\n is_public boolean DEFAULT true, -- whether the review is publicly visible\n staff_response text, -- official response from the property\n response_staff_id character varying(64), -- FK to staff (who responded)\n response_date timestamp with time zone, -- when the response was posted\n PRIMARY KEY (review_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "For each property, show the property_name, the total number of available services, and the average price of those services."}, {"role": "assistant", "content": "SELECT p.property_name,\n COUNT(s.service_id) AS total_available_services,\n AVG(s.price) AS avg_service_price\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.services s ON s.property_id = p.property_id\nWHERE s.is_available = TRUE\nGROUP BY p.property_name;"}, {"role": "user", "content": "Now exclude properties that have zero available services and only include those with an average price greater than 50."}, {"role": "assistant", "content": "SELECT p.property_name,\n COUNT(s.service_id) AS total_available_services,\n AVG(s.price) AS avg_service_price\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.services s ON s.property_id = p.property_id\nWHERE s.is_available = TRUE\nGROUP BY p.property_name\nHAVING COUNT(s.service_id) > 0\n AND AVG(s.price) > 50;"}, {"role": "user", "content": "Also, restrict the services to only those in the 'Wellness' and 'Spa' departments."}, {"role": "assistant", "content": "SELECT p.property_name,\n COUNT(s.service_id) AS total_available_services,\n AVG(s.price) AS avg_service_price\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.services s ON s.property_id = p.property_id\nWHERE s.is_available = TRUE\n AND s.department IN ('Wellness', 'Spa')\nGROUP BY p.property_name\nHAVING COUNT(s.service_id) > 0\n AND AVG(s.price) > 50;"}]} {"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.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id 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": "Show me the top 5 most recent medical records with a fever recorded. Return record_id, patient_id, record_date, and the temperature value from vitals."}, {"role": "assistant", "content": "SELECT record_id,\n patient_id,\n record_date,\n vitals->>'temperature' AS temperature\nFROM healthcare.medical_records\nWHERE (vitals->>'temperature')::numeric > 38\nORDER BY record_date DESC\nLIMIT 5;"}, {"role": "user", "content": "Actually, include only records where assessment is not empty."}, {"role": "assistant", "content": "SELECT record_id,\n patient_id,\n record_date,\n vitals->>'temperature' AS temperature\nFROM healthcare.medical_records\nWHERE (vitals->>'temperature')::numeric > 38\n AND assessment IS NOT NULL\n AND assessment <> ''\nORDER BY record_date DESC\nLIMIT 5;"}]} {"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 )\n", "conversations": [{"role": "user", "content": "Show me all staff members who have a manager assigned, along with each manager's full name."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name, s.manager_id, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM hospitality_technology.staff s\nLEFT JOIN hospitality_technology.staff m ON s.manager_id = m.staff_id\nWHERE s.manager_id IS NOT NULL;"}, {"role": "user", "content": "Actually, only include managers who are currently active."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name, s.manager_id, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM hospitality_technology.staff s\nLEFT JOIN hospitality_technology.staff m ON s.manager_id = m.staff_id\nWHERE s.manager_id IS NOT NULL AND m.is_active = TRUE;"}]} {"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 )\nCREATE TABLE financial_services.accounts ( account_id.text, customer_id.text, account_number.text, account_type.text, balance.numeric, currency.text, opened_date.date, status.text, interest_rate.numeric, last_updated_at.timestamp )\nCREATE TABLE financial_services.transactions ( transaction_id.text, account_id.text, related_account_id.text, transaction_type.text, amount.numeric, currency.text, transaction_date.timestamp, effective_date.date, description.text, status.text, reference_number.text )\nCREATE TABLE financial_services.securities ( security_id.text, ticker_symbol.text, isin_code.text, cusip_code.text, security_name.text, security_type.text, exchange.text, currency.text, issuer_name.text, sector.text, last_updated.timestamp )\nCREATE TABLE financial_services.trades ( trade_id.text, account_id.text, security_id.text, order_id.text, trade_type.text, quantity.numeric, price_per_unit.numeric, total_amount.numeric, commission.numeric, trade_timestamp.timestamp, settlement_date.date, status.text, execution_venue.text )\nCREATE TABLE financial_services.market_data ( data_point_id.bigint, security_id.text, data_timestamp.timestamp, open_price.numeric, high_price.numeric, low_price.numeric, close_price.numeric, adjusted_close_price.numeric, volume.bigint, source.text )\nCREATE TABLE financial_services.loans ( loan_id.text, account_id.text, loan_type.text, principal_amount.numeric, current_principal_balance.numeric, interest_rate.numeric, term_months.integer, origination_date.date, maturity_date.date, monthly_payment.numeric, collateral_description.text, status.text )\n", "conversations": [{"role": "user", "content": "Show me the total number of trades and the total traded value for each customer, including their first and last names."}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name, c.last_name, COUNT(t.trade_id) AS trade_count, SUM(t.total_amount) AS total_traded_value\nFROM financial_services.customers c\nJOIN financial_services.accounts a ON c.customer_id = a.customer_id\nJOIN financial_services.trades t ON a.account_id = t.account_id\nGROUP BY c.customer_id, c.first_name, c.last_name;"}, {"role": "user", "content": "Actually, only include customers who have executed more than 5 trades."}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name, c.last_name, COUNT(t.trade_id) AS trade_count, SUM(t.total_amount) AS total_traded_value\nFROM financial_services.customers c\nJOIN financial_services.accounts a ON c.customer_id = a.customer_id\nJOIN financial_services.trades t ON a.account_id = t.account_id\nGROUP BY c.customer_id, c.first_name, c.last_name\nHAVING COUNT(t.trade_id) > 5;"}]} {"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 all agencies and their main phone numbers."}, {"role": "assistant", "content": "SELECT agency_name, main_phone_number FROM government_services.agencies;"}, {"role": "user", "content": "Now show me the service locations associated with each of these agencies, including the location name and city."}, {"role": "assistant", "content": "SELECT a.agency_name, sl.location_name, sl.city FROM government_services.agencies AS a JOIN government_services.service_locations AS sl ON a.agency_id = sl.agency_id;"}, {"role": "user", "content": "Only include locations that are marked as accessible."}, {"role": "assistant", "content": "SELECT a.agency_name, sl.location_name, sl.city FROM government_services.agencies AS a JOIN government_services.service_locations AS sl ON a.agency_id = sl.agency_id WHERE sl.is_accessible = TRUE;"}, {"role": "user", "content": "And only for agencies with a jurisdiction level of 'Municipal'."}, {"role": "assistant", "content": "SELECT a.agency_name, sl.location_name, sl.city FROM government_services.agencies AS a JOIN government_services.service_locations AS sl ON a.agency_id = sl.agency_id WHERE sl.is_accessible = TRUE AND a.jurisdiction_level = 'Municipal';"}]} {"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 token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )\nCREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )\nCREATE TABLE cex_token_balance ( snapshot_time.text, chain.text, address.text, exchange.text, token_address.text, token_symbol.text, balance.numeric, usd_value.numeric, price.numeric )\nCREATE TABLE smart_money_token_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, chain.text )\n", "conversations": [{"role": "user", "content": "Show me tokens with a 24-hour trading volume over $1,000,000 from DEX pools that also have a positive net flow from smart money addresses. Display the token symbol, chain, 24h volume, and net flow."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0;"}, {"role": "user", "content": "Okay, now refine the results to only include tokens where the smart money ROI is greater than 5 (500%) and the realized ratio is above 0.5."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0 AND smtp.roi > 5 AND smtp.realized_ratio > 0.5;"}, {"role": "user", "content": "Add the token's current price from the basic info table and its narrative category to the results."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow, tbi.price AS current_price, tbi.narrative FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain JOIN token_basic_info AS tbi ON tdi.token_symbol = tbi.token_symbol AND tdi.chain = tbi.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0 AND smtp.roi > 5 AND smtp.realized_ratio > 0.5;"}, {"role": "user", "content": "Order the final list by 24-hour trading volume descending and show the top 10."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow, tbi.price AS current_price, tbi.narrative FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain JOIN token_basic_info AS tbi ON tdi.token_symbol = tbi.token_symbol AND tdi.chain = tbi.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0 AND smtp.roi > 5 AND smtp.realized_ratio > 0.5 ORDER BY tdi.volume_24h DESC LIMIT 10;"}]} {"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.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\n", "conversations": [{"role": "user", "content": "Find all diagnoses linked to prescriptions that have a quantity dispensed greater than 50. Show the diagnosis description and the diagnosis date."}, {"role": "assistant", "content": "SELECT T1.description, T1.diagnosis_date FROM healthcare.diagnoses AS T1 JOIN healthcare.prescriptions AS T2 ON T1.record_id = T2.record_id WHERE T2.quantity_dispensed > 50;"}, {"role": "user", "content": "Group the results by diagnosis description and count how many times each description appears. Only show descriptions that are linked to more than 1 such prescription."}, {"role": "assistant", "content": "SELECT T1.description, COUNT(T1.diagnosis_id) FROM healthcare.diagnoses AS T1 JOIN healthcare.prescriptions AS T2 ON T1.record_id = T2.record_id WHERE T2.quantity_dispensed > 50 GROUP BY T1.description HAVING COUNT(T1.diagnosis_id) > 1;"}]} {"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.text, firm_name.text, address.text, phone.text, website.text, founded_date.date, managing_partner_id.text )\n", "conversations": [{"role": "user", "content": "Find all pairs of law firms founded in the same year, showing both firm names and the shared founding year."}, {"role": "assistant", "content": "SELECT f1.firm_name AS firm1, f2.firm_name AS firm2, EXTRACT(YEAR FROM f1.founded_date) AS founding_year\nFROM legal_services.law_firms f1\nJOIN legal_services.law_firms f2\n ON EXTRACT(YEAR FROM f1.founded_date) = EXTRACT(YEAR FROM f2.founded_date)\n AND f1.firm_id < f2.firm_id;"}]} {"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.lawyers ( lawyer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, bar_number character varying(64) UNIQUE NOT NULL, firm_id character varying(64), email character varying(128) UNIQUE NOT NULL, phone character varying(32), specialization text, hire_date timestamp NOT NULL, is_partner boolean DEFAULT false, PRIMARY KEY (lawyer_id) )\n", "conversations": [{"role": "user", "content": "List all lawyers who were hired before the year 2020 and are partners. Show their full name (first and last name combined), bar number, and hire date. Order the results by hire date."}, {"role": "assistant", "content": "SELECT first_name || ' ' || last_name AS full_name, bar_number, hire_date FROM legal_services.lawyers WHERE hire_date < '2020-01-01' AND is_partner = TRUE ORDER BY hire_date;"}]} {"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 transportation.drivers ( driver_id.text, employee_id.text, first_name.text, last_name.text, license_number.text, license_expiry_date.date, contact_number.text, email.text, hire_date.date, status.text )\n", "conversations": [{"role": "user", "content": "For each driver, show their driver_id, first_name, last_name, along with any other driver whose license_expiry_date is earlier than theirs."}, {"role": "assistant", "content": "SELECT d1.driver_id AS driver_id,\n d1.first_name,\n d1.last_name,\n d2.driver_id AS earlier_driver_id,\n d2.license_expiry_date AS earlier_expiry_date\nFROM transportation.drivers d1\nJOIN transportation.drivers d2\n ON d2.license_expiry_date < d1.license_expiry_date;"}, {"role": "user", "content": "Exclude pairs where the two expiry dates are not in the same calendar year."}, {"role": "assistant", "content": "SELECT d1.driver_id AS driver_id,\n d1.first_name,\n d1.last_name,\n d2.driver_id AS earlier_driver_id,\n d2.license_expiry_date AS earlier_expiry_date\nFROM transportation.drivers d1\nJOIN transportation.drivers d2\n ON d2.license_expiry_date < d1.license_expiry_date\n AND EXTRACT(YEAR FROM d1.license_expiry_date) = EXTRACT(YEAR FROM d2.license_expiry_date);"}, {"role": "user", "content": "Also only include pairs where the difference between their expiry dates is more than 30 days."}, {"role": "assistant", "content": "SELECT d1.driver_id AS driver_id,\n d1.first_name,\n d1.last_name,\n d2.driver_id AS earlier_driver_id,\n d2.license_expiry_date AS earlier_expiry_date,\n DATE_PART('day', d1.license_expiry_date - d2.license_expiry_date) AS days_difference\nFROM transportation.drivers d1\nJOIN transportation.drivers d2\n ON d2.license_expiry_date < d1.license_expiry_date\n AND EXTRACT(YEAR FROM d1.license_expiry_date) = EXTRACT(YEAR FROM d2.license_expiry_date)\nWHERE d1.license_expiry_date - d2.license_expiry_date > INTERVAL '30 days';"}]} {"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.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 ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.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.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me the case number and case name for all cases, along with the full name of the lawyer who uploaded any document related to those cases."}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, l.first_name || ' ' || l.last_name AS lawyer_full_name\nFROM legal_services.cases c\nJOIN legal_services.documents d ON c.case_id = d.case_id\nJOIN legal_services.lawyers l ON d.uploaded_by_lawyer_id = l.lawyer_id;"}, {"role": "user", "content": "Please also include the document name and the time it was uploaded."}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, l.first_name || ' ' || l.last_name AS lawyer_full_name, d.document_name, d.upload_timestamp\nFROM legal_services.cases c\nJOIN legal_services.documents d ON c.case_id = d.case_id\nJOIN legal_services.lawyers l ON d.uploaded_by_lawyer_id = l.lawyer_id;"}, {"role": "user", "content": "Can you limit this to only documents that were uploaded on or after January 1, 2024?"}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, l.first_name || ' ' || l.last_name AS lawyer_full_name, d.document_name, d.upload_timestamp\nFROM legal_services.cases c\nJOIN legal_services.documents d ON c.case_id = d.case_id\nJOIN legal_services.lawyers l ON d.uploaded_by_lawyer_id = l.lawyer_id\nWHERE d.upload_timestamp >= '2024-01-01';"}]} {"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\nNode Label ':AircraftModel'. Properties: { model_id: String (Constraint: UNIQUE), model_name: String, manufacturer: String, passenger_capacity: Integer, max_range_km: Integer, engine_type: String, wingspan_m: Float, status: String, first_flight_date: Date }. Index on model_id.\nNode Label ':Component'. Properties: { component_id: String (Constraint: UNIQUE), part_number: String (Constraint: UNIQUE), component_name: String, description: String, weight_kg: Float, cost_usd: Float, criticality_level: String }. Relationships: (:Component)-[:MADE_OF]->(:Material {material_id}), (:Component)-[:SUPPLIED_BY]->(:Supplier {supplier_id}). Index on component_id, part_number.\nNode Label ':Material'. Properties: { material_id: String (Constraint: UNIQUE), material_name: String, specification: String, description: String, density_kg_m3: Float, tensile_strength_mpa: Integer }. Index on material_id.\nNode Label ':AssemblyLine'. Properties: { line_id: String (Constraint: UNIQUE), line_name: String, location_building: String, location_area: String, capacity_units_per_month: Integer, status: String }. Relationship: (:AssemblyLine)-[:BUILDS_MODEL]->(:AircraftModel {model_id}). Index on line_id.\nNode Label ':AssemblyStep'. Properties: { step_id: String (Constraint: UNIQUE), step_number: Integer, step_name: String, description: String, standard_duration_hours: Float, required_skill_level: String, workstation: String }. Relationship: (:AssemblyLine {line_id})-[:HAS_STEP {sequence: }]->(:AssemblyStep). Index on step_id.\nNode Label ':AircraftBuild'. Properties: { build_id: String (Constraint: UNIQUE), serial_number: String (Constraint: UNIQUE), build_start_date: Datetime, estimated_completion_date: Date, actual_completion_date: Datetime, current_status: String, customer_order_id: String }. Relationships: (:AircraftBuild)-[:IS_MODEL]->(:AircraftModel {model_id}), (:AircraftBuild)-[:ASSEMBLED_ON]->(:AssemblyLine {line_id}). Index on build_id, serial_number, current_status.\nNode Label ':Inspection'. Properties: { inspection_id: String (Constraint: UNIQUE), inspection_type: String, inspection_timestamp: Datetime, result: String, remarks: String }. Relationships: (:AircraftBuild {build_id})-[:UNDERWENT]->(:Inspection), (:Inspection)-[:PERFORMED_BY]->(:Employee {employee_id}), (:Inspection)-[:INSPECTED_COMPONENT]->(:Component {component_id}) (optional), (:Inspection)-[:FOLLOWED_STEP]->(:AssemblyStep {step_id}) (optional). Index on inspection_id.\n", "conversations": [{"role": "user", "content": "\u6211\u60f3\u67e5\u8be2\u67d0\u4e2a\u98de\u673a\u578b\u53f7\u7684\u6240\u6709\u6784\u5efa\u4fe1\u606f\uff0c\u5305\u62ec\u6784\u5efa\u7684\u5f00\u59cb\u65e5\u671f\u3001\u9884\u8ba1\u5b8c\u6210\u65e5\u671f\u4ee5\u53ca\u6240\u5728\u7684\u88c5\u914d\u7ebf\u540d\u79f0\u548c\u4f4d\u7f6e\u3002"}, {"role": "assistant", "content": "MATCH (am:AircraftModel)-[:IS_MODEL]-(ab:AircraftBuild)-[:ASSEMBLED_ON]->(al:AssemblyLine)\nWHERE am.model_id = 'specific_model_id'\nRETURN ab.build_id, ab.build_start_date, ab.estimated_completion_date, al.line_name, al.location_building, al.location_area"}, {"role": "user", "content": "\u80fd\u5426\u53ea\u663e\u793a\u5f53\u524d\u72b6\u6001\u4e3a'In Progress'\u7684\u6784\u5efa\u8bb0\u5f55\uff1f"}, {"role": "assistant", "content": "MATCH (am:AircraftModel)-[:IS_MODEL]-(ab:AircraftBuild)-[:ASSEMBLED_ON]->(al:AssemblyLine)\nWHERE am.model_id = 'specific_model_id' AND ab.current_status = 'In Progress'\nRETURN ab.build_id, ab.build_start_date, ab.estimated_completion_date, al.line_name, al.location_building, al.location_area"}, {"role": "user", "content": "\u5982\u679c\u6211\u60f3\u8fdb\u4e00\u6b65\u7b5b\u9009\u51fa\u5f00\u59cb\u65e5\u671f\u57282023\u5e741\u67081\u65e5\u4e4b\u540e\u7684\u8bb0\u5f55\uff0c\u5e94\u8be5\u600e\u4e48\u505a\uff1f"}, {"role": "assistant", "content": "MATCH (am:AircraftModel)-[:IS_MODEL]-(ab:AircraftBuild)-[:ASSEMBLED_ON]->(al:AssemblyLine)\nWHERE am.model_id = 'specific_model_id' AND ab.current_status = 'In Progress' AND ab.build_start_date >= datetime('2023-01-01')\nRETURN ab.build_id, ab.build_start_date, ab.estimated_completion_date, al.line_name, al.location_building, al.location_area"}, {"role": "user", "content": "\u8bf7\u6309\u6784\u5efa\u5f00\u59cb\u65e5\u671f\u4ece\u65e9\u5230\u665a\u6392\u5e8f\u7ed3\u679c\u3002"}, {"role": "assistant", "content": "MATCH (am:AircraftModel)-[:IS_MODEL]-(ab:AircraftBuild)-[:ASSEMBLED_ON]->(al:AssemblyLine)\nWHERE am.model_id = 'specific_model_id' AND ab.current_status = 'In Progress' AND ab.build_start_date >= datetime('2023-01-01')\nRETURN ab.build_id, ab.build_start_date, ab.estimated_completion_date, al.line_name, al.location_building, al.location_area\nORDER BY ab.build_start_date ASC"}]} {"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.transactions ( transaction_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, related_account_id character varying(64), transaction_type character varying(50) NOT NULL, amount numeric(19, 4) NOT NULL, currency character varying(3) NOT NULL, transaction_date timestamp NOT NULL, effective_date date NOT NULL, description text, status character varying(32) NOT NULL, reference_number character varying(128), PRIMARY KEY (transaction_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (related_account_id) REFERENCES financial_services.accounts(account_id) )\n", "conversations": [{"role": "user", "content": "Which accounts initiated transfer transactions to related accounts in April 2024, and what is the total amount sent per account?"}, {"role": "assistant", "content": "SELECT account_id, SUM(amount) AS total_sent\nFROM financial_services.transactions\nWHERE transaction_type = 'Transfer'\n AND transaction_date >= '2024-04-01' AND transaction_date < '2024-05-01'\n AND related_account_id IS NOT NULL\nGROUP BY account_id;"}, {"role": "user", "content": "Also include the number of such transactions for each account."}, {"role": "assistant", "content": "SELECT account_id, COUNT(*) AS transaction_count, SUM(amount) AS total_sent\nFROM financial_services.transactions\nWHERE transaction_type = 'Transfer'\n AND transaction_date >= '2024-04-01' AND transaction_date < '2024-05-01'\n AND related_account_id IS NOT NULL\nGROUP BY account_id;"}]} {"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 smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )\n", "conversations": [{"role": "user", "content": "Show all addresses that made their last trade in 2024, including their chain and profit."}, {"role": "assistant", "content": "SELECT address, chain, profit FROM smart_money_profit WHERE last_trade_time LIKE '2024%';"}]} {"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 text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id character varying(64) NOT NULL, case_number character varying(100) UNIQUE, case_name text NOT NULL, client_id character varying(64) NOT NULL, lead_lawyer_id character varying(64) NOT NULL, case_type character varying(100) NOT NULL, status character varying(50) NOT NULL, date_opened timestamp NOT NULL, date_closed timestamp, description text, court_jurisdiction character varying(128), PRIMARY KEY (case_id) )\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.invoices ( invoice_id text PRIMARY KEY, invoice_number text UNIQUE, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text PRIMARY KEY, 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 want each law firm's name, the total number of cases they have, and the total amount invoiced for those cases."}, {"role": "assistant", "content": "SELECT f.firm_name,\n COUNT(c.case_id) AS case_count,\n COALESCE(SUM(i.total_amount), 0) AS total_invoiced\nFROM legal_services.law_firms f\nLEFT JOIN legal_services.cases c ON f.managing_partner_id = c.lead_lawyer_id\nLEFT JOIN legal_services.invoices i ON c.case_id = i.case_id\nGROUP BY f.firm_name;"}, {"role": "user", "content": "Only include invoices with status 'Paid'."}, {"role": "assistant", "content": "SELECT f.firm_name,\n COUNT(c.case_id) AS case_count,\n COALESCE(SUM(i.total_amount), 0) AS total_invoiced\nFROM legal_services.law_firms f\nLEFT JOIN legal_services.cases c ON f.managing_partner_id = c.lead_lawyer_id\nLEFT JOIN legal_services.invoices i ON c.case_id = i.case_id AND i.status = 'Paid'\nGROUP BY f.firm_name;"}, {"role": "user", "content": "Also filter to firms founded after January 1st, 2010, and order by total_amount descending."}, {"role": "assistant", "content": "SELECT f.firm_name,\n COUNT(c.case_id) AS case_count,\n COALESCE(SUM(i.total_amount), 0) AS total_invoiced\nFROM legal_services.law_firms f\nLEFT JOIN legal_services.cases c ON f.managing_partner_id = c.lead_lawyer_id\nLEFT JOIN legal_services.invoices i ON c.case_id = i.case_id AND i.status = 'Paid'\nWHERE f.founded_date > '2010-01-01'\nGROUP BY f.firm_name\nORDER BY total_invoiced DESC;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, 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 integer, 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.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 )\nCREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, 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": "Which room types have the highest average base_rate? Return type_name and avg_rate, sorted descending, limit 5."}, {"role": "assistant", "content": "SELECT rt.type_name,\n AVG(rt.base_rate) AS avg_rate\nFROM hospitality_technology.room_types rt\nGROUP BY rt.type_name\nORDER BY avg_rate DESC\nLIMIT 5;"}, {"role": "user", "content": "Actually, I need the average per property as well, so include property_name and group by property."}, {"role": "assistant", "content": "SELECT p.property_name,\n rt.type_name,\n AVG(rt.base_rate) AS avg_rate\nFROM hospitality_technology.room_types rt\nJOIN hospitality_technology.properties p ON rt.property_id = p.property_id\nGROUP BY p.property_name, rt.type_name\nORDER BY avg_rate DESC\nLIMIT 5;"}, {"role": "user", "content": "Also only include room types with max_occupancy >= 2."}, {"role": "assistant", "content": "SELECT p.property_name,\n rt.type_name,\n AVG(rt.base_rate) AS avg_rate\nFROM hospitality_technology.room_types rt\nJOIN hospitality_technology.properties p ON rt.property_id = p.property_id\nWHERE rt.max_occupancy >= 2\nGROUP BY p.property_name, rt.type_name\nORDER BY avg_rate DESC\nLIMIT 5;"}]} {"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 social_media.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(50) NOT NULL UNIQUE, -- user's unique handle\n email character varying(128) NOT NULL UNIQUE, -- user's email address\n password_hash text NOT NULL, -- hashed password\n full_name character varying(100), -- user's full name\n profile_picture_url text, -- URL to the profile picture\n bio text, -- short user biography\n location character varying(100), -- user's location\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update\n is_verified boolean NOT NULL DEFAULT false, -- verification status\n PRIMARY KEY (user_id)\n)\nCREATE TABLE social_media.comments (\n comment_id character varying(64) NOT NULL, -- unique identifier for the comment\n post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)\n user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)\n parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)\n content text NOT NULL, -- textual content of the comment\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit\n PRIMARY KEY (comment_id)\n)\nCREATE TABLE social_media.likes (\n like_id character varying(64) NOT NULL, -- unique identifier for the like\n user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id)\n post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable)\n comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred\n PRIMARY KEY (like_id),\n CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes\n CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something\n)\nCREATE TABLE social_media.follows (\n follow_id character varying(64) NOT NULL, -- unique identifier for the follow relationship\n follower_user_id character varying(64) NOT NULL, -- identifier of the user who is following (FK to users.user_id)\n following_user_id character varying(64) NOT NULL, -- identifier of the user being followed (FK to users.user_id)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the follow started\n PRIMARY KEY (follow_id),\n CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) -- prevent duplicate follows\n)\nCREATE TABLE social_media.hashtags (\n hashtag_id character varying(64) NOT NULL, -- unique identifier for the hashtag\n tag_name character varying(100) NOT NULL UNIQUE, -- the actual hashtag text (without '#')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when the hashtag was first used\n PRIMARY KEY (hashtag_id)\n)\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.conversation_participants (\n participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry\n conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)\n user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)\n joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation\n last_read_at timestamp, -- timestamp indicating up to when the user has read messages\n PRIMARY KEY (participant_id),\n CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times\n)\nCREATE TABLE social_media.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)\n sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)\n notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')\n target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)\n target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created\n read_at timestamp, -- timestamp notification was marked as read\n PRIMARY KEY (notification_id)\n)\nCREATE TABLE social_media.user_settings (\n setting_id character varying(64) NOT NULL, -- unique identifier for the setting entry\n user_id character varying(64) NOT NULL UNIQUE, -- user the settings belong to (FK to users.user_id)\n theme character varying(20) DEFAULT 'light', -- UI theme ('light', 'dark')\n email_notifications_enabled boolean DEFAULT true, -- enable/disable email notifications\n push_notifications_enabled boolean DEFAULT true, -- enable/disable push notifications\n private_profile boolean DEFAULT false, -- is the user profile private\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last setting change\n PRIMARY KEY (setting_id)\n)\n", "conversations": [{"role": "user", "content": "For each hashtag, show its tag name and the number of unique users who have ever commented on posts associated with that hashtag."}, {"role": "assistant", "content": "SELECT h.tag_name, COUNT(DISTINCT c.user_id) AS unique_commenters\nFROM social_media.hashtags h\nJOIN social_media.post_hashtags ph ON h.hashtag_id = ph.hashtag_id\nJOIN social_media.comments c ON ph.post_id = c.post_id\nGROUP BY h.hashtag_id, h.tag_name;"}, {"role": "user", "content": "Only show hashtags that have more than 10 unique commenters, and order them by the number of unique commenters descending."}, {"role": "assistant", "content": "SELECT h.tag_name, COUNT(DISTINCT c.user_id) AS unique_commenters\nFROM social_media.hashtags h\nJOIN social_media.post_hashtags ph ON h.hashtag_id = ph.hashtag_id\nJOIN social_media.comments c ON ph.post_id = c.post_id\nGROUP BY h.hashtag_id, h.tag_name\nHAVING COUNT(DISTINCT c.user_id) > 10\nORDER BY unique_commenters DESC;"}]} {"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.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\n", "conversations": [{"role": "user", "content": "For each case type, calculate the average time to close cases in days, only including cases that have been closed."}, {"role": "assistant", "content": "SELECT case_type,\n AVG(EXTRACT(EPOCH FROM (date_closed - date_opened)) / 86400) AS avg_close_days\nFROM legal_services.cases\nWHERE status = 'Closed'\n AND date_closed IS NOT NULL\nGROUP BY case_type;"}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "List all pairs of insurance products that share the same product_type but have differing active statuses. Return both product_ids, the product_type, and each is_active flag."}, {"role": "assistant", "content": "SELECT p1.product_id AS product_id_1, p2.product_id AS product_id_2, p1.product_type, p1.is_active AS is_active_1, p2.is_active AS is_active_2\nFROM insurance.insurance_products p1\nJOIN insurance.insurance_products p2\n ON p1.product_type = p2.product_type\n AND p1.is_active <> p2.is_active\nWHERE p1.product_id < p2.product_id;"}]} {"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.transactions ( transaction_id.text, account_id.text, related_account_id.text, transaction_type.text, amount.numeric, currency.text, transaction_date.timestamp, effective_date.date, description.text, status.text, reference_number.text )\nCREATE TABLE financial_services.market_data ( data_point_id.bigint, security_id.text, data_timestamp.timestamp, open_price.numeric, high_price.numeric, low_price.numeric, close_price.numeric, adjusted_close_price.numeric, volume.bigint, source.text )\n", "conversations": [{"role": "user", "content": "Find the total transaction amount and total trade volume for each currency for today."}, {"role": "assistant", "content": "SELECT t.currency, SUM(t.amount) AS total_transaction_amount, SUM(md.volume) AS total_trade_volume\nFROM financial_services.transactions t\nLEFT JOIN financial_services.market_data md ON t.transaction_date::date = md.data_timestamp::date\nWHERE t.transaction_date::date = CURRENT_DATE\nGROUP BY t.currency\nORDER BY t.currency ASC;"}, {"role": "user", "content": "Remove currencies where the total transaction amount is less than 5000."}, {"role": "assistant", "content": "SELECT t.currency, SUM(t.amount) AS total_transaction_amount, SUM(md.volume) AS total_trade_volume\nFROM financial_services.transactions t\nLEFT JOIN financial_services.market_data md ON t.transaction_date::date = md.data_timestamp::date\nWHERE t.transaction_date::date = CURRENT_DATE\nGROUP BY t.currency\nHAVING SUM(t.amount) >= 5000\nORDER BY t.currency ASC;"}, {"role": "user", "content": "Please sort the result by total_trade_volume in descending order."}, {"role": "assistant", "content": "SELECT t.currency, SUM(t.amount) AS total_transaction_amount, SUM(md.volume) AS total_trade_volume\nFROM financial_services.transactions t\nLEFT JOIN financial_services.market_data md ON t.transaction_date::date = md.data_timestamp::date\nWHERE t.transaction_date::date = CURRENT_DATE\nGROUP BY t.currency\nHAVING SUM(t.amount) >= 5000\nORDER BY total_trade_volume DESC;"}]} {"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 transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date )\n", "conversations": [{"role": "user", "content": "I want to know how many vehicles are assigned to each depot_id."}, {"role": "assistant", "content": "SELECT depot_id, COUNT(*) AS vehicle_count FROM transportation.vehicles GROUP BY depot_id;"}, {"role": "user", "content": "Please only include depots with more than 10 vehicles."}, {"role": "assistant", "content": "SELECT depot_id, COUNT(*) AS vehicle_count FROM transportation.vehicles GROUP BY depot_id HAVING COUNT(*) > 10;"}, {"role": "user", "content": "Also include the average capacity of vehicles in each depot."}, {"role": "assistant", "content": "SELECT depot_id, COUNT(*) AS vehicle_count, AVG(capacity) AS avg_capacity FROM transportation.vehicles GROUP BY depot_id HAVING COUNT(*) > 10;"}, {"role": "user", "content": "Sort the result by avg_capacity descending and limit to the top 3 depots."}, {"role": "assistant", "content": "SELECT depot_id, COUNT(*) AS vehicle_count, AVG(capacity) AS avg_capacity FROM transportation.vehicles GROUP BY depot_id HAVING COUNT(*) > 10 ORDER BY avg_capacity DESC LIMIT 3;"}]} {"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 project_fundraising_record ( id character varying(32) NOT NULL, project_id character varying(32) NOT NULL, project_name character varying(128) NOT NULL, rounds_name character varying(32), investment_value numeric(38,14), investment_date character varying(128), introduction character varying(128), valuation numeric(38,14) )\nCREATE TABLE narrative_info ( narrative character varying(512) NOT NULL, top_3_coins text, price_change_percentage_1h double precision, price_change_percentage_24h double precision, price_change_percentage_7d double precision, market_cap double precision, volume_24h double precision, trend_rank bigint, token_num bigint )\nCREATE TABLE token_dexpool_info ( pair_address character varying(512) NOT NULL, token_name character varying(100) NOT NULL, token_symbol character varying(100) NOT NULL, chain text, price double precision, price_change_percentage_1h double precision, price_change_percentage_6h double precision, price_change_percentage_24h double precision, makers_24h double precision, volume_24h double precision, liquidity double precision, market_cap double precision, trend_rank bigint )\nCREATE TABLE cex_token_balance ( snapshot_time character varying(32) NOT NULL, chain character varying(128) NOT NULL, address character varying(128) NOT NULL, exchange character varying(512) NOT NULL, token_address character varying(128) NOT NULL, token_symbol character varying(512), balance numeric(38,10), usd_value numeric(38,14), price double precision )\nCREATE TABLE smart_money_token_performance ( token_address character varying(100) NOT NULL, token_symbol character varying(100), pnl numeric(38,2), net_flow numeric(38,2), avg_cost numeric(38,16), price double precision, realized_ratio numeric(10,2), roi numeric(10,2), chain character varying(100) )\n", "conversations": [{"role": "user", "content": "For each narrative, show its name and the total market cap of all related tokens based on DEX pool data."}, {"role": "assistant", "content": "SELECT n.narrative, SUM(d.market_cap) AS total_market_cap\nFROM narrative_info n\nJOIN token_dexpool_info d ON n.top_3_coins LIKE CONCAT('%', d.token_symbol, '%')\nGROUP BY n.narrative;"}, {"role": "user", "content": "Could you also include the number of tokens per narrative as a column in the result?"}, {"role": "assistant", "content": "SELECT n.narrative, COUNT(DISTINCT d.token_symbol) AS token_count, SUM(d.market_cap) AS total_market_cap\nFROM narrative_info n\nJOIN token_dexpool_info d ON n.top_3_coins LIKE CONCAT('%', d.token_symbol, '%')\nGROUP BY n.narrative;"}, {"role": "user", "content": "I want to filter out narratives where the total market cap is less than 100 million USD."}, {"role": "assistant", "content": "SELECT n.narrative, COUNT(DISTINCT d.token_symbol) AS token_count, SUM(d.market_cap) AS total_market_cap\nFROM narrative_info n\nJOIN token_dexpool_info d ON n.top_3_coins LIKE CONCAT('%', d.token_symbol, '%')\nGROUP BY n.narrative\nHAVING SUM(d.market_cap) >= 100000000;"}]} {"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.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.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 )\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\n", "conversations": [{"role": "user", "content": "Count the number of documents for each document type."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) FROM government_services.documents GROUP BY document_type;"}, {"role": "user", "content": "Only include document types that have more than 50 documents."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) FROM government_services.documents GROUP BY document_type HAVING COUNT(*) > 50;"}, {"role": "user", "content": "Exclude documents that have an expiry date in the past."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) FROM government_services.documents WHERE expiry_date IS NULL OR expiry_date >= CURRENT_DATE GROUP BY document_type HAVING COUNT(*) > 50;"}, {"role": "user", "content": "Show the results ordered by the count in descending order."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) FROM government_services.documents WHERE expiry_date IS NULL OR expiry_date >= CURRENT_DATE GROUP BY document_type HAVING COUNT(*) > 50 ORDER BY COUNT(*) DESC;"}]} {"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.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\n", "conversations": [{"role": "user", "content": "Find pairs of cases that share the same client and have the same status, but are different cases. Display the case name and case number for both cases in the pair, along with the shared client ID and shared status."}, {"role": "assistant", "content": "SELECT T1.case_name, T1.case_number, T2.case_name, T2.case_number, T1.client_id, T1.status FROM legal_services.cases AS T1 JOIN legal_services.cases AS T2 ON T1.client_id = T2.client_id AND T1.status = T2.status WHERE T1.case_id < T2.case_id;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id text PRIMARY KEY, property_id text, room_number text, room_type_id text, floor int, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text PRIMARY KEY, property_id text, type_name text, description text, base_rate numeric, max_occupancy int, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.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 text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.payments ( payment_id text PRIMARY KEY, 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 each room type with their maximum occupancy and the total number of rooms of that type across all properties."}, {"role": "assistant", "content": "SELECT rt.room_type_id, rt.type_name, rt.max_occupancy, COUNT(r.room_id) AS total_rooms \nFROM hospitality_technology.room_types rt \nLEFT JOIN hospitality_technology.rooms r ON rt.room_type_id = r.room_type_id \nGROUP BY rt.room_type_id, rt.type_name, rt.max_occupancy;"}, {"role": "user", "content": "Only include room types where maximum occupancy is greater than 2."}, {"role": "assistant", "content": "SELECT rt.room_type_id, rt.type_name, rt.max_occupancy, COUNT(r.room_id) AS total_rooms \nFROM hospitality_technology.room_types rt \nLEFT JOIN hospitality_technology.rooms r ON rt.room_type_id = r.room_type_id \nWHERE rt.max_occupancy > 2 \nGROUP BY rt.room_type_id, rt.type_name, rt.max_occupancy;"}, {"role": "user", "content": "Also, display the property name for each room type."}, {"role": "assistant", "content": "SELECT rt.room_type_id, rt.type_name, rt.max_occupancy, COUNT(r.room_id) AS total_rooms, p.property_name \nFROM hospitality_technology.room_types rt \nJOIN hospitality_technology.properties p ON rt.property_id = p.property_id \nLEFT JOIN hospitality_technology.rooms r ON rt.room_type_id = r.room_type_id \nWHERE rt.max_occupancy > 2 \nGROUP BY rt.room_type_id, rt.type_name, rt.max_occupancy, p.property_name;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id 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.appointments ( appointment_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, appointment_time timestamp with time zone NOT NULL, duration_minutes integer NOT NULL, reason text, status character varying(32) NOT NULL, location_id character varying(64), notes text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (appointment_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) )\n", "conversations": [{"role": "user", "content": "Show all diagnoses, including the diagnosis ID, description, diagnosis date, and the full name of the doctor who made the diagnosis."}, {"role": "assistant", "content": "SELECT T1.diagnosis_id, T1.description, T1.diagnosis_date, T2.first_name, T2.last_name FROM healthcare.diagnoses AS T1 JOIN healthcare.doctors AS T2 ON T1.doctor_id = T2.doctor_id;"}, {"role": "user", "content": "Refine this list to only include diagnoses where the diagnosis_date is in the year 2023 and the doctor's specialty is 'Cardiology'."}, {"role": "assistant", "content": "SELECT T1.diagnosis_id, T1.description, T1.diagnosis_date, T2.first_name, T2.last_name FROM healthcare.diagnoses AS T1 JOIN healthcare.doctors AS T2 ON T1.doctor_id = T2.doctor_id WHERE T2.specialty = 'Cardiology' AND EXTRACT(YEAR FROM T1.diagnosis_date) = 2023;"}]} {"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.accounts (\n account_id character varying(64) NOT NULL, -- unique identifier for the account\n customer_id character varying(64) NOT NULL, -- foreign key linking to the customer\n account_number character varying(128) NOT NULL UNIQUE, -- unique account number visible to customer\n account_type character varying(50) NOT NULL, -- e.g., Checking, Savings, Investment, Loan, Credit Card\n balance numeric(19, 4) NOT NULL DEFAULT 0.00, -- current account balance\n currency character varying(3) NOT NULL, -- currency code (e.g., USD, EUR)\n opened_date date NOT NULL, -- date the account was opened\n status character varying(32) NOT NULL, -- e.g., Open, Closed, Frozen\n interest_rate numeric(5, 4), -- annual interest rate, if applicable\n last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last account update\n PRIMARY KEY (account_id),\n FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id)\n)\n", "conversations": [{"role": "user", "content": "For each customer, provide a summary of their account statuses, showing their full name, account status, and the count of accounts for each status."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, a.status, COUNT(a.account_id) AS account_count FROM financial_services.accounts a JOIN financial_services.customers c ON a.customer_id = c.customer_id GROUP BY c.customer_id, c.first_name, c.last_name, a.status ORDER BY c.last_name, c.first_name, a.status;"}, {"role": "user", "content": "Refine this to only include customers who have accounts in at least two different statuses."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, a.status, COUNT(a.account_id) AS account_count FROM financial_services.accounts a JOIN financial_services.customers c ON a.customer_id = c.customer_id GROUP BY c.customer_id, c.first_name, c.last_name, a.status HAVING c.customer_id IN ( SELECT customer_id FROM financial_services.accounts GROUP BY customer_id HAVING COUNT(DISTINCT status) >= 2 ) ORDER BY c.last_name, c.first_name, a.status;"}]} {"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 social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\n", "conversations": [{"role": "user", "content": "I need all pairs of hashtags that start with the same first two letters. Show both tag names."}, {"role": "assistant", "content": "SELECT h1.tag_name AS tag1, h2.tag_name AS tag2\nFROM social_media.hashtags h1\nJOIN social_media.hashtags h2\n ON LEFT(h1.tag_name, 2) = LEFT(h2.tag_name, 2)\n AND h1.hashtag_id <> h2.hashtag_id;"}, {"role": "user", "content": "Please filter these pairs to include only those created in the same year."}, {"role": "assistant", "content": "SELECT h1.tag_name AS tag1, h2.tag_name AS tag2\nFROM social_media.hashtags h1\nJOIN social_media.hashtags h2\n ON LEFT(h1.tag_name, 2) = LEFT(h2.tag_name, 2)\n AND EXTRACT(YEAR FROM h1.created_at) = EXTRACT(YEAR FROM h2.created_at)\n AND h1.hashtag_id <> h2.hashtag_id;"}, {"role": "user", "content": "Now also include the year in the output."}, {"role": "assistant", "content": "SELECT h1.tag_name AS tag1, h2.tag_name AS tag2, EXTRACT(YEAR FROM h1.created_at) AS year\nFROM social_media.hashtags h1\nJOIN social_media.hashtags h2\n ON LEFT(h1.tag_name, 2) = LEFT(h2.tag_name, 2)\n AND EXTRACT(YEAR FROM h1.created_at) = EXTRACT(YEAR FROM h2.created_at)\n AND h1.hashtag_id <> h2.hashtag_id;"}]} {"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.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types ( room_type_id.text, property_id.text, type_name.text, description.text, base_rate.numeric, max_occupancy.integer, bed_type.text, area_sqft.numeric, amenities.text )\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\nCREATE TABLE hospitality_technology.staff (\n staff_id character varying(64) NOT NULL, -- unique identifier for the staff member\n property_id character varying(64) NOT NULL, -- FK to properties table (primary property)\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge\n work_email character varying(255) UNIQUE, -- staff member's work email\n work_phone character varying(30),\n hire_date date NOT NULL,\n termination_date date, -- date employment ended (if applicable)\n is_active boolean NOT NULL DEFAULT true, -- currently employed flag\n access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin)\n manager_id character varying(64), -- FK to staff table (self-referencing for supervisor)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (staff_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id)\n)\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 (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "List all staff members, including their first name, last name, position, and the name of the property they work at."}, {"role": "assistant", "content": "SELECT s.first_name, s.last_name, s.position, p.property_name FROM hospitality_technology.staff s JOIN hospitality_technology.properties p ON s.property_id = p.property_id;"}]} {"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.transactions (\n transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction\n block_id character varying(64) NOT NULL, -- identifier of the block containing the transaction\n sender_address character varying(128) NOT NULL, -- address of the sender\n receiver_address character varying(128) NOT NULL, -- address of the receiver\n amount numeric(38,14) NOT NULL, -- amount transferred\n timestamp timestamp NOT NULL, -- time when the transaction was created\n signature text NOT NULL, -- digital signature of the transaction\n PRIMARY KEY (transaction_id)\n)\n", "conversations": [{"role": "user", "content": "Find all pairs of transactions where the sender address and the receiver address are the same, but the transactions occurred on different days. Show transaction IDs, addresses, and their timestamps."}, {"role": "assistant", "content": "SELECT t1.transaction_id AS tx1_id, t2.transaction_id AS tx2_id, t1.sender_address, t1.timestamp AS tx1_time, t2.timestamp AS tx2_time\nFROM blockchain.transactions t1\nJOIN blockchain.transactions t2\n ON t1.sender_address = t2.sender_address\n AND t1.receiver_address = t2.receiver_address\n AND t1.transaction_id <> t2.transaction_id\n AND DATE(t1.timestamp) <> DATE(t2.timestamp)\nWHERE t1.sender_address = t1.receiver_address;"}, {"role": "user", "content": "Exclude pairs where the two transactions happened more than 7 days apart."}, {"role": "assistant", "content": "SELECT t1.transaction_id AS tx1_id, t2.transaction_id AS tx2_id, t1.sender_address, t1.timestamp AS tx1_time, t2.timestamp AS tx2_time\nFROM blockchain.transactions t1\nJOIN blockchain.transactions t2\n ON t1.sender_address = t2.sender_address\n AND t1.receiver_address = t2.receiver_address\n AND t1.transaction_id <> t2.transaction_id\n AND DATE(t1.timestamp) <> DATE(t2.timestamp)\nWHERE t1.sender_address = t1.receiver_address\n AND ABS(DATE_PART('day', t1.timestamp - t2.timestamp)) <= 7;"}]} {"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) )\nCREATE TABLE gaming_technology.games ( game_id uuid PRIMARY KEY, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, game_id uuid NOT NULL, server_id uuid, start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, end_time timestamp with time zone, duration_seconds integer, score integer, session_data jsonb, PRIMARY KEY (session_id) )\nCREATE TABLE gaming_technology.servers ( server_id uuid PRIMARY KEY, game_id uuid, server_name text, region text, ip_address text, port int, current_players int, max_players int, status text, last_heartbeat timestamptz )\nCREATE TABLE gaming_technology.achievements ( achievement_id.uuid, game_id.uuid, name.text, description.text, icon_url.text, points.integer, hidden.boolean )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid PRIMARY KEY, player_id uuid, achievement_id uuid, unlocked_at timestamptz )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid PRIMARY KEY, player_id uuid, item_id uuid, quantity int, acquired_at timestamptz, instance_data jsonb )\n", "conversations": [{"role": "user", "content": "For each player, list their username together with the titles of games they have any items from in their inventory."}, {"role": "assistant", "content": "SELECT DISTINCT p.username, g.title\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id;"}, {"role": "user", "content": "Now restrict the list to only include items of rarity 'Epic'."}, {"role": "assistant", "content": "SELECT DISTINCT p.username, g.title\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE i.rarity = 'Epic';"}, {"role": "user", "content": "Also include the quantity of each epic item and sort the output by quantity in descending order."}, {"role": "assistant", "content": "SELECT p.username, g.title, i.item_name, pi.quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE i.rarity = 'Epic'\nORDER BY pi.quantity DESC;"}, {"role": "user", "content": "Finally, filter out entries where the quantity is less than 2."}, {"role": "assistant", "content": "SELECT p.username, g.title, i.item_name, pi.quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE i.rarity = 'Epic'\n AND pi.quantity >= 2\nORDER BY pi.quantity DESC;"}]} {"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\n \"CREATE TABLE cex_token_balance (\",\n \"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp\",\n \"chain character varying(128) NOT NULL, -- the chain that the token resides\",\n \"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX\",\n \"exchange character varying(512) NOT NULL, -- a centralized exchange name\",\n \"token_address character varying(128) NOT NULL, -- token contract address\",\n \"token_symbol character varying(512), --token symbol\",\n \"balance numeric(38,10), -- token balance\",\n \"usd_value numeric(38,14), -- value of the token held in USD\",\n \"price double precision, --price of the token in USD\",\n \",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));\"\n\n", "conversations": [{"role": "user", "content": "Find all tokens on the 'BSC' chain in the latest snapshot where the individual holding `usd_value` is greater than $1,000,000. Show their symbol, exchange, balance, and USD value."}, {"role": "assistant", "content": "WITH latest_snapshot AS (\n SELECT max(snapshot_time) as max_time\n FROM cex_token_balance\n)\nSELECT token_symbol, exchange, balance, usd_value\nFROM cex_token_balance ctb\nJOIN latest_snapshot ls ON ctb.snapshot_time = ls.max_time\nWHERE chain = 'BSC' AND usd_value > 1000000.0;"}]} {"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.achievements (\n achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition\n game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to\n name character varying(150) NOT NULL, -- name of the achievement\n description text NOT NULL, -- how to unlock the achievement\n icon_url character varying(255), -- URL for the achievement's icon\n points integer DEFAULT 0, -- points awarded for unlocking (optional)\n hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked\n PRIMARY KEY (achievement_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\n", "conversations": [{"role": "user", "content": "Can you list the names of achievements and the length of their descriptions? Show the ones with the longest descriptions first."}, {"role": "assistant", "content": "SELECT name, LENGTH(description) AS description_length FROM achievements ORDER BY description_length DESC LIMIT 10;"}, {"role": "user", "content": "For these achievements, can you also show the title of the game they belong to?"}, {"role": "assistant", "content": "SELECT a.name, LENGTH(a.description) AS description_length, g.name AS game_title FROM achievements AS a JOIN games AS g ON a.game_id = g.game_id ORDER BY description_length DESC LIMIT 10;"}, {"role": "user", "content": "Also, please only include achievements that are not hidden."}, {"role": "assistant", "content": "SELECT a.name, LENGTH(a.description) AS description_length, g.name AS game_title FROM achievements AS a JOIN games AS g ON a.game_id = g.game_id WHERE a.hidden = FALSE ORDER BY description_length DESC LIMIT 10;"}]} {"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.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\n", "conversations": [{"role": "user", "content": "Can you list the number of items for each rarity in the system?"}, {"role": "assistant", "content": "SELECT rarity, COUNT(*) AS item_count\nFROM gaming_technology.in_game_items\nGROUP BY rarity;"}, {"role": "user", "content": "Please only show rarities with at least 3 items."}, {"role": "assistant", "content": "SELECT rarity, COUNT(*) AS item_count\nFROM gaming_technology.in_game_items\nGROUP BY rarity\nHAVING COUNT(*) >= 3;"}, {"role": "user", "content": "Can you also display the minimum, maximum, and average cost amount for each rarity?"}, {"role": "assistant", "content": "SELECT rarity, COUNT(*) AS item_count, MIN(cost_amount) AS min_cost, MAX(cost_amount) AS max_cost, AVG(cost_amount) AS avg_cost\nFROM gaming_technology.in_game_items\nGROUP BY rarity\nHAVING COUNT(*) >= 3;"}]} {"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 trading_platform.trades ( trade_id text, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp )\nCREATE TABLE trading_platform.utxos ( utxo_id text, transaction_id text, output_index integer, address text, amount numeric, spent boolean )\nCREATE TABLE trading_platform.metadata ( metadata_id text, asset_id text, key text, value text )\nCREATE TABLE trading_platform.notifications ( notification_id text, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "Show each user's total count of notifications and, for each, how many of them have been read."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS total_notifications, COUNT(read_at) AS notifications_read \nFROM trading_platform.notifications \nGROUP BY user_id;"}, {"role": "user", "content": "Please only include users who have more than 2 notifications."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS total_notifications, COUNT(read_at) AS notifications_read \nFROM trading_platform.notifications \nGROUP BY user_id \nHAVING COUNT(*) > 2;"}, {"role": "user", "content": "Now, for these users, show the most recent sent_at date for any notification."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS total_notifications, COUNT(read_at) AS notifications_read, MAX(sent_at) AS last_notification_sent_at \nFROM trading_platform.notifications \nGROUP BY user_id \nHAVING COUNT(*) > 2;"}, {"role": "user", "content": "Also, display only those users who have at least one read notification."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS total_notifications, COUNT(read_at) AS notifications_read, MAX(sent_at) AS last_notification_sent_at \nFROM trading_platform.notifications \nGROUP BY user_id \nHAVING COUNT(*) > 2 AND COUNT(read_at) > 0;"}]} {"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id.text, property_name.text, address_line1.text, address_line2.text, city.text, state_province.text, postal_code.text, country_code.text, phone_number.text, email_address.text, property_type.text, star_rating.numeric, timezone.text, manager_staff_id.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id.text, property_id.text, room_number.text, room_type_id.text, floor.integer, status.text, is_smoking.boolean, features.text, current_condition.text, last_cleaned_at.timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id.text, property_id.text, type_name.text, description.text, base_rate.numeric, max_occupancy.integer, bed_type.text, area_sqft.numeric, amenities.text )\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 )\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, property_id.text, reservation_id.text, guest_id.text, rating_overall.integer, rating_cleanliness.integer, rating_service.integer, rating_location.integer, rating_value.integer, 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": "List all service orders for spa services in the last month, including the guest ID and total price."}, {"role": "assistant", "content": "SELECT order_id, guest_id, total_price FROM hospitality_technology.service_orders WHERE service_id LIKE 'SPA%' AND order_timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);"}, {"role": "user", "content": "Now, include only orders with a total price over $100 and order them by total price in descending order."}, {"role": "assistant", "content": "SELECT order_id, guest_id, total_price FROM hospitality_technology.service_orders WHERE service_id LIKE 'SPA%' AND order_timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND total_price > 100 ORDER BY total_price DESC;"}, {"role": "user", "content": "The query is missing the property ID. Can you include that as well?"}, {"role": "assistant", "content": "SELECT so.order_id, so.guest_id, so.total_price, r.property_id FROM hospitality_technology.service_orders so JOIN hospitality_technology.reservations r ON so.reservation_id = r.reservation_id WHERE so.service_id LIKE 'SPA%' AND so.order_timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND so.total_price > 100 ORDER BY so.total_price DESC;"}, {"role": "user", "content": "Actually, I need to see the service description too, and order by guest ID."}, {"role": "assistant", "content": "SELECT so.order_id, so.guest_id, so.total_price, r.property_id, s.description FROM hospitality_technology.service_orders so JOIN hospitality_technology.reservations r ON so.reservation_id = r.reservation_id JOIN hospitality_technology.services s ON so.service_id = s.service_id WHERE so.service_id LIKE 'SPA%' AND so.order_timestamp >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND so.total_price > 100 ORDER BY so.guest_id;"}]} {"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 social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "List the user ID, theme, and updated_at for users who have updated their settings in the last 90 days and have their theme set to 'dark'."}, {"role": "assistant", "content": "SELECT user_id, theme, updated_at FROM social_media.user_settings WHERE updated_at >= NOW() - INTERVAL '90 days' AND theme = 'dark';"}, {"role": "user", "content": "Refine the list to only show users who have also disabled push notifications."}, {"role": "assistant", "content": "SELECT user_id, theme, updated_at FROM social_media.user_settings WHERE updated_at >= NOW() - INTERVAL '90 days' AND theme = 'dark' AND push_notifications_enabled = FALSE;"}]} {"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.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 )\n", "conversations": [{"role": "user", "content": "List each agent along with their manager's contact_email. Include agent_id, first_name, last_name, manager_id, and manager's contact_email."}, {"role": "assistant", "content": "SELECT a.agent_id,\n a.first_name,\n a.last_name,\n a.manager_id,\n m.contact_email AS manager_contact_email\nFROM insurance.agents a\nLEFT JOIN insurance.agents m\n ON a.manager_id = m.agent_id;"}, {"role": "user", "content": "Actually, only include records where the manager is currently active."}, {"role": "assistant", "content": "SELECT a.agent_id,\n a.first_name,\n a.last_name,\n a.manager_id,\n m.contact_email AS manager_contact_email\nFROM insurance.agents a\nLEFT JOIN insurance.agents m\n ON a.manager_id = m.agent_id\nWHERE m.status = 'active';"}]}