system stringlengths 315 8.06k | conversations listlengths 2 48 |
|---|---|
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
| [
{
"role": "user",
"content": "List the first and last names of citizens along with the reference numbers of the applications they have submitted.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.first_name , T1.last_name , T2.reference_number FROM government_services.citizens ... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
CREATE 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 )
CREATE 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 )
CREATE 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 )
| [
{
"role": "user",
"content": "Show me the first name, last name, and email address for all passengers who are part of the loyalty program with ID 'Gold'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT first_name , last_name , email FROM transportation.passengers WHERE loyalty_p... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
Index 'suppliers'. Mapping: { properties: { supplier_id: { type: 'keyword' }, supplier_name: { type: 'text', fields: { keyword: { type: 'keyword', ignore_above: 256 } } }, address: { type: 'text' }, country: { type: 'keyword' }, contact_person: { type: 'text', index: false }, contact_email: { type: 'keyword' }, quality_rating: { type: 'float' }, certified_date: { type: 'date' } } }. Document _id can be supplier_id.
| [
{
"role": "user",
"content": "특정 품질 등급 이상의 공급업체를 조회하고 싶습니다. 품질 등급, 공급업체 이름, 국가를 포함해 주세요.",
"sql": null
},
{
"role": "assistant",
"content": "GET suppliers/_search\n{\n \"query\": {\n \"range\": {\n \"quality_rating\": {\n \"gte\": 4.0\n }\n }\n },\n \"_source\": [\"... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "For each prescription, find the next prescription for the same patient. Return current prescription_id, next_prescription_id, patient_id, and days between start dates.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p1.patient_id,\n p1.prescript... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "List all food and beverage services (category = 'Food & Beverage') with their names, prices, and units, where the price is less than $20.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT service_name, price, unit FROM hospitality_technology.services WH... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "List all payments processed in USD, showing payment_id, guest_id, amount, and payment_timestamp.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT payment_id,\n guest_id,\n amount,\n payment_timestamp\nFROM hospitality_technology.payme... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.token_transfers (
transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer
token_id character varying(64) NOT NULL, -- identifier of the token being transferred
from_address character varying(128) NOT NULL, -- address of the sender
to_address character varying(128) NOT NULL, -- address of the receiver
value numeric(38,14) NOT NULL, -- amount of tokens transferred
transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer
log_index integer NOT NULL, -- index of the transfer log in the transaction
PRIMARY KEY (transfer_id)
)
| [
{
"role": "user",
"content": "Find cases where an address received tokens in one transfer and then sent tokens in another. List the receive transfer_id, the send transfer_id, the address, and both transfer values.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT recv.transfer_id AS... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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) )
| [
{
"role": "user",
"content": "Show the document ID, claim ID, and file name for all documents with a MIME type starting with 'image/'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT document_id, claim_id, file_name FROM insurance.claim_documents WHERE mime_type LIKE 'image/%';",
... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "Give me all trips where the trip status is 'Completed' with their trip ID, vehicle ID, and number of passengers.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT trip_id, vehicle_id, passenger_count FROM transportation.trips WHERE status = 'Completed';... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE smart_money_token_inflow ( token_address character varying(100) NOT NULL, -- the token's address token_symbol character varying(100), -- the tokens's symbol token_amount numeric(38,2), -- the absolute value of the amount if user bought minus the amount user sold of this token usd_value numeric(38,2), -- the absolute usd value of the bought token minus sold token avg_price numeric(38,6), -- the average cost price of user spent on this token type int, -- the direction of the trade on this token. 1 means buying, 2 means selling address_amount integer, -- the amount of the user bought this token narrative character varying(100), -- the category or narrative of the token chain character varying(100), -- the chain that the token resides ,PRIMARY KEY (token_address, chain) )
| [
{
"role": "user",
"content": "For each chain, show the total token_amount and usd_value for selling transactions (type=2).",
"sql": null
},
{
"role": "assistant",
"content": "SELECT chain, SUM(token_amount) AS total_sold_amount, SUM(usd_value) AS total_sold_usd_value\nFROM smart_money_token_... |
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.
##Table Structure
CREATE TABLE train_station_management.trains ( train_id character varying(64) NOT NULL, train_number character varying(32) NOT NULL, model character varying(128), manufacturer character varying(128), year_manufactured integer, capacity integer NOT NULL, status character varying(32) NOT NULL DEFAULT 'Active', last_maintenance_date date, next_maintenance_date date, PRIMARY KEY (train_id), UNIQUE (train_number) )
| [
{
"role": "user",
"content": "What is the fuel consumption rate of train number T1234?",
"sql": null
},
{
"role": "assistant",
"content": "I'm sorry, but I don't have information on the fuel consumption rate of train number T1234. The data available in the system only includes details such a... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "Show all room types that offer 'WiFi' in their amenities.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT room_type_id, property_id, type_name, amenities FROM hospitality_technology.room_types WHERE amenities LIKE '%WiFi%';",
"sql": null
},
{
... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.fuel_logs (
fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry
vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled
trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred
log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred
fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type)
quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh)
unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh)
cost_per_unit numeric(8, 4), -- price per unit of fuel
total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase
odometer_reading integer, -- vehicle mileage at time of fueling
location_id character varying(64), -- identifier of the fueling station/location
PRIMARY KEY (fuel_log_id)
)
| [
{
"role": "user",
"content": "For each trip, provide the trip_id, the total fuel quantity refueled, and the number of refueling events that occurred during the trip.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT trip_id, SUM(quantity) AS total_fuel_quantity, COUNT(*) AS refuel_e... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.tokens (
token_id character varying(64) NOT NULL, -- unique identifier for the token
contract_address character varying(128) NOT NULL, -- address of the token contract
token_name character varying(128) NOT NULL, -- name of the token
token_symbol character varying(32) NOT NULL, -- symbol of the token
decimals integer NOT NULL, -- number of decimals for the token
total_supply numeric(38,14) NOT NULL, -- total supply of the token
PRIMARY KEY (token_id)
)
| [
{
"role": "user",
"content": "Count how many tokens exist for each contract_address.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT contract_address,\n COUNT(*) AS token_count\nFROM web3.tokens\nGROUP BY contract_address;",
"sql": null
},
{
"role": "user",
"... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patient_insurance (
patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link
patient_id character varying(64) NOT NULL, -- FK to patients table
plan_id character varying(64) NOT NULL, -- FK to insurance_plans table
policy_number character varying(100) NOT NULL, -- patient's policy number
group_number character varying(100), -- group number, if applicable
subscriber_name character varying(200), -- name of the primary policy holder
effective_date date NOT NULL, -- date the coverage begins
expiration_date date, -- date the coverage ends (if known)
is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance
PRIMARY KEY (patient_insurance_id),
UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice
)
| [
{
"role": "user",
"content": "List all insurance plans that will expire within the next 30 days, showing the patient IDs and subscriber names.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT patient_id, subscriber_name, policy_number, expiration_date\nFROM healthcare.patient_insur... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "List accounts that were opened in the same month and year as another account for the same customer, but have a different account type. Show the account_id, customer_id, account_type, and opened_date for these accounts.",
"sql": null
},
{
"role": "assistant",
"co... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "How many reservations have been booked each month in 2023?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT DATE_TRUNC('month', created_at) AS month,\n COUNT(*) AS reservation_count\nFROM hospitality_technology.reservations\nWHERE created_at >= '... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
"CREATE TABLE cex_token_balance (",
"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp",
"chain character varying(128) NOT NULL, -- the chain that the token resides",
"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX",
"exchange character varying(512) NOT NULL, -- a centralized exchange name",
"token_address character varying(128) NOT NULL, -- token contract address",
"token_symbol character varying(512), --token symbol",
"balance numeric(38,10), -- token balance",
"usd_value numeric(38,14), -- value of the token held in USD",
"price double precision, --price of the token in USD",
",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));"
| [
{
"role": "user",
"content": "Which token symbol has the highest price among all tokens held by CEXes on the Polygon chain?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT token_symbol, MAX(price) AS max_price FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol OR... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp )
CREATE 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 )
| [
{
"role": "user",
"content": "List the order ID, type, and quantity for all orders placed using the wallet with ID 'wallet123'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT order_id, order_type, quantity FROM orders WHERE wallet_id = 'wallet123'",
"sql": null
},
{
"... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
| [
{
"role": "user",
"content": "List all locations situated within the state of California.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT location_id, name, city, state_province FROM transportation.locations WHERE state_province = 'CA';",
"sql": null
},
{
"role": "user... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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) )
| [
{
"role": "user",
"content": "Find pairs of players from the same country who have different last login dates. Show their usernames, country code, and last login dates. Exclude pairs where either last login date is null.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p1.username ... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medical_records (
record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry
patient_id character varying(64) NOT NULL, -- FK to patients table
appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)
doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)
record_date timestamp with time zone NOT NULL, -- date the record/observation was made
chief_complaint text, -- patient's primary reason for visit
present_illness_history text, -- detailed history of the current issue
past_medical_history text, -- relevant past conditions/surgeries
physical_examination_notes text, -- findings from the physical exam
assessment text, -- doctor's assessment/diagnosis summary
treatment_plan text, -- planned course of action
vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (record_id)
)
| [
{
"role": "user",
"content": "List each patient's first and last medical record entries, showing patient_id, earliest_record_id, earliest_record_date, latest_record_id, and latest_record_date.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT\n fl.patient_id,\n fr.record_id AS... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
// Use Hashes for ticket details. Key format: ticket:<ticket_id>
// HSET ticket:tkt_1a2b ticket_id "tkt_1a2b" booking_id "book_zyx" car_id "car_abc" seat_number "12A" ... is_checked_in 0 ...
// To link tickets to bookings (optional):
// SADD booking:book_zyx:tickets ticket:tkt_1a2b
// Use Hashes for maintenance record details. Key format: maintenance_record:<record_id>
// HSET maintenance_record:maint_rec_001 record_id "maint_rec_001" asset_id "train_789" asset_type "Train" ... status "Completed"
// To link records to assets (optional):
// SADD train:train_789:maintenance maintenance_record:maint_rec_001
// SADD platform:plat_123:maintenance maintenance_record:maint_rec_002
| [
{
"role": "user",
"content": "特定の予約ID 'book_zyx' に関連するすべてのチケットの詳細を取得するのを手伝っていただけますか?また、関連する車両情報も含めてください。",
"sql": null
},
{
"role": "assistant",
"content": "SMEMBERS booking:book_zyx:tickets\nHGETALL ticket:<ticket_id>\nHGETALL car:<car_id>",
"sql": null
},
{
"role": "user",
... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.diagnoses (
diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry
record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry
patient_id character varying(64) NOT NULL, -- FK to patients table
doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)
diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)
code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used
description text, -- textual description of the diagnosis
diagnosis_date date NOT NULL, -- date the diagnosis was made
status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out
is_chronic boolean DEFAULT false, -- flag for chronic conditions
PRIMARY KEY (diagnosis_id)
)
| [
{
"role": "user",
"content": "I need to find all pairs of diagnoses for the same patient where one diagnosis is chronic and the other is non-chronic. Show patient_id, chronic diagnosis_id as chronic_id, non-chronic diagnosis_id as acute_id, chronic diagnosis_date, and acute diagnosis_date.",
"sql": null... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE 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 )
CREATE 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 )
CREATE 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) )
CREATE 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 )
CREATE 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) )
CREATE 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) )
CREATE TABLE healthcare.patient_insurance (
patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link
patient_id character varying(64) NOT NULL, -- FK to patients table
plan_id character varying(64) NOT NULL, -- FK to insurance_plans table
policy_number character varying(100) NOT NULL, -- patient's policy number
group_number character varying(100), -- group number, if applicable
subscriber_name character varying(200), -- name of the primary policy holder
effective_date date NOT NULL, -- date the coverage begins
expiration_date date, -- date the coverage ends (if known)
is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance
PRIMARY KEY (patient_insurance_id),
UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice
)
| [
{
"role": "user",
"content": "Show me all male patients who have received more than one prescription, including their full name, date of birth, and the total number of prescriptions.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p.patient_id, p.first_name, p.last_name, p.date_of... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
Index 'component_inventory'. Mapping: { properties: { inventory_record_id: { type: 'keyword' }, component_id: { type: 'keyword' }, quantity: { type: 'integer' }, location_warehouse: { type: 'keyword' }, location_bin: { type: 'keyword' }, received_date: { type: 'date' }, expiry_date: { type: 'date' }, batch_number: { type: 'keyword' }, last_updated: { type: 'date' } } }. Document _id can be inventory_record_id.
| [
{
"role": "user",
"content": "特定の倉庫にあるコンポーネントの在庫情報を取得したいです。倉庫の場所、ビンの位置、在庫数量、コンポーネントIDを表示してください。",
"sql": null
},
{
"role": "assistant",
"content": "SELECT location_warehouse, location_bin, quantity, component_id FROM component_inventory WHERE location_warehouse = 'specific_warehouse';",
... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.vehicles (
vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle
license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate
vin character varying(17) UNIQUE, -- vehicle identification number
make character varying(64) NOT NULL, -- manufacturer of the vehicle
model character varying(64) NOT NULL, -- model of the vehicle
year integer NOT NULL, -- manufacturing year
type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)
capacity integer, -- passenger or cargo capacity
fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen
status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned
depot_id character varying(64), -- identifier of the home depot/base
acquisition_date date, -- date the vehicle was acquired
PRIMARY KEY (vehicle_id)
)
CREATE TABLE transportation.drivers ( driver_id character varying(64) NOT NULL, employee_id character varying(64) NOT NULL UNIQUE, first_name character varying(128) NOT NULL, last_name character varying(128) NOT NULL, license_number character varying(64) NOT NULL UNIQUE, license_expiry_date date NOT NULL, contact_number character varying(32), email character varying(128) UNIQUE, hire_date date NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (driver_id) )
CREATE 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 )
CREATE 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 )
CREATE 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) )
| [
{
"role": "user",
"content": "I need a list of all routes and the number of trips made on each route.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT route_id, COUNT(*) AS trip_count\nFROM transportation.trips\nGROUP BY route_id;",
"sql": null
},
{
"role": "user",
... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government_services.citizens (
citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen
national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number
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, -- full primary residential address
contact_email character varying(128) UNIQUE,
contact_phone character varying(32),
registration_date timestamp NOT NULL, -- when the citizen profile was created
is_verified boolean DEFAULT false, -- whether identity has been officially verified
PRIMARY KEY (citizen_id)
)
CREATE 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 )
CREATE 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) )
CREATE 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 )
CREATE TABLE government_services.payments ( payment_id text, 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 )
CREATE 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) )
CREATE TABLE government_services.service_locations (
location_id character varying(64) NOT NULL, -- unique identifier for the physical location
agency_id character varying(64) NOT NULL, -- FK to agencies table
location_name character varying(200), -- e.g., Downtown DMV Office
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, -- description of opening times
contact_phone character varying(32),
is_accessible boolean, -- accessibility information (e.g., wheelchair access)
PRIMARY KEY (location_id)
)
CREATE 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) )
| [
{
"role": "user",
"content": "Which citizens have made the highest total payments in USD? Show their full name and total payment amount, ordered by total in descending order, limited to the top 3.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.first_name || ' ' || c.last_name A... |
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 6