system
stringlengths
315
8.06k
conversations
listlengths
2
48
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )
[ { "role": "user", "content": "List all pairs of wallets that use the same private_key. Display w1.wallet_id, w1.user_id, w2.wallet_id, w2.user_id, and the shared private_key.", "sql": null }, { "role": "assistant", "content": "SELECT w1.wallet_id AS wallet1_id,\n w1.user_id AS user1_...
You are an expert in writing database language. You 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.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.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": "How many unread notifications does each user have?", "sql": null }, { "role": "assistant", "content": "SELECT user_id,\n COUNT(*) AS unread_notifications\nFROM trading_platform.notifications\nWHERE read_at IS NULL\nGROUP BY user_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 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) ) 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.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) ) CREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text ) 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": "List all prescriptions with the corresponding patient's emergency contact name and phone number. Show prescription ID, patient full name, emergency contact name, and emergency contact phone.", "sql": null }, { "role": "assistant", "content": "SELECT pr.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 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 gaming_technology.games ( game_id uuid PRIMARY KEY, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text ) 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 PRIMARY KEY, game_id uuid, server_name text, region text, ip_address text, port int, current_players int, max_players int, status text, last_heartbeat timestamptz ) CREATE TABLE gaming_technology.achievements ( achievement_id uuid PRIMARY KEY, game_id uuid, name text, description text, icon_url text, points int, hidden boolean ) CREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid PRIMARY KEY, player_id uuid, achievement_id uuid, unlocked_at timestamptz ) CREATE TABLE gaming_technology.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb ) 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": "Show me the title of each game and the total number of game sessions played on servers hosting that game.", "sql": null }, { "role": "assistant", "content": "SELECT t1.title, count(t3.session_id) FROM gaming_technology.games AS t1 JOIN gaming_technology.servers ...
You are an expert in writing database language. You 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.developers ( developer_id uuid, name text, country text, founded_year integer, website text, created_at timestamp with time zone )
[ { "role": "user", "content": "Give me the count of developers per country.", "sql": null }, { "role": "assistant", "content": "SELECT country,\n COUNT(*) AS developer_count\nFROM gaming_technology.developers\nGROUP BY country;\n", "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 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 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.lawyers ( lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer first_name character varying(100) NOT NULL, -- lawyer's first name last_name character varying(100) NOT NULL, -- lawyer's last name bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number firm_id character varying(64), -- FK to law_firms table email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email phone character varying(32), -- lawyer's contact phone number specialization text, -- areas of legal expertise hire_date timestamp NOT NULL, -- date the lawyer was hired or joined is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner PRIMARY KEY (lawyer_id) ) CREATE TABLE legal_services.law_firms ( firm_id character varying(64) NOT NULL, -- unique identifier for the law firm firm_name character varying(200) NOT NULL, -- official name of the law firm address text NOT NULL, -- primary address of the firm phone character varying(32), -- firm's main phone number website character varying(255), -- firm's website URL founded_date date, -- date the firm was established managing_partner_id character varying(64), -- FK to lawyers table (optional) PRIMARY KEY (firm_id) ) 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.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": "Show all law firms with more than one partner assigned. Display the law firm name and the number of partners.", "sql": null }, { "role": "assistant", "content": "SELECT lf.firm_name, COUNT(l.lawyer_id) AS partner_count\nFROM legal_services.law_firms lf\nJOIN leg...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE transportation.routes ( route_id text, 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.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text ) CREATE TABLE transportation.bookings ( booking_id text, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )
[ { "role": "user", "content": "Which locations have received fuel logs greater than 300 liters in total? Please include the location name and city.", "sql": null }, { "role": "assistant", "content": "SELECT l.name AS location_name, l.city, SUM(f.quantity) AS total_quantity\nFROM transportatio...
You are an expert in writing database language. You 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 character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )
[ { "role": "user", "content": "What is the average overall rating for each property?", "sql": null }, { "role": "assistant", "content": "SELECT property_id, AVG(rating_overall) AS avg_rating\nFROM hospitality_technology.reviews\nGROUP BY property_id;", "sql": null }, { "role": "us...
You are an expert in writing database language. You 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.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )
[ { "role": "user", "content": "Retrieve the first name, last name, and email for all guests.", "sql": null }, { "role": "assistant", "content": "SELECT first_name, last_name, email FROM hospitality_technology.guests;", "sql": null }, { "role": "user", "content": "Can you also ...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link patient_id character varying(64) NOT NULL, -- FK to patients table plan_id character varying(64) NOT NULL, -- FK to insurance_plans table policy_number character varying(100) NOT NULL, -- patient's policy number group_number character varying(100), -- group number, if applicable subscriber_name character varying(200), -- name of the primary policy holder effective_date date NOT NULL, -- date the coverage begins expiration_date date, -- date the coverage ends (if known) is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice )
[ { "role": "user", "content": "List all insurance plans that will expire within the next 30 days, showing the patient IDs and subscriber names.", "sql": null }, { "role": "assistant", "content": "SELECT patient_id, subscriber_name, policy_number, expiration_date\nFROM healthcare.patient_insur...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )
[ { "role": "user", "content": "List all service orders with quantity greater than 3, showing the order ID, total price, and the staff member who placed the order.", "sql": null }, { "role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered\nFROM hospitality_technology.se...
You are an expert in writing database language. You 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. You 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 hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) ) CREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, room_number character varying(10) NOT NULL, room_type_id character varying(64) NOT NULL, floor integer, status character varying(50) NOT NULL, is_smoking boolean NOT NULL DEFAULT false, features text, current_condition text, last_cleaned_at timestamp with time zone, PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) ) CREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) ) CREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) ) 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) ) CREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) ) CREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) ) CREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )
[ { "role": "user", "content": "List all services in the 'Concierge' department along with their names, price, and whether they are currently available. Include the property name as well.", "sql": null }, { "role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.prop...
You are an expert in writing database language. You 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.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.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.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": "How many available services are there per department for each property? Include property_id, department, and the service count.", "sql": null }, { "role": "assistant", "content": "SELECT\n property_id,\n department,\n COUNT(*) AS available_services_count\nFRO...
You are an expert in writing database language. You 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 ) 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.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.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.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 character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) ) CREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )
[ { "role": "user", "content": "Find all top-level agencies that do not have a parent agency. Display their agency_id and agency_name.", "sql": null }, { "role": "assistant", "content": "SELECT agency_id, agency_name\nFROM government_services.agencies\nWHERE parent_agency_id IS NULL;", "sq...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE web3.tokens ( token_id text PRIMARY KEY, contract_address text, token_name text, token_symbol text, decimals int, total_supply numeric )
[ { "role": "user", "content": "Find all pairs of tokens that have the same contract_address but different token_symbols. Show both token_ids, each token's symbol, and the shared contract_address.", "sql": null }, { "role": "assistant", "content": "SELECT t1.token_id AS token_id_1, t2.token_id...
You are an expert in writing database language. You 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, -- unique identifier for a specific trip instance route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips) vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used driver_id character varying(64) NOT NULL, -- identifier of the driver operating scheduled_departure timestamp with time zone NOT NULL, -- planned departure time actual_departure timestamp with time zone, -- actual departure time scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time actual_arrival timestamp with time zone, -- actual arrival time origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin) destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination) status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled passenger_count integer, -- number of passengers (if applicable) cargo_manifest_id character varying(64), -- link to cargo details (if applicable) PRIMARY KEY (trip_id) )
[ { "role": "user", "content": "For each trip, show the trip ID, vehicle ID, driver ID, and both the actual starting and ending location IDs.", "sql": null }, { "role": "assistant", "content": "SELECT trip_id, vehicle_id, driver_id, origin_location_id, destination_location_id FROM transportati...
You are an expert in writing database language. You 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 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.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.achievements ( achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to name character varying(150) NOT NULL, -- name of the achievement description text NOT NULL, -- how to unlock the achievement icon_url character varying(255), -- URL for the achievement's icon points integer DEFAULT 0, -- points awarded for unlocking (optional) hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked PRIMARY KEY (achievement_id) -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id) ) CREATE TABLE gaming_technology.player_achievements ( player_achievement_id.uuid, player_id.uuid, achievement_id.uuid, unlocked_at.timestamptz ) CREATE TABLE gaming_technology.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )
[ { "role": "user", "content": "Could you list each player's username and the total number of sessions they have played?", "sql": null }, { "role": "assistant", "content": "SELECT p.username, COUNT(gs.session_id) AS total_sessions\nFROM gaming_technology.players p\nLEFT JOIN gaming_technology....
You are an expert in writing database language. You 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 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 erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer ) 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 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 sui_coins_metadata ( object_id varchar NOT NULL, -- object id of the coin metadata object coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN status varchar NOT NULL, -- coin status, eg. exists, deleted decimals bigint NOT NULL, -- decimals of the coin description varchar NOT NULL, -- description of the coin icon_url varchar NOT NULL, -- icon url of the coin symbol varchar NOT NULL, -- symbol of the coin name varchar NOT NULL -- name of the coin ) CREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text ) CREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL ) CREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp ) CREATE TABLE token_prices_latest ( 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 token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text ) 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_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text ) CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text ) 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 ) CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )
[ { "role": "user", "content": "Which ERC1155 NFT contracts have received approval-for-all events, and for each contract, how many total approval events were recorded?", "sql": null }, { "role": "assistant", "content": "SELECT contract_address, COUNT(*) AS approval_count FROM erc1155_approval_...
You are an expert in writing database language. You 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 text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )
[ { "role": "user", "content": "How many addresses on the Ethereum chain have an ROI between 2 and 4?", "sql": null }, { "role": "assistant", "content": "SELECT COUNT(*) AS address_count FROM smart_money_profit WHERE chain = 'Ethereum' AND roi >= 2 AND roi <= 4;", "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 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 )
[ { "role": "user", "content": "Can you show me the number of lawyers grouped by specialization?", "sql": null }, { "role": "assistant", "content": "SELECT specialization, COUNT(*) AS lawyer_count FROM lawyers GROUP BY specialization;", "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 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) )
[ { "role": "user", "content": "Show me the total quantity traded and total amount for each security, identified by its ticker symbol, for trades in the last month.", "sql": null }, { "role": "assistant", "content": "SELECT T2.ticker_symbol, SUM(T1.quantity), SUM(T1.total_amount) FROM financia...
You are an expert in writing database language. You 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. You 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 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 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 hospitality_technology.rooms ( room_id character varying(64) NOT NULL, -- unique identifier for the room property_id character varying(64) NOT NULL, -- FK to properties table room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B') room_type_id character varying(64) NOT NULL, -- FK to room_types table floor integer, -- floor number the room is on status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi) current_condition text, -- notes on room condition last_cleaned_at timestamp with time zone, -- timestamp of last cleaning PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) ) 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 character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) ) CREATE TABLE hospitality_technology.staff ( staff_id character varying(64) NOT NULL, -- unique identifier for the staff member property_id character varying(64) NOT NULL, -- FK to properties table (primary property) first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge work_email character varying(255) UNIQUE, -- staff member's work email work_phone character varying(30), hire_date date NOT NULL, termination_date date, -- date employment ended (if applicable) is_active boolean NOT NULL DEFAULT true, -- currently employed flag access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin) manager_id character varying(64), -- FK to staff table (self-referencing for supervisor) created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (staff_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id) ) 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) ) CREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction reservation_id character varying(64), -- FK to reservations (if payment is for a stay) guest_id character varying(64) NOT NULL, -- FK to guests (who paid) bill_id character varying(64), -- FK to bills/invoices this payment applies to amount numeric(12,2) NOT NULL, -- amount of the payment currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR) payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC) card_last_four character varying(4), -- last 4 digits of CC (if CC) transaction_ref character varying(128), -- reference ID from payment gateway or processor payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed staff_id_processed character varying(64), -- FK to staff (who processed the payment) notes text, -- notes about the payment PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) )
[ { "role": "user", "content": "Show me the average base rate for each room type across all properties. Include the room type name and the calculated average rate.", "sql": null }, { "role": "assistant", "content": "SELECT type_name, AVG(base_rate) FROM hospitality_technology.room_types GROUP ...
You are an expert in writing database language. You 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 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 )
[ { "role": "user", "content": "Find all applications that were submitted in 2023 but received a decision ('Approved' or 'Rejected') in 2024. List the application ID, submitted date, decision date, and status.", "sql": null }, { "role": "assistant", "content": "SELECT application_id, submitted...
You are an expert in writing database language. You 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 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 )
[ { "role": "user", "content": "Show a count of drivers per status.", "sql": null }, { "role": "assistant", "content": "SELECT status, COUNT(*) AS driver_count\nFROM transportation.drivers\nGROUP BY status;", "sql": null }, { "role": "user", "content": "Can you also list the ea...
You are an expert in writing database language. You 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 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.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 )
[ { "role": "user", "content": "Show the number of staff members in each position and the average access level, grouping by position.", "sql": null }, { "role": "assistant", "content": "SELECT position,\n COUNT(*) AS staff_count,\n AVG(access_level) AS avg_access_level\nFROM hospit...
You are an expert in writing database language. You 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 insurance.claims ( claim_id character varying(64) NOT NULL, -- unique identifier for the claim policy_id character varying(64) NOT NULL, -- identifier of the policy under which the claim is made (FK to policies) customer_id character varying(64) NOT NULL, -- identifier of the customer making the claim (FK to customers) incident_date timestamp NOT NULL, -- date and time of the incident leading to the claim reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the claim was reported description text NOT NULL, -- detailed description of the incident and claim estimated_loss numeric(15, 2), -- initial estimated cost of the loss status character varying(30) NOT NULL, -- e.g., Filed, Processing, Under Review, Approved, Denied, Settled settlement_amount numeric(15, 2), -- final amount paid out settlement_date date, claim_handler_id character varying(64), -- identifier for the employee handling the claim (FK to employees/adjusters) police_report_number character varying(100), PRIMARY KEY (claim_id) )
[ { "role": "user", "content": "Show the number of claims filed for each distinct status, ordered by the count in descending order.", "sql": null }, { "role": "assistant", "content": "SELECT status, COUNT(*) AS claim_count\nFROM insurance.claims\nGROUP BY status\nORDER BY claim_count DESC;", ...
You are an expert in writing database language. You 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 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 financial_services.transactions ( transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction account_id character varying(64) NOT NULL, -- account involved in the transaction related_account_id character varying(64), -- counterpart account for transfers transaction_type character varying(50) NOT NULL, -- e.g., Deposit, Withdrawal, Transfer, Payment, Fee, Interest amount numeric(19, 4) NOT NULL, -- transaction amount currency character varying(3) NOT NULL, -- transaction currency transaction_date timestamp NOT NULL, -- exact time of the transaction effective_date date NOT NULL, -- date the transaction affects the balance description text, -- description or memo of the transaction status character varying(32) NOT NULL, -- e.g., Pending, Completed, Failed, Reversed reference_number character varying(128), -- external reference if applicable (e.g., check number) 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.trades ( trade_id.text, account_id.text, security_id.text, order_id.text, trade_type.text, quantity.numeric, price_per_unit.numeric, total_amount.numeric, commission.numeric, trade_timestamp.timestamp, settlement_date.date, status.text, execution_venue.text ) CREATE TABLE financial_services.employees ( employee_id text, 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": "How many transactions are there for each status?", "sql": null }, { "role": "assistant", "content": "SELECT status, COUNT(*) AS transaction_count FROM financial_services.transactions GROUP BY status;", "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.customers ( customer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, ssn_hash character varying(128), address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state character varying(50) NOT NULL, zip_code character varying(20) NOT NULL, country character varying(50) NOT NULL DEFAULT 'USA', phone_number character varying(30), email character varying(128) UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, status character varying(20) NOT NULL DEFAULT 'Active', PRIMARY KEY (customer_id) ) 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 character varying(64) NOT NULL, product_name character varying(150) NOT NULL, product_type character varying(50) NOT NULL, description text, base_premium numeric(10, 2) NOT NULL, coverage_details text, underwriting_rules text, is_active boolean NOT NULL DEFAULT true, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, PRIMARY KEY (product_id) ) CREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, amount_paid numeric(12, 2) NOT NULL, payment_method character varying(50), transaction_reference character varying(128) UNIQUE, due_date date, payment_period_start date, payment_period_end date, status character varying(30) NOT NULL DEFAULT 'Completed', PRIMARY KEY (payment_id) ) 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": "Count the number of premium payments that have a null payment method.", "sql": null }, { "role": "assistant", "content": "SELECT COUNT(*) AS null_payment_method_count\nFROM insurance.premium_payments\nWHERE payment_method IS NULL;", "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 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 government_services.agencies ( agency_id character varying(64) NOT NULL, -- unique identifier for the agency agency_name character varying(255) NOT NULL, -- full name of the government agency jurisdiction_level character varying(50) NOT NULL, -- e.g., Federal, State, County, City 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), -- FK to self for hierarchical structure PRIMARY KEY (agency_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 character varying(64) NOT NULL, -- unique identifier for the document instance application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly) citizen_id character varying(64) NOT NULL, -- FK to citizens table document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path) upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected verified_by_employee_id character varying(64), -- FK to employees table verification_timestamp timestamp, PRIMARY KEY (document_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) )
[ { "role": "user", "content": "List the agency names and addresses for all service locations in the state of 'Florida'.", "sql": null }, { "role": "assistant", "content": "SELECT a.agency_name, l.address\nFROM government_services.service_locations l\nJOIN government_services.agencies a ON l.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 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 hospitality_technology.properties ( property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.) property_name character varying(255) NOT NULL, -- name of the property address_line1 character varying(255) NOT NULL, -- primary address line address_line2 character varying(255), -- secondary address line city character varying(100) NOT NULL, -- city state_province character varying(100), -- state or province postal_code character varying(20) NOT NULL, -- zip or postal code country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN) phone_number character varying(30), -- main contact phone email_address character varying(255), -- main contact email property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel star_rating numeric(2,1), -- star rating (e.g., 4.5) timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York) manager_staff_id character varying(64), -- FK to staff table for the general manager created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time PRIMARY KEY (property_id) ) 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.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) ) CREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp ) CREATE TABLE hospitality_technology.services ( service_id text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text ) CREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) ) CREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )
[ { "role": "user", "content": "Show all payments made for reservations that had more than 2 adults. Include the payment ID, amount, currency, reservation ID, guest full name, and the number of adults in the reservation.", "sql": null }, { "role": "assistant", "content": "SELECT T1.payment_id,...
You are an expert in writing database language. You 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, 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 pairs of distinct locations in the same city that share the same location type. Show both location IDs, names, city, and the shared type.", "sql": null }, { "role": "assistant", "content": "SELECT L1.location_id AS location1_id, L1.name AS location1_name, L...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE transportation.fuel_logs ( fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type) quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh) unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh) cost_per_unit numeric(8, 4), -- price per unit of fuel total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase odometer_reading integer, -- vehicle mileage at time of fueling location_id character varying(64), -- identifier of the fueling station/location PRIMARY KEY (fuel_log_id) )
[ { "role": "user", "content": "For each trip, provide the trip_id, the total fuel quantity refueled, and the number of refueling events that occurred during the trip.", "sql": null }, { "role": "assistant", "content": "SELECT trip_id, SUM(quantity) AS total_fuel_quantity, COUNT(*) AS refuel_e...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE web3.tokens ( token_id character varying(64) NOT NULL, -- unique identifier for the token contract_address character varying(128) NOT NULL, -- address of the token contract token_name character varying(128) NOT NULL, -- name of the token token_symbol character varying(32) NOT NULL, -- symbol of the token decimals integer NOT NULL, -- number of decimals for the token total_supply numeric(38,14) NOT NULL, -- total supply of the token PRIMARY KEY (token_id) )
[ { "role": "user", "content": "Count how many tokens exist for each contract_address.", "sql": null }, { "role": "assistant", "content": "SELECT contract_address,\n COUNT(*) AS token_count\nFROM web3.tokens\nGROUP BY contract_address;", "sql": null }, { "role": "user", "...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text ) 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.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, 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": "Retrieve the policy_number, claim_id, incident_date, and document_type for all claims that have at least one \"Damage Assessment\" document. Sort the results by incident_date descending.", "sql": null }, { "role": "assistant", "content": "SELECT p.policy_number,...
You are an expert in writing database language. You 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.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 )
[ { "role": "user", "content": "Find all applications that were submitted in 2023 but received a decision ('Approved' or 'Rejected') in 2024. List the application ID, submitted date, decision date, and status.", "sql": null }, { "role": "assistant", "content": "SELECT application_id, submitted...
You are an expert in writing database language. You 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.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )
[ { "role": "user", "content": "List the number of bookings for each day.", "sql": null }, { "role": "assistant", "content": "SELECT DATE(booking_time) AS booking_date, COUNT(*) AS booking_count\nFROM transportation.bookings\nGROUP BY DATE(booking_time);\n", "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 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 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 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.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.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id) hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id) PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post ) 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": "How many users have verified profiles and private profiles enabled?", "sql": null }, { "role": "assistant", "content": "SELECT COUNT(*) \nFROM social_media.users u\nJOIN social_media.user_settings s ON u.user_id = s.user_id\nWHERE u.is_verified = true AND s.priv...
You are an expert in writing database language. You 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, 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 )
[ { "role": "user", "content": "List the first name, last name, and email of all customers who live in New York or California.", "sql": null }, { "role": "assistant", "content": "SELECT first_name, last_name, email FROM insurance.customers WHERE state IN ('NY', 'CA');", "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 gaming_technology.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry player_id uuid NOT NULL, -- FK linking to the player owning the item item_id uuid NOT NULL, -- FK linking to the item definition quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items) acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability) PRIMARY KEY (inventory_id), -- Optional unique constraint if items are non-stackable or unique instances -- UNIQUE (player_id, item_id) -- Use if quantity is always 1 -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id), -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id) )
[ { "role": "user", "content": "Show the latest time each player acquired any item.", "sql": null }, { "role": "assistant", "content": "SELECT player_id, MAX(acquired_at) AS last_acquired_at FROM gaming_technology.player_inventory GROUP BY player_id;", "sql": null }, { "role": "use...
You are an expert in writing database language. You 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.contracts ( contract_id.text, address.text, abi.text, bytecode.text, deployer_address.text, deployed_at.timestamp, network_id.text, status.text ) CREATE TABLE web3.events ( event_id character varying(64) NOT NULL, -- unique identifier for the event contract_id character varying(64) NOT NULL, -- identifier of the contract emitting the event event_name character varying(128) NOT NULL, -- name of the event data text NOT NULL, -- data payload of the event emitted_at timestamp NOT NULL, -- time when the event was emitted transaction_id character varying(64) NOT NULL, -- identifier of the transaction that triggered the event log_index integer NOT NULL, -- index of the event log in the transaction PRIMARY KEY (event_id) ) CREATE TABLE web3.tokens ( token_id text PRIMARY KEY, contract_address text, token_name text, token_symbol text, decimals int, total_supply numeric ) CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp ) CREATE TABLE web3.users ( user_id text, username text, email text, password_hash text, created_at timestamp )
[ { "role": "user", "content": "Count the number of tokens for each contract address.", "sql": null }, { "role": "assistant", "content": "SELECT contract_address, COUNT(*) AS token_count FROM web3.tokens GROUP BY contract_address;", "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.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 healthcare.appointments ( appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment patient_id character varying(64) NOT NULL, -- FK to patients table doctor_id character varying(64) NOT NULL, -- FK to doctors table appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment duration_minutes integer NOT NULL, -- expected duration in minutes reason text, -- reason for the visit status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show location_id character varying(64), -- FK to a potential locations/clinics table notes text, -- notes related to scheduling created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (appointment_id) )
[ { "role": "user", "content": "List the total number of appointments for each status and also show the latest appointment_time for each status.", "sql": null }, { "role": "assistant", "content": "SELECT status, COUNT(*) AS total_appointments, MAX(appointment_time) AS latest_appointment_time\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 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 healthcare.medical_records ( record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry patient_id character varying(64) NOT NULL, -- FK to patients table appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt) doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record) record_date timestamp with time zone NOT NULL, -- date the record/observation was made chief_complaint text, -- patient's primary reason for visit present_illness_history text, -- detailed history of the current issue past_medical_history text, -- relevant past conditions/surgeries physical_examination_notes text, -- findings from the physical exam assessment text, -- doctor's assessment/diagnosis summary treatment_plan text, -- planned course of action vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )
[ { "role": "user", "content": "List each patient's first and last medical record entries, showing patient_id, earliest_record_id, earliest_record_date, latest_record_id, and latest_record_date.", "sql": null }, { "role": "assistant", "content": "SELECT\n fl.patient_id,\n fr.record_id AS...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure 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 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 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 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 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 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 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 character varying(64) NOT NULL, -- unique identifier for the transfer token_id character varying(64) NOT NULL, -- identifier of the token being transferred from_address character varying(128) NOT NULL, -- address of the sender to_address character varying(128) NOT NULL, -- address of the receiver value numeric(38,14) NOT NULL, -- amount of tokens transferred transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer log_index integer NOT NULL, -- index of the transfer log in the transaction PRIMARY KEY (transfer_id) )
[ { "role": "user", "content": "Find cases where an address received tokens in one transfer and then sent tokens in another. List the receive transfer_id, the send transfer_id, the address, and both transfer values.", "sql": null }, { "role": "assistant", "content": "SELECT recv.transfer_id AS...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE insurance.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 character varying(64) NOT NULL, product_name character varying(150) NOT NULL, product_type character varying(50) NOT NULL, description text, base_premium numeric(10, 2) NOT NULL, coverage_details text, underwriting_rules text, is_active boolean NOT NULL DEFAULT true, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, PRIMARY KEY (product_id) ) 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 me the incident date, estimated loss, and the associated product name for all claims with an estimated loss greater than 20000.", "sql": null }, { "role": "assistant", "content": "SELECT c.incident_date, c.estimated_loss, p.product_name\nFROM insurance.clai...
You are an expert in writing database language. You 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, -- unique identifier for the policy customer_id character varying(64) NOT NULL, -- identifier for the policyholder (FK to customers) product_id character varying(64) NOT NULL, -- identifier for the insurance product (FK to insurance_products) agent_id character varying(64), -- identifier for the agent who sold the policy (FK to agents) policy_number character varying(100) NOT NULL UNIQUE, -- customer-facing policy number start_date date NOT NULL, -- date the policy coverage begins end_date date NOT NULL, -- date the policy coverage ends premium_amount numeric(12, 2) NOT NULL, -- total premium for the policy term coverage_limit numeric(15, 2) NOT NULL, -- maximum amount covered deductible numeric(10, 2) NOT NULL, -- amount customer pays before coverage kicks in status character varying(30) NOT NULL, -- e.g., Active, Expired, Cancelled, Pending issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the policy was issued 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.agents ( agent_id.text, first_name.text, last_name.text, agency_name.text, license_number.text, license_state.text, contact_email.text, contact_phone.text, hire_date.date, termination_date.date, status.text, commission_rate.numeric, manager_id.text ) 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 )
[ { "role": "user", "content": "List all policies that have been cancelled, showing the policy number, cancellation date, and reason.", "sql": null }, { "role": "assistant", "content": "SELECT policy_number, cancellation_date, cancellation_reason FROM insurance.policies WHERE status = 'Cancell...
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 gaming_technology.players ( player_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the player username character varying(100) NOT NULL UNIQUE, -- player's chosen display name email character varying(255) NOT NULL UNIQUE, -- player's email address for login/recovery password_hash text NOT NULL, -- securely hashed password registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the player account was created last_login timestamp with time zone, -- timestamp of the last successful login country_code character(2), -- player's country (ISO 3166-1 alpha-2) status character varying(20) NOT NULL DEFAULT 'active', -- account status (e.g., active, banned, suspended) profile_data jsonb, -- flexible field for avatar url, bio, preferences etc. PRIMARY KEY (player_id) ) 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 ) CREATE TABLE gaming_technology.game_sessions ( session_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game session player_id uuid NOT NULL, -- FK linking to the players table game_id uuid NOT NULL, -- FK linking to the games table server_id uuid, -- FK linking to the servers table (nullable for single-player) start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the session began end_time timestamp with time zone, -- when the session ended (null if ongoing) duration_seconds integer, -- calculated duration of the session in seconds score integer, -- player's score for the session, if applicable session_data jsonb, -- flexible field for session-specific info (e.g., map played, character used) PRIMARY KEY (session_id) -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id), -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id), -- FOREIGN KEY (server_id) REFERENCES gaming_technology.servers(server_id) ) CREATE TABLE gaming_technology.servers ( server_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game server instance game_id uuid NOT NULL, -- FK linking to the game this server hosts server_name character varying(150), -- display name for the server region character varying(50) NOT NULL, -- geographical region (e.g., us-east-1, eu-west-2) ip_address character varying(45), -- IP address (IPv4 or IPv6) port integer, -- network port number current_players integer NOT NULL DEFAULT 0, -- number of players currently connected max_players integer NOT NULL, -- maximum player capacity status character varying(30) NOT NULL DEFAULT 'offline', -- server status (e.g., online, offline, maintenance) last_heartbeat timestamp with time zone, -- last time the server reported its status PRIMARY KEY (server_id) -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id) ) CREATE TABLE gaming_technology.achievements ( achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to name character varying(150) NOT NULL, -- name of the achievement description text NOT NULL, -- how to unlock the achievement icon_url character varying(255), -- URL for the achievement's icon points integer DEFAULT 0, -- points awarded for unlocking (optional) hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked PRIMARY KEY (achievement_id) -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id) ) CREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for this unlock instance player_id uuid NOT NULL, -- FK linking to the player who unlocked it achievement_id uuid NOT NULL, -- FK linking to the achievement definition unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the achievement was unlocked PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) -- Ensure a player can only unlock an achievement once -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id), -- FOREIGN KEY (achievement_id) REFERENCES gaming_technology.achievements(achievement_id) ) CREATE TABLE gaming_technology.in_game_items ( item_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the item definition game_id uuid NOT NULL, -- FK linking to the game this item belongs to item_name character varying(150) NOT NULL, -- name of the item item_type character varying(50) NOT NULL, -- type (e.g., Cosmetic, Consumable, Weapon, Armor) description text, -- description of the item rarity character varying(30), -- item rarity (e.g., Common, Rare, Epic, Legendary) cost_currency character varying(10), -- currency code if purchasable (e.g., USD, EUR, GOLD) cost_amount numeric(12, 2), -- price if purchasable attributes jsonb, -- flexible field for item stats or properties PRIMARY KEY (item_id) -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id) ) CREATE TABLE gaming_technology.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry player_id uuid NOT NULL, -- FK linking to the player owning the item item_id uuid NOT NULL, -- FK linking to the item definition quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items) acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability) PRIMARY KEY (inventory_id), -- Optional unique constraint if items are non-stackable or unique instances -- UNIQUE (player_id, item_id) -- Use if quantity is always 1 -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id), -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id) )
[ { "role": "user", "content": "Show usernames of players who own items of 'Legendary' rarity.", "sql": null }, { "role": "assistant", "content": "SELECT DISTINCT T1.username FROM players AS T1 JOIN player_inventory AS T2 ON T1.player_id = T2.player_id JOIN in_game_items AS T3 ON T2.item_id = ...
You are an expert in writing database language. You 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 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) )
[ { "role": "user", "content": "Find all service locations in the city of 'Albany' that are accessible. Show their IDs, names, and contact phone numbers along with their address.", "sql": null }, { "role": "assistant", "content": "SELECT location_id, location_name, contact_phone, address FROM ...
You are an expert in writing database language. You 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, license_plate text, vin text, make text, model text, year integer, type text, capacity integer, fuel_type text, status text, depot_id text, acquisition_date date )
[ { "role": "user", "content": "Show each vehicle's ID along with another vehicle's ID where they share the same make but have different models. Sort by the first vehicle_id.", "sql": null }, { "role": "assistant", "content": "SELECT v1.vehicle_id AS vehicle_a, v2.vehicle_id AS vehicle_b\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 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 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 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 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.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text ) CREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, -- unique identifier for the document instance application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly) citizen_id character varying(64) NOT NULL, -- FK to citizens table document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path) upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected verified_by_employee_id character varying(64), -- FK to employees table verification_timestamp timestamp, PRIMARY KEY (document_id) ) CREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) ) CREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment citizen_id character varying(64) NOT NULL, -- FK to citizens table employee_id character varying(64), -- FK to employees table (optional, if assigned) location_id character varying(64), -- FK to service_locations table (if physical) service_id character varying(64), -- FK to services table (optional, if related to specific service) scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, -- reason for the appointment status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show booking_method character varying(50), -- e.g., Online, Phone, In-Person created_at timestamp NOT NULL, -- when the appointment was booked notes text, PRIMARY KEY (appointment_id) ) 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": "For each service category, show the category and the number of distinct citizens who have scheduled at least one appointment for a service in that category. Order the results by the number of citizens in descending order.", "sql": null }, { "role": "assistant", ...
You are an expert in writing database language. You 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.contracts ( contract_id character varying(64) NOT NULL, address character varying(128) NOT NULL, abi text NOT NULL, bytecode text NOT NULL, deployer_address character varying(128) NOT NULL, deployed_at timestamp NOT NULL, network_id character varying(64) NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (contract_id) )
[ { "role": "user", "content": "List all contracts with status 'active' and include their deployment timestamp and network ID.", "sql": null }, { "role": "assistant", "content": "SELECT address, deployed_at, network_id FROM web3.contracts WHERE status = 'active';", "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 project_fundraising_record ( id character varying(32) NOT NULL, -- fundraising record id project_id character varying(32) NOT NULL, -- the invested project's id project_name character varying(128) NOT NULL, -- name of the invested project rounds_name character varying(32), -- name of the fundraising round investment_value numeric(38,14), -- amount of the fundraising in USD investment_date character varying(128), -- the date of the investment happened introduction character varying(128), -- the introduction of the invested project valuation numeric(38,14), -- the valuation of the project in USD when invested ) CREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, -- the id of the token token_name character varying(100) NOT NULL, -- the token's name token_symbol character varying(100) NOT NULL, -- the token's symbol token_address character varying(100) NOT NULL, -- the token's address chain text, -- the chain that the token resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours price_change_percentage_7d double precision, -- change in value divided by the absolute price value of the original token price in 7 days highest_price_24h double precision, -- the highest price of the token in 24 hours lowest_price_24h double precision, -- the lowest price of the token in 24 hours market_cap double precision, -- the market cap of the token market_cap_rank bigint, -- the rank of the token market cap in desc market_cap_change_percentage_24h text, -- the percentage of market cap changes in 24 hours total_volume text, -- the trade volum of the token both in decentralized exchange(DEX) and centralized exchange(CEX) narrative text, -- the category or narrative of the token trend_rank biging, -- the trending rank of the token, value 1 expresses the most popular token. ,PRIMARY KEY (coin_id, chain) ) 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 token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric ) 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_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, 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 projects that raised funds in 2023 have an associated token, and what are their fundraising amounts, token symbols, and token market caps?", "sql": null }, { "role": "assistant", "content": "SELECT T1.project_name, T1.investment_value, T2.token_symbol, 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 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.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )
[ { "role": "user", "content": "How many reservations have been booked each month in 2023?", "sql": null }, { "role": "assistant", "content": "SELECT DATE_TRUNC('month', created_at) AS month,\n COUNT(*) AS reservation_count\nFROM hospitality_technology.reservations\nWHERE created_at >= '...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure Collection 'inspections'. Document structure: { _id: <ObjectId (or inspection_id)>, inspection_id: String, build_id: String (reference), component_id: String (reference, optional), step_id: String (reference, optional), inspection_type: String, inspector_employee_id: String (reference), inspection_timestamp: ISODate, result: String, remarks: String }. Required: inspection_id, build_id, inspection_type, inspector_employee_id, inspection_timestamp, result. Indexes on build_id, component_id, step_id, inspector_employee_id, result.
[ { "role": "user", "content": "我想查看所有检查记录中检查员的ID和检查结果,同时统计每个检查员的检查次数。", "sql": null }, { "role": "assistant", "content": "db.inspections.aggregate([\n {\n $group: {\n _id: '$inspector_employee_id',\n total_inspections: { $count: {} },\n results: { $push: '$result' }\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 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 legal_services.documents ( document_id character varying(64) NOT NULL, -- unique identifier for the document case_id character varying(64) NOT NULL, -- FK to cases table document_name character varying(255) NOT NULL, -- name of the document file document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence storage_path text NOT NULL, -- path or reference to the document storage location uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it) upload_timestamp timestamp NOT NULL, -- time the document was uploaded version integer DEFAULT 1, -- document version number description text, -- brief description or notes about the document PRIMARY KEY (document_id) )
[ { "role": "user", "content": "Find pairs of documents in the same case where one document is version 1 and the other is the highest version for that document_name, showing case_id, document_name, version1, latest_version, version1_upload_timestamp, and latest_upload_timestamp.", "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 token_dexpool_info (", "pair_address character varying(512) NOT NULL, -- the id of dexpool", "token_name character varying(100) NOT NULL, -- the name of the token in the dexpool", "token_symbol character varying(100) NOT NULL, -- the token's symbol", "chain text, -- the chain that the dexpool resides", "price double precision, -- the current price of the token", "price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour", "price_change_percentage_6h double precision, -- change in value divided by the absolute price value of the original token price in 6 hours", "price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours", "makers_24h double precision, -- the makers of the dex pool in 24 hours", "volume_24h double precision, -- the trade volume of the dex pool in 24 hours", "liquidity double precision, -- the liquidity of the dex pool", "market_cap double precision, -- the market cap of the token", "trend_rank bigint, -- the rank of token in the dex pool of recent trending, value 1 expresses the most popular token.", ",PRIMARY KEY (pair_address, chain);"
[ { "role": "user", "content": "For each chain, find the token with the highest price and the token with the lowest price. List chain, high_price_token, max_price, low_price_token, and min_price.", "sql": null }, { "role": "assistant", "content": "WITH max_prices AS (\n SELECT chain,\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 financial_services.loans ( loan_id character varying(64) NOT NULL, -- unique identifier for the loan, could be same as account_id account_id character varying(64) NOT NULL UNIQUE, -- link to the general account record loan_type character varying(50) NOT NULL, -- e.g., Mortgage, Personal, Auto, Student principal_amount numeric(19, 4) NOT NULL, -- original loan amount current_principal_balance numeric(19, 4) NOT NULL, -- remaining principal interest_rate numeric(6, 4) NOT NULL, -- annual interest rate term_months integer NOT NULL, -- loan term in months origination_date date NOT NULL, -- date the loan was disbursed maturity_date date NOT NULL, -- date the loan is due to be fully repaid monthly_payment numeric(12, 4), -- scheduled monthly payment amount collateral_description text, -- description of collateral, if secured loan status character varying(32) NOT NULL, -- e.g., Active, Paid Off, Defaulted PRIMARY KEY (loan_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id) )
[ { "role": "user", "content": "Retrieve all pairs of loans for the same account where both loans are active and have different loan types. Show account_id, loan_id as loan_a, loan_type as type_a, loan_id as loan_b, and loan_type as type_b.", "sql": null }, { "role": "assistant", "content": "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 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 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 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 legal_services.invoices ( invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number client_id character varying(64) NOT NULL, -- FK to clients table case_id character varying(64), -- FK to cases table (optional, could be general retainer) issue_date date NOT NULL, -- date the invoice was generated due_date date NOT NULL, -- date the payment is due total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void payment_date timestamp, -- date the invoice was fully paid (nullable) notes text, -- additional notes or terms on the invoice created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (invoice_id) )
[ { "role": "user", "content": "Show me all invoice numbers together with the client IDs and related case IDs for invoices issued after March 1st, 2024.", "sql": null }, { "role": "assistant", "content": "SELECT invoice_number, client_id, case_id FROM legal_services.invoices WHERE issue_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 social_media.posts ( post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, visibility character varying(20) NOT NULL DEFAULT 'public', location_lat numeric(9,6), location_lon numeric(9,6), PRIMARY KEY (post_id) ) 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.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp ) CREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp ) 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, -- unique identifier for the post-hashtag link post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id) hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id) PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post ) CREATE TABLE social_media.messages ( message_id text PRIMARY KEY, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp ) 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 text PRIMARY KEY, 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": "Show conversations that are group chats and have more than 5 participants. List the conversation_id and group_name.", "sql": null }, { "role": "assistant", "content": "SELECT c.conversation_id, c.group_name FROM social_media.conversations AS c JOIN 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 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.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )
[ { "role": "user", "content": "Can you show me all pairs of customers living in the same city but with different last names? Show both customer IDs, both full names, and their city.", "sql": null }, { "role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, CONCAT(a.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 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 }, { "...