system stringlengths 315 8.06k | conversations listlengths 6 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 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 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) )
| [
{
"role": "user",
"content": "I want to know the total number of appointments per location along with the location name for appointments scheduled in March 2024.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT\n sl.location_name,\n COUNT(a.appointment_id) AS appointment_count\nF... |
You are an expert in writing database language. You 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.assets ( asset_id character varying(64) NOT NULL, name character varying(128) NOT NULL, symbol character varying(32) NOT NULL, type character varying(32) NOT NULL, PRIMARY KEY (asset_id) )
CREATE TABLE trading_platform.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean )
| [
{
"role": "user",
"content": "Find transaction IDs in the utxos table that have both spent and unspent UTXOs associated with them. List these transaction IDs.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT transaction_id FROM trading_platform.utxos GROUP BY transaction_id HAVING ... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "Find all pairs of appointments that are scheduled for the same case and overlap in time. Show the IDs of the two overlapping appointments and the shared case ID.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT t1.appointment_id AS appointment1_id, t2.... |
You are an expert in writing database language. You 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 character varying(64) NOT NULL, route_id character varying(64), vehicle_id character varying(64) NOT NULL, driver_id character varying(64) NOT NULL, scheduled_departure timestamp with time zone NOT NULL, actual_departure timestamp with time zone, scheduled_arrival timestamp with time zone NOT NULL, actual_arrival timestamp with time zone, origin_location_id character varying(64) NOT NULL, destination_location_id character varying(64) NOT NULL, status character varying(32) NOT NULL, passenger_count integer, cargo_manifest_id character varying(64), PRIMARY KEY (trip_id) )
| [
{
"role": "user",
"content": "Show me pairs of trip IDs that used the same vehicle.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT\n t1.trip_id AS trip1_id,\n t2.trip_id AS trip2_id\nFROM transportation.trips AS t1\nJOIN transportation.trips AS t2\n ON t1.vehicle_id = t2.vehic... |
You are an expert in writing database language. You 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, 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) )
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.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) )
| [
{
"role": "user",
"content": "Show each patient's policy number, the associated insurance plan ID, and any medications they have been prescribed, including the medication ID and prescription date.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT pi.patient_id, pi.policy_number, pi.... |
You are an expert in writing database language. You 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 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 )
CREATE 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 )
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.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 )
CREATE TABLE transportation.maintenance_logs (
log_id character varying(64) NOT NULL, -- unique identifier for the maintenance record
vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle serviced
service_date date NOT NULL, -- date the service was performed
odometer_reading integer, -- vehicle mileage at time of service
service_type character varying(128) NOT NULL, -- type of service (e.g., Oil Change, Tire Rotation, Engine Repair)
description text NOT NULL, -- detailed description of work done
cost numeric(10, 2), -- cost of the service
mechanic_name character varying(128), -- name or ID of the mechanic/shop
next_service_due_date date, -- recommended date for next service
PRIMARY KEY (log_id)
)
CREATE TABLE transportation.passengers (
passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger
first_name character varying(128) NOT NULL, -- passenger's first name
last_name character varying(128) NOT NULL, -- passenger's last name
email character varying(128) UNIQUE, -- email address
phone_number character varying(32) UNIQUE, -- phone number
date_of_birth date, -- passenger's date of birth
loyalty_program_id character varying(64), -- identifier for loyalty program membership
created_at timestamp with time zone NOT NULL, -- time when the passenger record was created
PRIMARY KEY (passenger_id)
)
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": "For each maintenance log, list the vehicle's license plate, the name of the mechanic, and the service date, ordered by most recent service first.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT ml.log_id, v.license_plate, ml.mechanic_name, ml.service_... |
You are an expert in writing database language. You 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 text PRIMARY KEY, token_id text, from_address text, to_address text, value numeric, transaction_id text, log_index int )
| [
{
"role": "user",
"content": "Provide the count of transfers for each token_id.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT token_id,\n COUNT(*) AS transfer_count\nFROM web3.token_transfers\nGROUP BY token_id;",
"sql": null
},
{
"role": "user",
"content":... |
You are an expert in writing database language. You 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 social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )
| [
{
"role": "user",
"content": "I need to find users who have liked both a post and a comment on the same day. For each such user and date, list user_id, date, post_id, and comment_id.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p.user_id, DATE(p.created_at) AS like_date, p.post... |
You are an expert in writing database language. You 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 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, -- unique identifier for the service
agency_id character varying(64) NOT NULL, -- FK to agencies table
service_name character varying(255) NOT NULL, -- name of the service (e.g., Driver's License Renewal)
description text,
category character varying(100), -- e.g., Licensing, Benefits, Taxation, Permits
eligibility_criteria text, -- description of who is eligible
standard_fee numeric(10, 2) DEFAULT 0.00, -- typical fee for the service
average_processing_time_days integer, -- estimated processing time
is_active boolean DEFAULT true, -- whether the service is currently offered
online_application_url character varying(255),
PRIMARY KEY (service_id)
)
CREATE TABLE government_services.applications (
application_id character varying(64) NOT NULL, -- unique identifier for the application
citizen_id character varying(64) NOT NULL, -- FK to citizens table
service_id character varying(64) NOT NULL, -- FK to services table
submitted_at timestamp NOT NULL, -- time the application was submitted
status character varying(50) NOT NULL, -- e.g., Submitted, Processing, Approved, Rejected, Pending Info
last_updated_at timestamp NOT NULL, -- time the status or details last changed
assigned_employee_id character varying(64), -- FK to employees table (optional)
decision_date date, -- date when a final decision was made
notes text, -- internal notes or citizen-provided comments
reference_number character varying(100) UNIQUE, -- publicly visible reference number
PRIMARY KEY (application_id)
)
CREATE 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 )
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, -- unique identifier for the government employee
agency_id character varying(64) NOT NULL, -- FK to agencies table
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, -- null if currently employed
access_level character varying(50), -- Role or permission level
manager_employee_id character varying(64), -- FK to self for reporting structure
PRIMARY KEY (employee_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) )
| [
{
"role": "user",
"content": "List the first name and last name of employees who were hired in the year 2023, along with the name of the agency they work for.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT e.first_name, e.last_name, a.agency_name FROM government_services.employee... |
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 manufacturing.aircraft_models ( model_id text PRIMARY KEY, model_name text, manufacturer text, passenger_capacity int, max_range_km int, engine_type text, wingspan_m numeric, status text, first_flight_date date )
| [
{
"role": "user",
"content": "What are the environmental impact assessments for the production of the Airbus A350 model?",
"sql": null
},
{
"role": "assistant",
"content": "I'm sorry, but I don't have access to data regarding the environmental impact assessments for the production of specifi... |
You are an expert in writing database language. You 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.in_game_items ( item_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, item_name character varying(150) NOT NULL, item_type character varying(50) NOT NULL, description text, rarity character varying(30), cost_currency character varying(10), cost_amount numeric(12, 2), attributes jsonb, PRIMARY KEY (item_id) )
| [
{
"role": "user",
"content": "I need to list all pairs of in-game items in the same game where one item is Epic and the other is Legendary, showing game_id, epic_item, and legendary_item.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT a.game_id,\n a.item_name AS epic_item,\... |
You are an expert in writing database language. You 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 )
| [
{
"role": "user",
"content": "Show me all pairs of patients who share the same emergency contact phone, including both patient IDs, their names, and the shared emergency contact phone.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p1.patient_id,\n p1.first_name,\n p1... |
You are an expert in writing database language. You 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 platform details. Key format: platform:<platform_id>
// 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
// To link platforms to stations (optional):
// SADD station:station_xyz:platforms platform:plat_123 platform:plat_456
// Use Hashes for train details. Key format: train:<train_id>
// HSET train:train_789 train_id "train_789" train_number "Acela 2151" model "Siemens Velaro" ... status "Active" ...
// To find train by train_number (optional index):
// SET train_number:"Acela 2151" train:train_789
// Use Hashes for car details. Key format: car:<car_id>
// 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"
// To link cars to trains (optional):
// SADD train:train_789:cars car:car_abc car:car_def
// Use Hashes for details. Key format: route_station:<route_station_id>
// HSET route_station:rs_ne_1 route_station_id "rs_ne_1" route_id "route_ne_corr" station_id "station_bos" sequence_order 1 ...
// To find stops for a route, use a Sorted Set (score by sequence_order):
// ZADD route:route_ne_corr:stops 1 route_station:rs_ne_1
// ZADD route:route_ne_corr:stops 2 route_station:rs_ne_2
// Use Hashes for schedule details. Key format: schedule:<schedule_id>
// HSET schedule:sched_1122 schedule_id "sched_1122" train_id "train_789" route_id "route_ne_corr" departure_datetime "2024-05-10T08:00:00-04:00" ... status "Scheduled"
// Use Hashes for details. Key format: schedule_stop:<stop_id>
// HSET schedule_stop:stop_sched1122_1 stop_id "stop_sched1122_1" schedule_id "sched_1122" station_id "station_bos" ...
// To find stops for a schedule, use a Sorted Set (score by sequence_order):
// ZADD schedule:sched_1122:stops 1 schedule_stop:stop_sched1122_1
// ZADD schedule:sched_1122:stops 2 schedule_stop:stop_sched1122_2
// Use Hashes for passenger details. Key format: passenger:<passenger_id>
// HSET passenger:pass_pqr passenger_id "pass_pqr" first_name "Alice" last_name "Smith" email "alice.smith@example.com" ...
// To find passenger by email (optional index):
// SET passenger_email:"alice.smith@example.com" passenger:pass_pqr
// Use Hashes for booking details. Key format: booking:<booking_id>
// HSET booking:book_zyx booking_id "book_zyx" passenger_id "pass_pqr" schedule_id "sched_1122" ... status "Confirmed" ...
// To link bookings to passengers/schedules (optional):
// SADD passenger:pass_pqr:bookings booking:book_zyx
// SADD schedule:sched_1122:bookings booking:book_zyx
// 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 staff details. Key format: staff:<staff_id>
// HSET staff:staff_mno staff_id "staff_mno" first_name "Bob" ... employee_number "E12345" ... is_active 1
// To find staff by employee number (optional index):
// SET staff_employee_number:"E12345" staff:staff_mno
// 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": "Can you help me retrieve the details of all schedules for a specific train with train_id 'train_789', including the route and stops information?",
"sql": null
},
{
"role": "assistant",
"content": "HGETALL train:train_789\nSMEMBERS schedule:sched_*:train:train_78... |
You are an expert in writing database language. You 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 insurance.premium_payments ( payment_id text PRIMARY KEY, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )
| [
{
"role": "user",
"content": "Which customers have made more than three premium payments in 2024? Show the customer_id and the number of payments.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT customer_id, COUNT(*) AS payment_count FROM insurance.premium_payments WHERE payment_d... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "List all pairs of beneficiaries on the same policy, showing policy_id, beneficiary1_id, beneficiary1 first_name, beneficiary1 last_name, beneficiary2_id, beneficiary2 first_name, and beneficiary2 last_name.",
"sql": null
},
{
"role": "assistant",
"content": "SEL... |
You are an expert in writing database language. You 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 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 )
CREATE 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) )
CREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )
CREATE TABLE social_media.notifications ( notification_id text PRIMARY KEY, 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 )
| [
{
"role": "user",
"content": "Find users who have both commented on a post and liked that same post. Return the user_id and the count of such posts as post_count.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.user_id, COUNT(DISTINCT c.post_id) AS post_count\nFROM social_media.... |
You are an expert in writing database language. You 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.player_inventory ( inventory_id uuid PRIMARY KEY, player_id uuid, item_id uuid, quantity int, acquired_at timestamptz, instance_data jsonb )
| [
{
"role": "user",
"content": "For each player, calculate the total quantity of items they have acquired. Return player_id and total_quantity.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT player_id,\n SUM(quantity) AS total_quantity\nFROM gaming_technology.player_inventory... |
You are an expert in writing database language. You 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 social_media.messages (
message_id character varying(64) NOT NULL, -- unique identifier for the message
conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)
sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)
content text, -- textual content of the message
media_url text, -- URL to attached media (image/video)
media_type character varying(20), -- type of media ('image', 'video', null)
sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent
read_at timestamp, -- timestamp when message was read by recipient(s)
PRIMARY KEY (message_id)
)
| [
{
"role": "user",
"content": "How many messages currently have a media file attached?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT COUNT(*) FROM social_media.messages WHERE media_url IS NOT NULL;",
"sql": null
},
{
"role": "user",
"content": "For each user, show... |
You are an expert in writing database language. You 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 legal_services.clients (
client_id character varying(64) NOT NULL, -- unique identifier for the client
first_name character varying(100) NOT NULL, -- client's first name
last_name character varying(100) NOT NULL, -- client's last name
company_name character varying(200), -- company name if applicable
email character varying(128) UNIQUE NOT NULL, -- client's primary email
phone character varying(32), -- client's contact phone number
address text, -- client's full address
date_registered timestamp NOT NULL, -- when the client was first registered
status character varying(32) NOT NULL, -- client status (e.g., active, inactive, prospect)
PRIMARY KEY (client_id)
)
CREATE TABLE legal_services.time_entries (
entry_id character varying(64) NOT NULL, -- unique identifier for the time entry
case_id character varying(64) NOT NULL, -- FK to cases table
lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)
date_worked date NOT NULL, -- date the work was performed
hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)
billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry
description text NOT NULL, -- detailed description of the work performed
is_billable boolean DEFAULT true, -- whether this time entry is billable to the client
is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice
invoice_id character varying(64), -- FK to invoices table (once billed)
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded
PRIMARY KEY (entry_id)
)
CREATE TABLE legal_services.appointments (
appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment
client_id character varying(64) NOT NULL, -- FK to clients table
lawyer_id character varying(64) NOT NULL, -- FK to lawyers table
case_id character varying(64), -- FK to cases table (optional, if related to a specific case)
start_time timestamp NOT NULL, -- scheduled start date and time
end_time timestamp NOT NULL, -- scheduled end date and time
location text, -- location of the meeting (address or virtual link)
subject character varying(255), -- subject or purpose of the appointment
notes text, -- additional notes for the appointment
status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (appointment_id)
)
| [
{
"role": "user",
"content": "Calculate the total sum of hours spent across all time entries that are billable but have not yet been billed.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT SUM(hours_spent) FROM legal_services.time_entries WHERE is_billable = TRUE AND is_billed = F... |
You are an expert in writing database language. You 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 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 )
CREATE 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 )
CREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )
CREATE 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 )
CREATE 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 )
CREATE 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 )
| [
{
"role": "user",
"content": "List all appointments along with their subject and start time for lawyers specializing in 'Criminal Law'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.subject, T1.start_time FROM legal_services.appointments AS T1 JOIN legal_services.lawyers AS T... |
You are an expert in writing database language. You 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.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) )
| [
{
"role": "user",
"content": "Provide for each security its ticker_symbol, the most recent close_price and corresponding timestamp.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT s.ticker_symbol, md.close_price, md.data_timestamp\nFROM financial_services.market_data md\nJOIN fina... |
You are an expert in writing database language. You 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 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) )
CREATE 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) )
CREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )
CREATE 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) )
CREATE 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) )
CREATE TABLE social_media.messages ( message_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, sender_user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (message_id) )
CREATE 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) )
CREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, recipient_user_id character varying(64) NOT NULL, sender_user_id character varying(64), notification_type character varying(30) NOT NULL, target_entity_id character varying(64), target_entity_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (notification_id) )
CREATE 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) )
| [
{
"role": "user",
"content": "List all users who commented on posts tagged with hashtag 'spring', showing user_id, comment_id, content, and tag_name.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.user_id, c.comment_id, c.content, h.tag_name\nFROM social_media.comments c\nJOIN ... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "List the latitude and longitude coordinates for all service locations located in a city named 'Seattle'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT latitude , longitude FROM government_services.service_locations WHERE city = 'Seattle'",
"sql... |
You are an expert in writing database language. You 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.maintenance_logs ( log_id character varying(64) NOT NULL, vehicle_id character varying(64) NOT NULL, service_date date NOT NULL, odometer_reading integer, service_type character varying(128) NOT NULL, description text NOT NULL, cost numeric(10, 2), mechanic_name character varying(128), next_service_due_date date, PRIMARY KEY (log_id) )
| [
{
"role": "user",
"content": "Find pairs of consecutive maintenance logs for the same vehicle based on service date. Show the vehicle ID, log IDs, service dates, and odometer readings for both logs in each pair.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT vehicle_id, log_id, s... |
You are an expert in writing database language. You 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 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
CREATE 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) )
| [
{
"role": "user",
"content": "Show me all cases opened in the year 2024, along with the full name of the client for each case.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.case_number, T1.case_name, T2.first_name, T2.last_name FROM cases AS T1 JOIN clients AS T2 ON T1.client... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "For each server, what is the earliest and latest start time of its sessions?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT server_id, MIN(start_time), MAX(start_time) FROM gaming_technology.game_sessions GROUP BY server_id;",
"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 financial_services.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 text NOT NULL, 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, email character varying(128) UNIQUE, phone_number character varying(32), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, status character varying(32) NOT NULL, risk_profile character varying(50), PRIMARY KEY (customer_id) )
CREATE 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) )
CREATE TABLE financial_services.securities ( security_id character varying(64) NOT NULL, ticker_symbol character varying(20) NOT NULL UNIQUE, isin_code character varying(12) UNIQUE, cusip_code character varying(9) UNIQUE, security_name text NOT NULL, security_type character varying(50) NOT NULL, exchange character varying(50), currency character varying(3) NOT NULL, issuer_name character varying(255), sector character varying(100), last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (security_id) )
CREATE 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) )
CREATE TABLE financial_services.employees ( employee_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(100) NOT NULL, department character varying(100), branch_id character varying(64), email character varying(128) NOT NULL UNIQUE, phone_extension character varying(20), hire_date date NOT NULL, termination_date date, manager_id character varying(64), status character varying(32) NOT NULL, PRIMARY KEY (employee_id), FOREIGN KEY (branch_id) REFERENCES financial_services.branches(branch_id), FOREIGN KEY (manager_id) REFERENCES financial_services.employees(employee_id) )
| [
{
"role": "user",
"content": "List all customers and the total amount they have traded, showing their full name, email, and the total across all their trades. Join customers to their accounts, then to trades.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.customer_id, c.first_n... |
You are an expert in writing database language. You 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.customers (
customer_id character varying(64) NOT NULL, -- unique identifier for the customer
first_name character varying(100) NOT NULL, -- customer's first name
last_name character varying(100) NOT NULL, -- customer's last name
date_of_birth date NOT NULL, -- customer's date of birth
ssn_hash character varying(128), -- Hashed social security number (or national ID)
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, -- unique email address
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the customer record was created
updated_at timestamp, -- when the customer record was last updated
status character varying(20) NOT NULL DEFAULT 'Active', -- e.g., Active, Inactive, Prospect
PRIMARY KEY (customer_id)
)
CREATE 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) )
CREATE 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) )
CREATE 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 )
CREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )
CREATE 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 )
| [
{
"role": "user",
"content": "List all premium payments along with the customer's first and last name for payments made after July 1, 2023.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT pp.payment_id, pp.payment_date, pp.amount_paid, cu.first_name, cu.last_name\nFROM insurance.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
CREATE 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 )
CREATE TABLE erc1155_approval_for_all (
block_number bigint NOT NULL, -- Block number containing the transaction
block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction
transaction_index integer NOT NULL, -- Index of the transaction within the block
transaction_hash varchar(66) NOT NULL, -- Transaction hash
log_index integer NOT NULL, -- Log index
contract_address varchar(42) NOT NULL -- Event contract address
)
CREATE TABLE erc20_balances ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk varchar )
CREATE TABLE nft_holders ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )
CREATE TABLE nft_holder_historical (
block_number bigint NOT NULL, -- Block number containing the transaction
contract_address varchar NOT NULL, -- Event contract address
wallet_address varchar NOT NULL, -- The wallet address for the contract(with bloom filter)
token_id varchar NOT NULL, -- NFT token id
contract_type varchar NOT NULL, -- NFT contract type
amount varchar NOT NULL, -- The quantity held in the wallet
pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))
)
CREATE 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 )
CREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )
CREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )
CREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )
CREATE TABLE token_balances (
block_number bigint NOT NULL, -- Block number containing the transaction
block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction
tick varchar NOT NULL, -- Token tick
wallet_address varchar(42) NOT NULL, -- Address of owner
total_supply decimal(38,0) NOT NULL, -- Max supply
amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height
)
CREATE 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 )
CREATE 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 )
CREATE TABLE token_balances_bitcoin (
block_number bigint NOT NULL, -- Block number containing the transaction
block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction
tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription
wallet_address varchar(42) NOT NULL, -- Address of owner
total_supply varchar NOT NULL, -- Max supply: Set max supply of the inscription
amount varchar NOT NULL -- The balance of wallet balance at the corresponding block height
)
CREATE 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 )
CREATE TABLE token_balances_avalanche (
block_number bigint NOT NULL, -- Block number containing the transaction
block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction
tick varchar(20) NOT NULL, -- Ticker: Identifier of the inscription
wallet_address varchar(42) NOT NULL, -- Address of owner
total_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription
amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height
)
| [
{
"role": "user",
"content": "Show me all Sui coins with at least 6 decimal places and status 'exists' from the metadata table. List coin_type, symbol, name, and decimals.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT coin_type, symbol, name, decimals\nFROM sui_coins_metadata\nW... |
You are an expert in writing database language. You 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.employees (
employee_id character varying(64) NOT NULL, -- unique identifier for the employee
first_name character varying(100) NOT NULL,
last_name character varying(100) NOT NULL,
job_title character varying(100) NOT NULL, -- e.g., Teller, Branch Manager, Financial Advisor, Analyst
department character varying(100), -- e.g., Retail Banking, Wealth Management, IT
branch_id character varying(64), -- Identifier for the branch they work at (if applicable)
email character varying(128) NOT NULL UNIQUE,
phone_extension character varying(20),
hire_date date NOT NULL,
termination_date date, -- Date of termination, null if currently employed
manager_id character varying(64), -- Self-referencing key for manager relationship
status character varying(32) NOT NULL, -- e.g., Active, Terminated, On Leave
PRIMARY KEY (employee_id),
FOREIGN KEY (branch_id) REFERENCES financial_services.branches(branch_id), -- Assuming a branches table exists
FOREIGN KEY (manager_id) REFERENCES financial_services.employees(employee_id)
)
| [
{
"role": "user",
"content": "List employees whose job title is different from their manager's job title, showing the employee's full name and their manager's full name.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT e.first_name, e.last_name, m.first_name AS manager_first_name, ... |
You are an expert in writing database language. You 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 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) )
| [
{
"role": "user",
"content": "How many patients have provided both a phone_number and emergency_contact_phone?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT COUNT(*) FROM healthcare.patients WHERE phone_number IS NOT NULL AND emergency_contact_phone IS NOT NULL;",
"sql": nul... |
You are an expert in writing database language. You 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.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 )
CREATE TABLE insurance.policies ( policy_id text PRIMARY KEY, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )
CREATE 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 )
CREATE 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 )
CREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )
CREATE 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 )
CREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text PRIMARY KEY, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )
| [
{
"role": "user",
"content": "Find the average settlement_amount of closed claims for each claim handler. Return claim_handler_id and avg_settlement_amount.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.claim_handler_id, AVG(c.settlement_amount) AS avg_settlement_amount\nFROM ... |
You are an expert in writing database language. You 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 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 )
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 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 )
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 )
| [
{
"role": "user",
"content": "Find all patients who have never received any diagnoses. Show patient ID, first_name, and last_name.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p.patient_id,\n p.first_name,\n p.last_name\nFROM healthcare.patients p\nLEFT JOIN healthc... |
You are an expert in writing database language. You 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.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) )
| [
{
"role": "user",
"content": "Count the number of events for each hour of the day based on the emitted_at timestamp.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT EXTRACT(HOUR FROM emitted_at) AS event_hour, COUNT(*) AS event_count FROM web3.events GROUP BY event_hour ORDER BY 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 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 )
| [
{
"role": "user",
"content": "Show me reviews from 'Expedia' that have an overall rating of 1 or 2.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT review_id, property_id, guest_id, rating_overall, review_date, comment FROM hospitality_technology.reviews WHERE review_source = 'Exp... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "List all posts where the content mentions 'meeting'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT post_id, user_id, content, created_at FROM social_media.posts WHERE content LIKE '%meeting%'",
"sql": null
},
{
"role": "user",
"conte... |
You are an expert in writing database language. You 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.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )
CREATE TABLE trading_platform.wallets ( wallet_id text PRIMARY KEY, user_id text, address text, private_key text, created_at timestamp )
CREATE TABLE trading_platform.trades ( trade_id text PRIMARY KEY, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp )
CREATE TABLE trading_platform.assets ( asset_id text PRIMARY KEY, name text, symbol text, type text )
CREATE TABLE trading_platform.utxos ( utxo_id text PRIMARY KEY, transaction_id text, output_index int, address text, amount numeric, spent boolean )
CREATE TABLE trading_platform.dapps ( dapp_id text PRIMARY KEY, name text, description text, url text )
CREATE TABLE trading_platform.peers ( peer_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )
CREATE TABLE trading_platform.metadata ( metadata_id text PRIMARY KEY, asset_id text, key text, value text )
CREATE TABLE trading_platform.kyc_audit ( kyc_audit_id text PRIMARY KEY, user_id text, status text, reviewed_at timestamp )
CREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )
CREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )
| [
{
"role": "user",
"content": "List all users who currently have a 'pending' KYC status, showing their user ID and username.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT u.user_id, u.username FROM users u JOIN kyc_audit k ON u.user_id = k.user_id WHERE k.status = 'pending';",
... |
You are an expert in writing database language. You 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.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) )
| [
{
"role": "user",
"content": "List all policies that have a coverage limit greater than 750000 and a premium amount greater than 1000. Show the policy number, product ID, coverage limit, and premium amount.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT\n policy_number,\n produ... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "Can you show me all user IDs that have both email and push notifications disabled, along with whether their profile is set to private?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT user_id, private_profile FROM social_media.user_settings WHERE email... |
You are an expert in writing database language. You 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 blockchain.wallets ( wallet_id.text, user_id.text, address_id.text, private_key.text )
| [
{
"role": "user",
"content": "Show me all wallet addresses that belong to user_id 'U12345'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT address_id FROM blockchain.wallets WHERE user_id = 'U12345';",
"sql": null
},
{
"role": "user",
"content": "Now join this wit... |
You are an expert in writing database language. You 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 character varying(64) NOT NULL, name character varying(255) NOT NULL, type character varying(64) NOT NULL, address_line1 character varying(255), city character varying(128), state_province character varying(128), postal_code character varying(32), country character varying(64) NOT NULL, latitude numeric(9, 6), longitude numeric(9, 6), timezone character varying(64), PRIMARY KEY (location_id) )
| [
{
"role": "user",
"content": "Get all pairs of locations in the same city, showing both location IDs, names, and the shared city.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT l1.location_id AS location1_id, l1.name AS location1_name,\n l2.location_id AS location2_id, l2.n... |
You are an expert in writing database language. You 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 PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb )
CREATE TABLE gaming_technology.games ( game_id uuid NOT NULL DEFAULT gen_random_uuid(), title character varying(200) NOT NULL, developer_id uuid NOT NULL, publisher_id uuid, genre character varying(100), release_date date, description text, platform character varying(50) NOT NULL, engine character varying(100), website character varying(255), PRIMARY KEY (game_id) )
CREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )
CREATE 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 )
CREATE 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 )
CREATE 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) )
CREATE TABLE gaming_technology.in_game_items ( item_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, item_name character varying(150) NOT NULL, item_type character varying(50) NOT NULL, description text, rarity character varying(30), cost_currency character varying(10), cost_amount numeric(12, 2), attributes jsonb, PRIMARY KEY (item_id) )
CREATE 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) )
| [
{
"role": "user",
"content": "Show me a list of players and, for each, list all the different games where they have acquired items. Also include the number of unique item types they've acquired per game.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p.player_id, p.username, g.ti... |
You are an expert in writing database language. You 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 legal_services.time_entries (
entry_id character varying(64) NOT NULL, -- unique identifier for the time entry
case_id character varying(64) NOT NULL, -- FK to cases table
lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)
date_worked date NOT NULL, -- date the work was performed
hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)
billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry
description text NOT NULL, -- detailed description of the work performed
is_billable boolean DEFAULT true, -- whether this time entry is billable to the client
is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice
invoice_id character varying(64), -- FK to invoices table (once billed)
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded
PRIMARY KEY (entry_id)
)
| [
{
"role": "user",
"content": "I want to see all time entries where the description contains the word 'draft' and that have not been billed yet.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT *\nFROM legal_services.time_entries\nWHERE description ILIKE '%draft%'\n AND is_billed =... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "Find pairs of citizens who have the same last name but different national_id_number.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c1.citizen_id AS citizen_id_1, c1.first_name AS first_name_1, c1.last_name AS last_name_1, c1.national_id_number AS na... |
You are an expert in writing database language. You 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.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) )
| [
{
"role": "user",
"content": "Show me how many achievements each player has unlocked.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT player_id,\n COUNT(*) AS total_unlocked\nFROM gaming_technology.player_achievements\nGROUP BY player_id;",
"sql": null
},
{
"role... |
You are an expert in writing database language. You 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
Node 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.
Node 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.
Node 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.
Node 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.
Node 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: <step_number>}]->(:AssemblyStep). Index on step_id.
Node 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.
Node 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.
| [
{
"role": "user",
"content": "我想获取某个组件的详细信息,包括组件名称、描述、重量以及成本。",
"sql": null
},
{
"role": "assistant",
"content": "MATCH (c:Component)\nWHERE c.component_id = 'specific_component_id'\nRETURN c.component_name, c.description, c.weight_kg, c.cost_usd",
"sql": null
},
{
"role": "user"... |
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.text, train_number.text, model.text, manufacturer.text, year_manufactured.integer, capacity.integer, status.text, last_maintenance_date.date, next_maintenance_date.date )
| [
{
"role": "user",
"content": "What is the average speed of train number T9876 during its last journey?",
"sql": null
},
{
"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 tab... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "Can you show me the total amount paid by each citizen for each service? Please display the citizen_id, service_id, and the total amount.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT citizen_id, service_id, SUM(amount) AS total_amount\nFROM governme... |
You are an expert in writing database language. You 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.agents ( agent_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, agency_name character varying(150), license_number character varying(100) NOT NULL UNIQUE, license_state character varying(50) NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(30), hire_date date, termination_date date, status character varying(20) NOT NULL DEFAULT 'Active', commission_rate numeric(5, 4) NOT NULL DEFAULT 0.05, manager_id character varying(64), PRIMARY KEY (agent_id) )
| [
{
"role": "user",
"content": "Show all active agents along with their respective managers' full names.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT a.agent_id, a.first_name || ' ' || a.last_name AS agent_name, m.first_name || ' ' || m.last_name AS manager_name FROM insurance.ag... |
You are an expert in writing database language. You 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.games (
game_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game
title character varying(200) NOT NULL, -- official title of the game
developer_id uuid NOT NULL, -- FK linking to the developers table
publisher_id uuid, -- FK linking to a potential publishers table (optional)
genre character varying(100), -- primary genre (e.g., RPG, FPS, Strategy)
release_date date, -- official release date
description text, -- short description or synopsis of the game
platform character varying(50) NOT NULL, -- primary platform (e.g., PC, PlayStation 5, Xbox Series X, Mobile)
engine character varying(100), -- game engine used (e.g., Unreal Engine 5, Unity)
website character varying(255), -- official website URL
PRIMARY KEY (game_id)
-- FOREIGN KEY (developer_id) REFERENCES gaming_technology.developers(developer_id) -- Example FK constraint
)
| [
{
"role": "user",
"content": "List each genre and the number of games in that genre.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT genre,\n COUNT(*) AS game_count\nFROM gaming_technology.games\nGROUP BY genre;",
"sql": null
},
{
"role": "user",
"content": "... |
You are an expert in writing database language. You 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.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text )
| [
{
"role": "user",
"content": "List the claim ID, incident date, estimated loss, and the first and last name of the customer for all claims with an estimated loss greater than 5000.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.claim_id, T1.incident_date, T1.estimated_loss, T2... |
You are an expert in writing database language. You 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 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 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 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 )
| [
{
"role": "user",
"content": "Show me the total fuel cost for each vehicle, grouped by fuel type.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT vehicle_id, fuel_type, SUM(total_cost) AS total_fuel_cost FROM transportation.fuel_logs GROUP BY vehicle_id, fuel_type;",
"sql": nu... |
You are an expert in writing database language. You 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... |
You are an expert in writing database language. You 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 character varying(64) NOT NULL, -- unique identifier for the account
customer_id character varying(64) NOT NULL, -- foreign key linking to the customer
account_number character varying(128) NOT NULL UNIQUE, -- unique account number visible to customer
account_type character varying(50) NOT NULL, -- e.g., Checking, Savings, Investment, Loan, Credit Card
balance numeric(19, 4) NOT NULL DEFAULT 0.00, -- current account balance
currency character varying(3) NOT NULL, -- currency code (e.g., USD, EUR)
opened_date date NOT NULL, -- date the account was opened
status character varying(32) NOT NULL, -- e.g., Open, Closed, Frozen
interest_rate numeric(5, 4), -- annual interest rate, if applicable
last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last account update
PRIMARY KEY (account_id),
FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id)
)
CREATE 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 )
CREATE 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) )
CREATE 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 )
| [
{
"role": "user",
"content": "Show me a summary listing each customer's full name and the number of accounts they have, broken down by account status.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT\n c.first_name,\n c.last_name,\n a.status,\n COUNT(a.account_id) AS account_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 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 )
| [
{
"role": "user",
"content": "Count the total number of distinct specialties listed in the doctors table.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT count(DISTINCT specialty) FROM healthcare.doctors;",
"sql": null
},
{
"role": "user",
"content": "Show the lice... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "List the diagnosis_id, patient_id, and doctor_id for all diagnoses with status 'Pending' and is_chronic set to TRUE.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT diagnosis_id, patient_id, doctor_id FROM healthcare.diagnoses WHERE status = 'Pending'... |
You are an expert in writing database language. You 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.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )
CREATE TABLE trading_platform.wallets (
wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet
user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet
address character varying(128) NOT NULL, -- address of the wallet
private_key text NOT NULL, -- private key of the wallet
created_at timestamp NOT NULL, -- time when the wallet was created
PRIMARY KEY (wallet_id)
)
CREATE TABLE trading_platform.orders ( order_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, wallet_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, order_type character varying(32) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, status character varying(32) NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (order_id) )
CREATE TABLE trading_platform.trades ( trade_id text PRIMARY KEY, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp )
CREATE TABLE trading_platform.assets (
asset_id character varying(64) NOT NULL, -- unique identifier for the asset
name character varying(128) NOT NULL, -- name of the asset
symbol character varying(32) NOT NULL, -- symbol of the asset
type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)
PRIMARY KEY (asset_id)
)
CREATE TABLE trading_platform.utxos (
utxo_id character varying(64) NOT NULL, -- unique identifier for the UTXO
transaction_id character varying(64) NOT NULL, -- identifier of the transaction that created the UTXO
output_index integer NOT NULL, -- index of the output in the transaction
address character varying(128) NOT NULL, -- address that can spend the UTXO
amount numeric(38,14) NOT NULL, -- amount of the asset in the UTXO
spent boolean NOT NULL, -- whether the UTXO has been spent
PRIMARY KEY (utxo_id)
)
CREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )
CREATE TABLE trading_platform.metadata (
metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata
asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with
key character varying(128) NOT NULL, -- key of the metadata
value text NOT NULL, -- value of the metadata
PRIMARY KEY (metadata_id)
)
CREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )
CREATE TABLE trading_platform.logs (
log_id character varying(64) NOT NULL, -- unique identifier for the log entry
user_id character varying(64), -- identifier of the user associated with the log entry
action character varying(128) NOT NULL, -- action performed
details text NOT NULL, -- details of the action
logged_at timestamp NOT NULL, -- time when the log entry was created
PRIMARY KEY (log_id)
)
CREATE TABLE trading_platform.notifications ( notification_id.text, user_id.text, message.text, sent_at.timestamp, read_at.timestamp )
| [
{
"role": "user",
"content": "Show me the usernames and emails of all users who have placed at least one 'buy' order for the asset named 'Bitcoin'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT DISTINCT T1.username, T1.email FROM trading_platform.users AS T1 JOIN trading_platfor... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "How many insurance policies does each subscriber have? Please display the subscriber name and policy count.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT subscriber_name, COUNT(*) AS policy_count FROM healthcare.patient_insurance GROUP BY subscriber... |
You are an expert in writing database language. You 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. Key pattern: 'component:<component_id>'. Example: HSET component:LGSTRUT01 part_number "PN-5521-A" component_name "Landing Gear Strut" material_id "mat:TI64" supplier_id "sup:ACME_AERO" ... Consider Sets for reverse lookups (e.g., 'material_components:<material_id>' -> Set<component_id>).
| [
{
"role": "user",
"content": "Can you help me get a list of components and their associated materials, including the supplier information for each component?",
"sql": null
},
{
"role": "assistant",
"content": "SMEMBERS material_components:<material_id>\nHGETALL component:<component_id>\nHGET... |
You are an expert in writing database language. You 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 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 )
CREATE 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 )
CREATE 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 )
CREATE 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 )
CREATE 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 )
| [
{
"role": "user",
"content": "Which exchange holds the largest total USD value of the token with the highest 24h price increase in the 'AI' narrative, and what is that value?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT ctb.exchange, SUM(ctb.usd_value) AS total_usd_value\nFROM ... |
You are an expert in writing database language. You 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.train_cars (
car_id character varying(64) NOT NULL, -- Unique identifier for the train car
train_id character varying(64) NOT NULL, -- Foreign key referencing trains
car_number character varying(10) NOT NULL, -- Identifier of the car within the train set
car_type character varying(64) NOT NULL, -- e.g., Locomotive, Passenger, Sleeper, Dining, Baggage
class character varying(32), -- e.g., First, Business, Economy (null for non-passenger cars)
capacity integer, -- Passenger capacity of this specific car (null for non-passenger cars)
features text, -- Comma-separated list of features (e.g., 'WiFi', 'Power Outlet', 'Accessible Restroom')
PRIMARY KEY (car_id),
FOREIGN KEY (train_id) REFERENCES train_station_management.trains(train_id)
)
CREATE TABLE train_station_management.routes (
route_id character varying(64) NOT NULL, -- Unique identifier for the route
route_name character varying(128) NOT NULL, -- Name of the route (e.g., 'Northeast Corridor')
description text, -- Description of the route
origin_station_id character varying(64) NOT NULL, -- Starting station
destination_station_id character varying(64) NOT NULL, -- Final station
is_active boolean NOT NULL DEFAULT true, -- Is the route currently operational?
PRIMARY KEY (route_id),
FOREIGN KEY (origin_station_id) REFERENCES train_station_management.stations(station_id),
FOREIGN KEY (destination_station_id) REFERENCES train_station_management.stations(station_id)
)
CREATE TABLE train_station_management.tickets (
ticket_id character varying(64) NOT NULL, -- Unique identifier for the ticket
booking_id character varying(64) NOT NULL, -- Foreign key referencing the booking
car_id character varying(64) NOT NULL, -- Foreign key referencing the train car
seat_number character varying(10), -- Assigned seat number (e.g., '12A')
ticket_type character varying(32) NOT NULL DEFAULT 'Adult', -- e.g., Adult, Child, Senior, Student
price numeric(10, 2) NOT NULL, -- Price of this specific ticket
is_checked_in boolean NOT NULL DEFAULT false, -- Has the passenger checked in with this ticket?
qr_code_data text, -- Data for generating a QR code for the ticket
PRIMARY KEY (ticket_id),
FOREIGN KEY (booking_id) REFERENCES train_station_management.bookings(booking_id),
FOREIGN KEY (car_id) REFERENCES train_station_management.train_cars(car_id)
)
| [
{
"role": "user",
"content": "Can you help me find the total passenger capacity for each train car on a specific route with route_id 'RT123'?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT tc.train_id, tc.car_id, tc.car_number, tc.capacity\nFROM train_station_management.train_car... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "For each location, what is the average appointment duration? Show location_id and the average duration.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT location_id, AVG(duration_minutes) FROM healthcare.appointments GROUP BY location_id;",
"sql": ... |
You are an expert in writing database language. You 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 social_media.comments (
comment_id character varying(64) NOT NULL, -- unique identifier for the comment
post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)
user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)
parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)
content text NOT NULL, -- textual content of the comment
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit
PRIMARY KEY (comment_id)
)
CREATE TABLE social_media.conversation_participants ( participant_id text, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )
CREATE 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 )
| [
{
"role": "user",
"content": "List the content and comment ID for all comments made by users with private profiles.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.comment_id, c.content FROM social_media.comments AS c JOIN social_media.user_settings AS us ON c.user_id = us.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 trading_platform.dapps (
dapp_id character varying(64) NOT NULL, -- unique identifier for the DApp
name character varying(128) NOT NULL, -- name of the DApp
description text NOT NULL, -- description of the DApp
url character varying(256) NOT NULL, -- URL of the DApp
PRIMARY KEY (dapp_id)
)
CREATE TABLE trading_platform.kyc_audit (
kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit
user_id character varying(64) NOT NULL, -- identifier of the user being audited
status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)
reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed
PRIMARY KEY (kyc_audit_id)
)
| [
{
"role": "user",
"content": "Show me the names and URLs of all DApps, and for each DApp, list the KYC status and last review date for all users who have an audit entry.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT d.name AS dapp_name, d.url, k.user_id, k.status, k.reviewed_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 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) )
CREATE 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 )
CREATE TABLE trading_platform.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean )
CREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )
CREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )
CREATE TABLE trading_platform.metadata (
metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata
asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with
key character varying(128) NOT NULL, -- key of the metadata
value text NOT NULL, -- value of the metadata
PRIMARY KEY (metadata_id)
)
CREATE TABLE trading_platform.kyc_audit (
kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit
user_id character varying(64) NOT NULL, -- identifier of the user being audited
status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)
reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed
PRIMARY KEY (kyc_audit_id)
)
| [
{
"role": "user",
"content": "Count the number of metadata entries for each asset.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT asset_id, COUNT(*) AS metadata_count\nFROM trading_platform.metadata\nGROUP BY asset_id;",
"sql": null
},
{
"role": "user",
"content":... |
You are an expert in writing database language. You 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.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) )
CREATE 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) )
CREATE TABLE trading_platform.orders ( order_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, wallet_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, order_type character varying(32) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, status character varying(32) NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (order_id) )
CREATE TABLE trading_platform.dapps ( dapp_id character varying(64) NOT NULL, name character varying(128) NOT NULL, description text NOT NULL, url character varying(256) NOT NULL, PRIMARY KEY (dapp_id) )
CREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )
CREATE 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) )
CREATE TABLE trading_platform.logs ( log_id character varying(64) NOT NULL, user_id character varying(64), action character varying(128) NOT NULL, details text NOT NULL, logged_at timestamp NOT NULL, PRIMARY KEY (log_id) )
CREATE TABLE trading_platform.notifications ( notification_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, message text NOT NULL, sent_at timestamp NOT NULL, read_at timestamp, PRIMARY KEY (notification_id) )
| [
{
"role": "user",
"content": "Show all peers, listing their ID, IP address, and port.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT peer_id, ip_address, port FROM trading_platform.peers;",
"sql": null
},
{
"role": "user",
"content": "Display the username and the ... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "Show me all replies to comments, including the reply's comment ID, the parent comment ID, and the content.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT comment_id, parent_comment_id, content FROM social_media.comments WHERE parent_comment_id IS NOT... |
You are an expert in writing database language. You 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)
)
| [
{
"role": "user",
"content": "Show the count of citizens grouped by their verification status.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT is_verified, COUNT(*) FROM government_services.citizens GROUP BY is_verified;",
"sql": null
},
{
"role": "user",
"content"... |
You are an expert in writing database language. You 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 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 )
| [
{
"role": "user",
"content": "Find documents that have the same document_name but are associated with different cases. Show the document name and the two different case IDs.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT d1.document_name, d1.case_id AS case_id_1, d2.case_id AS ca... |
You are an expert in writing database language. You 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 social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )
| [
{
"role": "user",
"content": "How many users have followed more than one person in total?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT follower_user_id, COUNT(DISTINCT following_user_id) AS following_count\nFROM social_media.follows\nGROUP BY follower_user_id\nHAVING COUNT(DIST... |
You are an expert in writing database language. You 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.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )
| [
{
"role": "user",
"content": "List all medications with a description that includes the word 'antibiotic'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT * FROM healthcare.medications WHERE description ILIKE '%antibiotic%';",
"sql": null
},
{
"role": "user",
"cont... |
You are an expert in writing database language. You 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 legal_services.cases (
case_id character varying(64) NOT NULL, -- unique identifier for the case/matter
case_number character varying(100) UNIQUE, -- official case number (court or internal)
case_name text NOT NULL, -- descriptive name or title for the case
client_id character varying(64) NOT NULL, -- FK to clients table
lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)
case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP
status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed
date_opened timestamp NOT NULL, -- date the case was formally opened
date_closed timestamp, -- date the case was closed (nullable)
description text, -- detailed description of the case
court_jurisdiction character varying(128), -- court or jurisdiction if applicable
PRIMARY KEY (case_id)
)
CREATE TABLE legal_services.time_entries ( entry_id text PRIMARY KEY, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable bool, is_billed bool, invoice_id text, created_at timestamp )
CREATE 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 )
| [
{
"role": "user",
"content": "Show me the total hours spent by each lawyer for each case, along with the case number and lawyer ID.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT t.case_id, c.case_number, t.lawyer_id, SUM(t.hours_spent) AS total_hours\nFROM legal_services.time_en... |
You are an expert in writing database language. You 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 character varying(64) NOT NULL, -- unique identifier for the room type
property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)
type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite
description text, -- description of the room type
base_rate numeric(10, 2) NOT NULL, -- standard price per night
max_occupancy integer NOT NULL, -- maximum number of guests
bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin
area_sqft numeric(8,2), -- size of the room in square feet
amenities text, -- comma-separated list or JSON of amenities
PRIMARY KEY (room_type_id),
FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)
)
CREATE 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 )
| [
{
"role": "user",
"content": "Show each staff member's first name, last name, and the average base rate of room types available at the property where they work.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.first_name, T1.last_name, T2.avg_base_rate FROM hospitality_technolog... |
You are an expert in writing database language. You 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_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) )
| [
{
"role": "user",
"content": "Show me the top 5 smart money addresses by profit on the Ethereum chain, along with their most profitable token and ROI, but only include addresses with a realized profit ratio above 70%.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT address, most_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
CREATE 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 )
| [
{
"role": "user",
"content": "Count the number of passengers in each month of the year 2024 based on their created_at date.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT EXTRACT(MONTH FROM created_at) AS month, COUNT(*) AS passenger_count\nFROM transportation.passengers\nWHERE c... |
You are an expert in writing database language. You 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
Collection 'assembly_steps'. Document structure: { _id: <ObjectId (or step_id)>, step_id: String, line_id: String (reference), step_number: NumberInt, step_name: String, description: String, standard_duration_hours: Decimal128, required_skill_level: String, workstation: String }. Required: step_id, line_id, step_number, step_name. Index on line_id, step_number.
Collection 'employees'. Document structure: { _id: <ObjectId (or employee_id)>, employee_id: String, first_name: String, last_name: String, job_title: String, skill_certifications: [String], hire_date: ISODate, assigned_line_id: String (reference, optional), employment_status: String, supervisor_employee_id: String (reference, optional) }. Required: employee_id, first_name, last_name, job_title, hire_date, employment_status.
| [
{
"role": "user",
"content": "特定の職種の従業員情報を取得したいです。従業員ID、名前、職種、雇用日を表示してください。",
"sql": null
},
{
"role": "assistant",
"content": "db.employees.find(\n { job_title: '<specific_job_title>' },\n { employee_id: 1, first_name: 1, last_name: 1, job_title: 1, hire_date: 1, _id: 0 }\n).sort({ hi... |
You are an expert in writing database language. You 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 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) )
| [
{
"role": "user",
"content": "Show me the names, founding dates, and websites of all law firms whose name contains the word 'Legal' and were founded after the year 2005. Sort the results by their founding date.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT firm_name, founded_dat... |
You are an expert in writing database language. You 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 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) )
| [
{
"role": "user",
"content": "List all pairs of hashtags created on the same calendar date, showing both tag names and the creation date.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT h1.tag_name AS tag1, h2.tag_name AS tag2, DATE(h1.created_at) AS created_date\nFROM social_medi... |
You are an expert in writing database language. You 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
// db.createCollection('stations')
// Optional: Add unique index: db.stations.createIndex({ station_id: 1 }, { unique: true })
{
_id: ObjectId(), // Auto-generated MongoDB ID
station_id: "station_xyz", // String (unique identifier, corresponds to SQL PK)
station_name: "Grand Central Terminal", // String
city: "New York", // String
state_province: "NY", // String
country_code: "USA", // String
address: "89 E 42nd St, New York, NY 10017", // String
timezone: "America/New_York", // String
number_of_platforms: 44, // Int32
created_at: ISODate("2023-01-15T10:00:00Z"), // Date
last_updated_at: ISODate("2023-10-28T15:30:00Z") // Date
}
// db.createCollection('trains')
// Optional: db.trains.createIndex({ train_id: 1 }, { unique: true })
// Optional: db.trains.createIndex({ train_number: 1 }, { unique: true })
{
_id: ObjectId(),
train_id: "train_789", // String (unique)
train_number: "Acela 2151", // String (unique)
model: "Siemens Velaro", // String
manufacturer: "Siemens", // String
year_manufactured: 2010, // Int32
capacity: 304, // Int32
status: "Active", // String ('Active', 'Maintenance', 'Retired')
last_maintenance_date: ISODate("2023-09-15"), // Date (Date part only relevant)
next_maintenance_date: ISODate("2024-03-15") // Date (Date part only relevant)
}
// db.createCollection('bookings')
// Optional: db.bookings.createIndex({ booking_id: 1 }, { unique: true })
// Optional: db.bookings.createIndex({ passenger_id: 1 })
// Optional: db.bookings.createIndex({ schedule_id: 1 })
{
_id: ObjectId(),
booking_id: "book_zyx", // String (unique)
passenger_id: "pass_pqr", // String (references passengers.passenger_id)
schedule_id: "sched_1122", // String (references schedules.schedule_id)
booking_datetime: ISODate("2024-04-15T14:30:00Z"), // Date
status: "Confirmed", // String ('Confirmed', 'Cancelled', 'Pending')
total_price: 150.75, // Decimal128 or Double
currency_code: "USD", // String
special_requests: "Wheelchair assistance required at origin" // String
}
// db.createCollection('staff')
// Optional: db.staff.createIndex({ staff_id: 1 }, { unique: true })
// Optional: db.staff.createIndex({ employee_number: 1 }, { unique: true })
// Optional: db.staff.createIndex({ contact_email: 1 }, { unique: true, sparse: true })
{
_id: ObjectId(),
staff_id: "staff_mno", // String (unique)
first_name: "Bob", // String
last_name: "Jones", // String
role: "Conductor", // String
primary_station_id: null, // String (references stations.station_id, nullable)
employee_number: "E12345", // String (unique)
hire_date: ISODate("2018-06-01"), // Date
contact_email: "bob.jones@example-rail.com", // String (unique, sparse)
contact_phone: "+15559876543", // String
is_active: true // Boolean
}
| [
{
"role": "user",
"content": "Can you help me count the total number of active staff members in the database?",
"sql": null
},
{
"role": "assistant",
"content": "db.staff.countDocuments({ is_active: true });",
"sql": null
},
{
"role": "user",
"content": "Can you assist me in ... |
You are an expert in writing database language. You 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. Key pattern: 'inv:<inventory_record_id>'. 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:<component_id> <expiry_timestamp> <inventory_record_id>.
| [
{
"role": "user",
"content": "Can you help me fetch the inventory records for components stored in a specific warehouse, along with their expiry dates?",
"sql": null
},
{
"role": "assistant",
"content": "HGETALL inv:<inventory_record_id>\nZRANGE component_expiry:<component_id> 0 -1 WITHSCORE... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "Show me all transactions along with the related account IDs where the transaction type is 'Transfer'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT transaction_id, account_id, related_account_id, transaction_type, amount, currency, transaction_date,... |
You are an expert in writing database language. You 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.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 )
CREATE 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 )
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 )
CREATE 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 )
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 )
CREATE 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 )
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 )
CREATE 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 )
CREATE 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 )
| [
{
"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.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT so.order_id, g.first_name, g.last_name, s.service_name, st.first_name AS staff... |
You are an expert in writing database language. You 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.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )
| [
{
"role": "user",
"content": "Count the number of logs for each action type.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT action,\n COUNT(*) AS count\nFROM trading_platform.logs\nGROUP BY action;",
"sql": null
},
{
"role": "user",
"content": "For each 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 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 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 manufacturing.employees ( employee_id text PRIMARY KEY, first_name text, last_name text, job_title text, skill_certifications text, hire_date date, assigned_line_id text, employment_status text, supervisor_employee_id text )
| [
{
"role": "user",
"content": "What is the total number of vacation days taken by employee with ID 'EMP101' in the past year?",
"sql": null
},
{
"role": "assistant",
"content": "I'm sorry, but I can't provide information on the vacation days taken by an employee as this data is not stored in ... |
You are an expert in writing database language. You 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.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) )
CREATE 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) )
CREATE 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) )
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) )
| [
{
"role": "user",
"content": "Show all prescriptions with prescription_id, patient_id, medication_id, quantity_dispensed, and refills_allowed.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT prescription_id, patient_id, medication_id, quantity_dispensed, refills_allowed FROM healt... |
You are an expert in writing database language. You 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 social_media.users (
user_id character varying(64) NOT NULL, -- unique identifier for the user
username character varying(50) NOT NULL UNIQUE, -- user's unique handle
email character varying(128) NOT NULL UNIQUE, -- user's email address
password_hash text NOT NULL, -- hashed password
full_name character varying(100), -- user's full name
profile_picture_url text, -- URL to the profile picture
bio text, -- short user biography
location character varying(100), -- user's location
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update
is_verified boolean NOT NULL DEFAULT false, -- verification status
PRIMARY KEY (user_id)
)
CREATE TABLE social_media.posts (
post_id character varying(64) NOT NULL, -- unique identifier for the post
user_id character varying(64) NOT NULL, -- identifier of the user who created the post (FK to users.user_id)
content text, -- textual content of the post
media_url text, -- URL to attached media (image/video)
media_type character varying(20), -- type of media ('image', 'video', null)
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of post creation
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last post edit
visibility character varying(20) NOT NULL DEFAULT 'public', -- visibility ('public', 'friends', 'private')
location_lat numeric(9,6), -- latitude of post location
location_lon numeric(9,6), -- longitude of post location
PRIMARY KEY (post_id)
)
CREATE TABLE social_media.comments (
comment_id character varying(64) NOT NULL, -- unique identifier for the comment
post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)
user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)
parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)
content text NOT NULL, -- textual content of the comment
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit
PRIMARY KEY (comment_id)
)
CREATE TABLE social_media.likes (
like_id character varying(64) NOT NULL, -- unique identifier for the like
user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id)
post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable)
comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable)
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred
PRIMARY KEY (like_id),
CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes
CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something
)
CREATE TABLE social_media.follows (
follow_id character varying(64) NOT NULL, -- unique identifier for the follow relationship
follower_user_id character varying(64) NOT NULL, -- identifier of the user who is following (FK to users.user_id)
following_user_id character varying(64) NOT NULL, -- identifier of the user being followed (FK to users.user_id)
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the follow started
PRIMARY KEY (follow_id),
CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) -- prevent duplicate follows
)
CREATE TABLE social_media.hashtags (
hashtag_id character varying(64) NOT NULL, -- unique identifier for the hashtag
tag_name character varying(100) NOT NULL UNIQUE, -- the actual hashtag text (without '#')
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when the hashtag was first used
PRIMARY KEY (hashtag_id)
)
CREATE TABLE social_media.messages (
message_id character varying(64) NOT NULL, -- unique identifier for the message
conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)
sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)
content text, -- textual content of the message
media_url text, -- URL to attached media (image/video)
media_type character varying(20), -- type of media ('image', 'video', null)
sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent
read_at timestamp, -- timestamp when message was read by recipient(s)
PRIMARY KEY (message_id)
)
CREATE TABLE social_media.conversations (
conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated
last_message_at timestamp, -- timestamp of the last message in the conversation
is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message
group_name character varying(100), -- name of the group chat (if applicable)
PRIMARY KEY (conversation_id)
)
CREATE TABLE social_media.conversation_participants (
participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry
conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)
user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)
joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation
last_read_at timestamp, -- timestamp indicating up to when the user has read messages
PRIMARY KEY (participant_id),
CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times
)
CREATE TABLE social_media.notifications (
notification_id character varying(64) NOT NULL, -- unique identifier for the notification
recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)
sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)
notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')
target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)
target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created
read_at timestamp, -- timestamp notification was marked as read
PRIMARY KEY (notification_id)
)
CREATE TABLE social_media.user_settings (
setting_id character varying(64) NOT NULL, -- unique identifier for the setting entry
user_id character varying(64) NOT NULL UNIQUE, -- user the settings belong to (FK to users.user_id)
theme character varying(20) DEFAULT 'light', -- UI theme ('light', 'dark')
email_notifications_enabled boolean DEFAULT true, -- enable/disable email notifications
push_notifications_enabled boolean DEFAULT true, -- enable/disable push notifications
private_profile boolean DEFAULT false, -- is the user profile private
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last setting change
PRIMARY KEY (setting_id)
)
| [
{
"role": "user",
"content": "List users who commented on posts and the content of the post they commented on. Show commenter username and post content.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.username, T2.content FROM social_media.users AS T1 JOIN social_media.comments... |
You are an expert in writing database language. You 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 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) )
| [
{
"role": "user",
"content": "List all available services along with the property name where they are offered.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT s.service_id, s.service_name, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.propert... |
You are an expert in writing database language. You 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.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 )
| [
{
"role": "user",
"content": "Get the number of insurance products grouped by product_type and their active status. Return product_type, is_active, and the count of products.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT product_type, is_active, COUNT(*) AS product_count\nFROM i... |
You are an expert in writing database language. You 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 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 )
CREATE 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 )
CREATE 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 )
CREATE 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 )
CREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, 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 )
CREATE 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 )
| [
{
"role": "user",
"content": "Show the full names and contact emails of all citizens who have made a payment for an application that is currently in 'Pending' status.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT DISTINCT c.first_name || ' ' || c.last_name AS full_name, c.contac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.