Dataset Viewer
Auto-converted to Parquet Duplicate
system
stringlengths
315
7.62k
conversations
listlengths
2
8
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE web3.token_transfers ( transfer_id text PRIMARY KEY, token_id text, from_address text, to_address text, value numeric, transaction_id text, log_index int )
[ { "role": "user", "content": "List the top 5 addresses that have received the most token transfers." }, { "role": "assistant", "content": "SELECT to_address, COUNT(*) AS transfer_count FROM web3.token_transfers GROUP BY to_address ORDER BY transfer_count DESC LIMIT 5;" }, { "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 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": "Can you help me retrieve all inspection records for a specific build ID, including the inspection type, result, and the timestamp of the inspection, along with the associated component ID if available?" }, { "role": "assistant", "content": "db.inspections.find({ bui...
You are an expert in writing database language. You 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.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text )
[ { "role": "user", "content": "For each application that has at least one failed notification, provide the application ID, the total number of notifications received for that application, and the count of failed notifications." }, { "role": "assistant", "content": "SELECT application_id, COUNT(*)...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE blockchain.blocks ( block_id.text, previous_block_id.text, timestamp.timestamp, nonce.integer, merkle_root.text, difficulty.integer ) CREATE TABLE blockchain.transactions ( transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction block_id character varying(64) NOT NULL, -- identifier of the block containing the transaction sender_address character varying(128) NOT NULL, -- address of the sender receiver_address character varying(128) NOT NULL, -- address of the receiver amount numeric(38,14) NOT NULL, -- amount transferred timestamp timestamp NOT NULL, -- time when the transaction was created signature text NOT NULL, -- digital signature of the transaction PRIMARY KEY (transaction_id) ) CREATE TABLE blockchain.addresses ( address_id character varying(128) NOT NULL, public_key text NOT NULL, balance numeric(38,14) NOT NULL, PRIMARY KEY (address_id) ) CREATE TABLE blockchain.wallets ( wallet_id.text, user_id.text, address_id.text, private_key.text ) CREATE TABLE blockchain.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, PRIMARY KEY (user_id) ) CREATE TABLE blockchain.smart_contracts ( contract_id character varying(64) NOT NULL, creator_address character varying(128) NOT NULL, code text NOT NULL, timestamp timestamp NOT NULL, PRIMARY KEY (contract_id) )
[ { "role": "user", "content": "Retrieve the username and email for every user, along with the wallet ID and associated address ID for any wallets they own." }, { "role": "assistant", "content": "SELECT\n u.username,\n u.email,\n w.wallet_id,\n w.address_id\nFROM\n blockchain.users ...
You are an expert in writing database language. You 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 text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool ) CREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric ) 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 text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp ) CREATE TABLE social_media.post_hashtags ( post_hashtag_id text PRIMARY KEY, post_id text, hashtag_id text ) CREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text ) 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.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 ) CREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )
[ { "role": "user", "content": "Show me all users who have never commented on any post." }, { "role": "assistant", "content": "SELECT u.user_id, u.username\nFROM social_media.users u\nLEFT JOIN social_media.comments c ON u.user_id = c.user_id\nWHERE c.comment_id IS 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 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": "Show me the usernames of users who have joined more than one conversation, and list the conversation IDs for each user." }, { "role": "assistant", "content": "SELECT user_id, ARRAY_AGG(conversation_id) AS conversation_ids\nFROM social_media.conversation_participants...
You are an expert in writing database language. You 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": "For each exchange, compute the percentage change in total USD value of its holdings between snapshots '2023-01-01 00:00:00' and '2023-02-01 00:00:00'. Show exchange, chain, value_jan, value_feb, and pct_change." }, { "role": "assistant", "content": "SELECT t1.exchan...
You are an expert in writing database language. You 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, username text, email text, password_hash text, registration_date timestamp with time zone, last_login timestamp with time zone, country_code text, status text, profile_data jsonb ) CREATE TABLE gaming_technology.developers ( developer_id uuid, name text, country text, founded_year integer, website text, created_at timestamp with time zone ) CREATE TABLE gaming_technology.game_sessions ( session_id uuid, player_id uuid, game_id uuid, server_id uuid, start_time timestamp with time zone, end_time timestamp with time zone, duration_seconds integer, score integer, session_data jsonb ) CREATE TABLE gaming_technology.achievements ( achievement_id uuid, game_id uuid, name text, description text, icon_url text, points integer, hidden boolean ) CREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb ) CREATE TABLE gaming_technology.player_inventory ( inventory_id uuid, player_id uuid, item_id uuid, quantity integer, acquired_at timestamp with time zone, instance_data jsonb )
[ { "role": "user", "content": "Show the usernames of players and a count of how many different item types they have in their inventory." }, { "role": "assistant", "content": "SELECT T1.username, count(DISTINCT T3.item_type) FROM gaming_technology.players AS T1 JOIN gaming_technology.player_invent...
You are an expert in writing database language. You 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.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp ) 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) ) 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 ) CREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text ) CREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )
[ { "role": "user", "content": "Show the names of all insurance plans and the number of patients enrolled in each plan." }, { "role": "assistant", "content": "SELECT ip.plan_name, COUNT(pi.patient_id) AS enrolled_patients FROM healthcare.insurance_plans ip JOIN healthcare.patient_insurance pi ON i...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE 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": "List all claim IDs that have both an 'Accident Report' and a 'Damage Assessment' document type." }, { "role": "assistant", "content": "SELECT claim_id\nFROM insurance.claim_documents\nWHERE document_type IN ('Accident Report', 'Damage Assessment')\nGROUP BY claim_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.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 ) 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.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date ) CREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text ) CREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )
[ { "role": "user", "content": "List all drivers whose licenses expire in the next 30 days, along with their contact information." }, { "role": "assistant", "content": "SELECT driver_id, first_name, last_name, license_number, license_expiry_date, contact_number, email FROM transportation.drivers W...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE insurance.insurance_products ( product_id 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 text PRIMARY KEY, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )
[ { "role": "user", "content": "Show me the total premium paid by each customer for insurance products where the base premium is less than 2000. I want to see customer_id, product_id, and total_premium_paid." }, { "role": "assistant", "content": "SELECT pp.customer_id, ip.product_id, SUM(pp.amount...
You are an expert in writing database language. You 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.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": "How many distinct users have uploaded claim documents of type 'ACCIDENT_REPORT'?" }, { "role": "assistant", "content": "SELECT COUNT(DISTINCT uploaded_by) FROM insurance.claim_documents WHERE document_type = 'ACCIDENT_REPORT';" } ]
You are an expert in writing database language. You 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.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": "Show me claim_id, incident_date, policy_number, and customer full name for all claims where settlement_amount is null." }, { "role": "assistant", "content": "SELECT c.claim_id, c.incident_date, p.policy_number, cu.first_name || ' ' || cu.last_name AS customer_full_n...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE insurance.agents ( agent_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, agency_name character varying(150), license_number character varying(100) NOT NULL UNIQUE, license_state character varying(50) NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(30), hire_date date, termination_date date, status character varying(20) NOT NULL DEFAULT 'Active', commission_rate numeric(5, 4) NOT NULL DEFAULT 0.05, manager_id character varying(64), PRIMARY KEY (agent_id) )
[ { "role": "user", "content": "Retrieve the agent ID, first and last name, agency name, and their manager's first and last name for every agent." }, { "role": "assistant", "content": "SELECT a.agent_id, a.first_name AS agent_first_name, a.last_name AS agent_last_name, a.agency_name, m.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 smart_money_token_inflow (", "token_address character varying(100) NOT NULL, -- the token's address", "token_symbol character varying(100), -- the tokens's symbol", "token_amount numeric(38,2), -- the absolute value of the amount if user bought minus the amount user sold of this token", "usd_value numeric(38,2), -- the absolute usd value of the bought token minus sold token", "avg_price numeric(38,6), -- the average cost price of user spent on this token", "type int, -- the direction of the trade on this token. 1 means buying, 2 means selling", "address_amount integer, -- the amount of the user bought this token", "narrative character varying(100), -- the category or narrative of the token", "chain character varying(100), -- the chain that the token resides", ",PRIMARY KEY (token_address, chain)",
[ { "role": "user", "content": "What are the top 3 narratives with the highest total USD buy value?" }, { "role": "assistant", "content": "SELECT narrative,\n SUM(usd_value) AS total_buy_usd\nFROM smart_money_token_inflow\nWHERE type = 1\nGROUP BY narrative\nORDER BY total_buy_usd DESC\nLIMI...
You are an expert in writing database language. You 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.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 )
[ { "role": "user", "content": "Which services charge more than the average standard fee of their category? Show the service name, its fee, and the average fee for that category." }, { "role": "assistant", "content": "SELECT\n s.service_name,\n s.standard_fee,\n avg_fees.avg_fee\nFROM governmen...
You are an expert in writing database language. You 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(6) NOT NULL, block_number bigint NOT NULL, transaction_hash varchar NOT NULL, transaction_index bigint NOT NULL, from_address varchar NOT NULL, contract_address varchar NOT NULL, symbol varchar NOT NULL, total_supply varchar NOT NULL, name varchar NOT NULL, decimals bigint NOT NULL, is_erc20 integer NOT NULL, is_erc721 integer NOT NULL, is_erc1155 integer NOT NULL, is_proxy integer NOT NULL, extra_info varchar NOT NULL, pk integer NOT NULL ) CREATE TABLE erc20_balances ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk varchar ) CREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer ) CREATE TABLE sui_coins_metadata ( object_id varchar NOT NULL, coin_type varchar NOT NULL, status varchar NOT NULL, decimals bigint NOT NULL, description varchar NOT NULL, icon_url varchar NOT NULL, symbol varchar NOT NULL, name varchar NOT NULL ) 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.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer ) CREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract address varchar(42) NOT NULL, -- address fields for the functionType in contract decimals bigint NOT NULL, -- decimals fields for the functionType in contract symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract price real NOT NULL, -- price fields for the functionType in contract timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract ) CREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal ) 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 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(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table) block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table) tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table) tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table) tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription max_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription lim decimal(38,0) NOT NULL, -- Mint limit: limit per inscription wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint dec integer NOT NULL, -- Decimal for minimum divie creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table) ) CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table) block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table) tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table) tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table) log_index integer NOT NULL, -- Index of the log within the transaction type varchar(20) NOT NULL, -- Operation: Type of event (deploy, mint, transfer, list) tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription id varchar(255) NOT NULL, -- Unique identifier of the inscription amt decimal(38,0) NOT NULL, -- Amount to mint: States the amount of the inscription to operation. When operation is mint, has to be less or equal to "lim" from_address varchar(62) NOT NULL, -- Address sending the inscription to_address varchar(62) NOT NULL -- Address receiving the inscription ) 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(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(20) 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, minted decimal(38,0) NOT NULL, holders decimal(38,0) NOT NULL, txs decimal(38,0) NOT NULL, updated_timestamp timestamp(3) NOT NULL, completed_timestamp timestamp(3) NOT NULL, id varchar(255) NOT NULL )
[ { "role": "user", "content": "Show me wallet addresses that hold more than 1000 of any ERC20 token, along with the token symbol and amount." }, { "role": "assistant", "content": "SELECT eb.wallet_address, tm.symbol, eb.amount FROM erc20_balances eb JOIN token_metas tm ON eb.contract_address = tm...
You are an expert in writing database language. You 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": "Show the latest version number of each document_name for every case." }, { "role": "assistant", "content": "SELECT case_id,\n document_name,\n MAX(version) AS latest_version\nFROM legal_services.documents\nGROUP BY case_id, document_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 social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean ) CREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric ) CREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp ) CREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text ) CREATE TABLE social_media.messages ( message_id.text, conversation_id.text, sender_user_id.text, content.text, media_url.text, media_type.text, sent_at.timestamp, read_at.timestamp ) 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 creation time of posts made by users who have a private profile." }, { "role": "assistant", "content": "SELECT T1.content, T1.created_at FROM social_media.posts AS T1 JOIN social_media.users AS T2 ON T1.user_id = T2.user_id JOIN social_media.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 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": "Find pairs of claim documents for the same claim where the upload time difference is less than 5 minutes. List the document IDs of the pairs and the claim ID." }, { "role": "assistant", "content": "SELECT a.document_id AS document1_id, b.document_id AS document2_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 healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp ) CREATE TABLE healthcare.doctors ( doctor_id text PRIMARY KEY, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp ) CREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) ) CREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) ) CREATE TABLE healthcare.insurance_plans ( plan_id text PRIMARY KEY, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text ) CREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )
[ { "role": "user", "content": "I want to see a list of all patients, including their full name and date of birth, along with every doctor they have been diagnosed by and that doctor's specialty." }, { "role": "assistant", "content": "SELECT p.patient_id, p.first_name || ' ' || p.last_name AS pati...
You are an expert in writing database language. You 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 text PRIMARY KEY, invoice_number text UNIQUE, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )
[ { "role": "user", "content": "Show me pairs of invoice numbers for the same case." }, { "role": "assistant", "content": "SELECT T1.invoice_number, T2.invoice_number, T1.case_id FROM legal_services.invoices AS T1 JOIN legal_services.invoices AS T2 ON T1.case_id = T2.case_id AND T1.invoice_id <> T...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE 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, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text ) CREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text ) 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 nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer ) CREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text ) CREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text ) CREATE TABLE nft_collections ( blockchain.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer ) 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, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal ) CREATE TABLE token_info ( 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 ( 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_activities_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text ) CREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal ) CREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )
[ { "role": "user", "content": "List all SUI coins that have status 'exists' in both `sui_coins` and `sui_coins_metadata`. Show their `coin_type`, `balance`, and `owner`." }, { "role": "assistant", "content": "SELECT sc.coin_type, sc.balance, sc.owner FROM sui_coins sc JOIN sui_coins_metadata scm ...
You are an expert in writing database language. You 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.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp ) CREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) ) CREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean ) CREATE TABLE healthcare.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 ) CREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text ) CREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )
[ { "role": "user", "content": "Show me the top 5 most recent medical records with a fever recorded. Return record_id, patient_id, record_date, and the temperature value from vitals." }, { "role": "assistant", "content": "SELECT record_id,\n patient_id,\n record_date,\n vitals->>...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp ) CREATE TABLE hospitality_technology.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.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp ) CREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp ) CREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text ) CREATE TABLE hospitality_technology.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text ) CREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )
[ { "role": "user", "content": "Retrieve all reservations with status 'Cancelled' and show the reservation_id, property_name, and room_type_name." }, { "role": "assistant", "content": "SELECT res.reservation_id,\n p.property_name,\n rt.type_name AS room_type_name\nFROM hospitality_tech...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )
[ { "role": "user", "content": "Show all appointments that have 'follow-up' mentioned in the notes field." }, { "role": "assistant", "content": "SELECT * FROM healthcare.appointments WHERE notes LIKE '%follow-up%';" } ]
You are an expert in writing database language. You 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, -- unique identifier for the patient first_name character varying(100) NOT NULL, -- patient's first name last_name character varying(100) NOT NULL, -- patient's last name date_of_birth date NOT NULL, -- patient's date of birth gender character varying(10), -- patient's gender (e.g., Male, Female, Other) address text, -- patient's home address phone_number character varying(20), -- patient's phone number email character varying(128) UNIQUE, -- patient's email address emergency_contact_name character varying(200), -- name of emergency contact emergency_contact_phone character varying(20), -- phone number of emergency contact 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 (patient_id) ) CREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, -- unique identifier for the doctor first_name character varying(100) NOT NULL, -- doctor's first name last_name character varying(100) NOT NULL, -- doctor's last name specialty character varying(100) NOT NULL, -- doctor's medical specialty license_number character varying(50) UNIQUE NOT NULL, -- doctor's medical license number phone_number character varying(20), -- doctor's contact phone email character varying(128) UNIQUE, -- doctor's contact email hospital_affiliation_id character varying(64), -- FK to hospitals table (optional) created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) ) CREATE TABLE healthcare.appointments ( appointment_id character varying(64) NOT NULL, -- 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) ) 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) ) CREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, -- unique identifier for the medication type medication_name character varying(255) NOT NULL, -- common or brand name generic_name character varying(255), -- generic chemical name manufacturer character varying(100), -- drug manufacturer ndc_code character varying(20) UNIQUE, -- National Drug Code (optional but useful) description text, -- description of the medication PRIMARY KEY (medication_id) ) CREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, -- unique identifier for the prescription record_id character varying(64) NOT NULL, -- FK linking to the medical record where it was prescribed patient_id character varying(64) NOT NULL, -- FK to patients table doctor_id character varying(64) NOT NULL, -- FK to prescribing doctor medication_id character varying(64) NOT NULL, -- FK to medications table dosage character varying(100) NOT NULL, -- e.g., '100mg', '1 tablet' frequency character varying(100) NOT NULL, -- e.g., 'Once daily', 'Twice a day with meals' route character varying(50), -- e.g., 'Oral', 'Topical', 'Intravenous' start_date date NOT NULL, -- date prescription begins end_date date, -- date prescription ends (if applicable) quantity_dispensed numeric(10,2), -- amount dispensed (e.g., number of tablets) refills_allowed integer NOT NULL DEFAULT 0, -- number of allowed refills prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) ) CREATE TABLE healthcare.insurance_plans ( plan_id character varying(64) NOT NULL, -- unique identifier for the insurance plan plan_name character varying(200) NOT NULL, -- name of the insurance plan insurance_provider character varying(100) NOT NULL, -- name of the insurance company plan_type character varying(50), -- e.g., PPO, HMO, EPO contact_phone character varying(20), -- provider contact number website character varying(255), -- provider website PRIMARY KEY (plan_id) ) CREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link patient_id character varying(64) NOT NULL, -- FK to patients table plan_id character varying(64) NOT NULL, -- FK to insurance_plans table policy_number character varying(100) NOT NULL, -- patient's policy number group_number character varying(100), -- group number, if applicable subscriber_name character varying(200), -- name of the primary policy holder effective_date date NOT NULL, -- date the coverage begins expiration_date date, -- date the coverage ends (if known) is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice )
[ { "role": "user", "content": "Retrieve each patient's full name, total number of appointments, and date of their most recent appointment." }, { "role": "assistant", "content": "SELECT p.first_name || ' ' || p.last_name AS patient_name, COUNT(a.appointment_id) AS appointment_count, MAX(a.appointm...
You are an expert in writing database language. You 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": "What is the average quantity_dispensed per route for prescriptions with start_date in 2024? Return route and avg_quantity." }, { "role": "assistant", "content": "SELECT route,\n AVG(quantity_dispensed) AS avg_quantity\nFROM healthcare.prescriptions\nWHERE star...
You are an expert in writing database language. You 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) )
[ { "role": "user", "content": "Show me all assets whose symbol starts with 'BTC' or 'ETH', along with their full names and types." }, { "role": "assistant", "content": "SELECT asset_id, name, symbol, type FROM trading_platform.assets WHERE symbol LIKE 'BTC%' OR symbol LIKE 'ETH%';" } ]
You are an expert in writing database language. You 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, -- 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 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 ) 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.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp ) 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 ) CREATE TABLE hospitality_technology.payments ( payment_id.text, reservation_id.text, guest_id.text, bill_id.text, amount.numeric, currency_code.text, payment_method.text, card_type.text, card_last_four.text, transaction_ref.text, payment_timestamp.timestamp, status.text, staff_id_processed.text, notes.text )
[ { "role": "user", "content": "Calculate the average length of stay in days for completed reservations for each property." }, { "role": "assistant", "content": "SELECT p.property_id,\n p.property_name,\n AVG(res.check_out_date - res.check_in_date) AS avg_stay_days\nFROM hospitality_te...
You are an expert in writing database language. You 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, username text, email text, password_hash text, created_at timestamp ) 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 ) CREATE TABLE trading_platform.trades ( trade_id text, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp ) CREATE TABLE trading_platform.assets ( asset_id text, name text, symbol text, type text ) CREATE TABLE trading_platform.utxos ( utxo_id text, transaction_id text, output_index integer, address text, amount numeric, spent boolean ) CREATE TABLE trading_platform.dapps ( dapp_id text, name text, description text, url text ) CREATE TABLE trading_platform.peers ( peer_id text, ip_address text, port integer, last_seen timestamp ) CREATE TABLE trading_platform.kyc_audit ( kyc_audit_id text, user_id text, status text, reviewed_at timestamp ) CREATE TABLE trading_platform.logs ( log_id text, user_id text, action text, details text, logged_at timestamp ) CREATE TABLE trading_platform.notifications ( notification_id text, user_id text, message text, sent_at timestamp, read_at timestamp )
[ { "role": "user", "content": "List the user ID and username for users who have placed orders for assets of type 'cryptocurrency'." }, { "role": "assistant", "content": "SELECT DISTINCT T1.user_id, T1.username FROM trading_platform.users AS T1 JOIN trading_platform.orders AS T2 ON T1.user_id = T2...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE 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": "Show me all documents that have a version greater than 2 and include the document name, upload timestamp, and description." }, { "role": "assistant", "content": "SELECT document_id, document_name, upload_timestamp, description FROM legal_services.documents WHERE ver...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )
[ { "role": "user", "content": "List all failed payments (status = 'failed') with their reservation IDs and amounts, ordered by the payment timestamp." }, { "role": "assistant", "content": "SELECT payment_id, reservation_id, amount, payment_timestamp FROM hospitality_technology.payments WHERE stat...
You are an expert in writing database language. You 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.trades ( trade_id.text, order_id.text, buyer_id.text, seller_id.text, asset_id.text, quantity.numeric, price.numeric, traded_at.timestamp ) CREATE TABLE trading_platform.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean ) CREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text ) CREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp ) CREATE TABLE trading_platform.logs ( log_id.text, user_id.text, action.text, details.text, logged_at.timestamp )
[ { "role": "user", "content": "List all log entries associated with users who have participated in any trade, showing the log details and the trade ID." }, { "role": "assistant", "content": "SELECT T1.log_id, T1.action, T1.details, T1.logged_at, T2.trade_id, T2.buyer_id, T2.seller_id FROM logs 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 legal_services.lawyers ( lawyer_id.text, first_name.text, last_name.text, bar_number.text, firm_id.text, email.text, phone.text, specialization.text, hire_date.timestamp, is_partner.boolean ) CREATE TABLE legal_services.law_firms ( firm_id.text, firm_name.text, address.text, phone.text, website.text, founded_date.date, managing_partner_id.text ) CREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text ) CREATE TABLE legal_services.time_entries ( entry_id.text, case_id.text, lawyer_id.text, date_worked.date, hours_spent.numeric, billing_rate.numeric, description.text, is_billable.boolean, is_billed.boolean, invoice_id.text, created_at.timestamp )
[ { "role": "user", "content": "Show me case number, case name, and the lead lawyer's full name for all cases in the 'State Court' jurisdiction." }, { "role": "assistant", "content": "SELECT T1.case_number, T1.case_name, T2.first_name, T2.last_name FROM cases AS T1 JOIN lawyers AS T2 ON T1.lead_la...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) ) CREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )
[ { "role": "user", "content": "List the number of appointments for each booking method." }, { "role": "assistant", "content": "SELECT\n a.booking_method,\n COUNT(*) AS appointment_count\nFROM appointments a\nGROUP BY a.booking_method;" }, { "role": "user", "content": "Filter this to...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, -- unique identifier for the medication type medication_name character varying(255) NOT NULL, -- common or brand name generic_name character varying(255), -- generic chemical name manufacturer character varying(100), -- drug manufacturer ndc_code character varying(20) UNIQUE, -- National Drug Code (optional but useful) description text, -- description of the medication PRIMARY KEY (medication_id) )
[ { "role": "user", "content": "List the medication_id, medication_name, and description for all medications whose generic_name starts with 'A'." }, { "role": "assistant", "content": "SELECT medication_id, medication_name, description\nFROM healthcare.medications\nWHERE generic_name LIKE '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 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) )
[ { "role": "user", "content": "For each patient, find their latest medical record and show patient_id, latest_record_id, and record_date." }, { "role": "assistant", "content": "SELECT a.patient_id,\n a.record_id AS latest_record_id,\n a.record_date\nFROM healthcare.medical_records a\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 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": "Retrieve a list of all patient insurance policies, showing the subscriber name and the name of the insurance provider for the plan." }, { "role": "assistant", "content": "SELECT T1.subscriber_name, T2.insurance_provider FROM healthcare.patient_insurance AS T1 JOIN h...
You are an expert in writing database language. You 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": "List the names of all DApps whose description contains the word 'auction' along with the user IDs of anyone who has had a KYC audit." }, { "role": "assistant", "content": "SELECT d.name AS dapp_name, k.user_id\nFROM trading_platform.dapps d\nJOIN trading_platform.ky...
You are an expert in writing database language. You 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) )
[ { "role": "user", "content": "Get the usernames of users who have created any public posts, and count how many public posts each user has made. Order the results by the post count in descending order." }, { "role": "assistant", "content": "SELECT u.username, COUNT(p.post_id) AS public_post_count...
You are an expert in writing database language. You 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.securities ( security_id character varying(64) NOT NULL, -- unique identifier for the security ticker_symbol character varying(20) NOT NULL UNIQUE, -- stock ticker or fund symbol isin_code character varying(12) UNIQUE, -- International Securities Identification Number cusip_code character varying(9) UNIQUE, -- CUSIP number security_name text NOT NULL, -- full name of the security security_type character varying(50) NOT NULL, -- e.g., Stock, Bond, ETF, Mutual Fund, Option, Future exchange character varying(50), -- primary exchange where traded (e.g., NYSE, NASDAQ) currency character varying(3) NOT NULL, -- currency the security is denominated in issuer_name character varying(255), -- name of the issuing entity sector character varying(100), -- industry sector last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (security_id) ) CREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, -- auto-incrementing primary key security_id character varying(64) NOT NULL, -- identifier for the security data_timestamp timestamp NOT NULL, -- timestamp for the data point (e.g., end of day, intraday) open_price numeric(19, 8), -- opening price for the period high_price numeric(19, 8), -- highest price during the period low_price numeric(19, 8), -- lowest price during the period close_price numeric(19, 8) NOT NULL, -- closing price for the period adjusted_close_price numeric(19, 8), -- closing price adjusted for dividends and splits volume bigint, -- trading volume during the period source character varying(50), -- source of the market data (e.g., Bloomberg, Refinitiv) PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), -- Ensure unique data point per security per time FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )
[ { "role": "user", "content": "Show me all securities listed on the 'NYSE' exchange with their ticker symbol and most recent close price." }, { "role": "assistant", "content": "SELECT s.security_name, s.ticker_symbol, md.close_price\nFROM financial_services.securities s\nJOIN financial_services.m...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE transportation.vehicles ( vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate vin character varying(17) UNIQUE, -- vehicle identification number make character varying(64) NOT NULL, -- manufacturer of the vehicle model character varying(64) NOT NULL, -- model of the vehicle year integer NOT NULL, -- manufacturing year type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van) capacity integer, -- passenger or cargo capacity fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned depot_id character varying(64), -- identifier of the home depot/base acquisition_date date, -- date the vehicle was acquired PRIMARY KEY (vehicle_id) ) CREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text ) CREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text ) CREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )
[ { "role": "user", "content": "List all completed trips, including each trip's scheduled and actual arrival times, along with the make and model of the assigned vehicle." }, { "role": "assistant", "content": "SELECT t.trip_id, t.scheduled_arrival, t.actual_arrival, v.make, v.model\nFROM transport...
You are an expert in writing database language. You 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.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": "Find all PDF claim documents uploaded in May 2024, showing document_id, claim_id, and file_size_bytes, and also list who uploaded each document." }, { "role": "assistant", "content": "SELECT document_id, claim_id, file_size_bytes, uploaded_by FROM insurance.claim_do...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE gaming_technology.players ( player_id uuid PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb ) CREATE TABLE gaming_technology.games ( game_id.uuid, 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.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 ) 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": "I want to get the number of servers and the average current players for each game, including the game title." }, { "role": "assistant", "content": "SELECT g.title,\n COUNT(s.server_id) AS server_count,\n AVG(s.current_players) AS avg_current_players\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 transportation.vehicles ( vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate vin character varying(17) UNIQUE, -- vehicle identification number make character varying(64) NOT NULL, -- manufacturer of the vehicle model character varying(64) NOT NULL, -- model of the vehicle year integer NOT NULL, -- manufacturing year type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van) capacity integer, -- passenger or cargo capacity fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned depot_id character varying(64), -- identifier of the home depot/base acquisition_date date, -- date the vehicle was acquired PRIMARY KEY (vehicle_id) ) CREATE TABLE transportation.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) ) CREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp ) 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": "List all passengers with their first name, last name, and email." }, { "role": "assistant", "content": "SELECT first_name, last_name, email FROM transportation.passengers;" }, { "role": "user", "content": "Can you also include their phone number in the r...
You are an expert in writing database language. You 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.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.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )
[ { "role": "user", "content": "Find pairs of appointment IDs that were scheduled at the same location. Show the IDs of the two appointments." }, { "role": "assistant", "content": "SELECT t1.appointment_id, t2.appointment_id FROM appointments AS t1 JOIN appointments AS t2 ON t1.location_id = t2.lo...
You are an expert in writing database language. You 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 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) )
[ { "role": "user", "content": "List the first name, last name, specialization, and the name of the law firm for all lawyers hired before January 1, 2020." }, { "role": "assistant", "content": "SELECT T1.first_name , T1.last_name , T1.specialization , T2.firm_name FROM legal_services.lawyers 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 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, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text ) CREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text ) CREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer ) CREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text ) CREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text ) 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_metadata ( blockchain.text, contract_address.text, token_id.text, contract_name.text, erc_type.text, amount.bigint, minter.text, owner.text, mint_block_number.bigint, mint_time.bigint, mint_transaction_hash.text, mint_price.text, token_uri.text, metadata.text, name.text, image_uri.text, traits.text, updated_at.bigint, status.text, rarity_score.real, rarity_rank.integer, unique_attribute_count.integer, pk.integer ) CREATE TABLE nft_collections ( blockchain.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer ) 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 token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal ) 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, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text ) 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_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal ) CREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )
[ { "role": "user", "content": "What is the total number of ERC20 tokens in the `token_metas` table that are marked as a proxy (is_proxy = 1)?" }, { "role": "assistant", "content": "SELECT COUNT(*) FROM token_metas WHERE is_erc20 = 1 AND is_proxy = 1;" }, { "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 blockchain.smart_contracts ( contract_id text, creator_address text, code text, timestamp timestamp )
[ { "role": "user", "content": "Show me all smart contracts created by addresses that have created more than 3 contracts, along with the total number of contracts each creator has made." }, { "role": "assistant", "content": "SELECT sc.contract_id, sc.creator_address, COUNT(*) OVER (PARTITION BY sc...
You are an expert in writing database language. You 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.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean ) CREATE TABLE trading_platform.logs ( log_id.text, user_id.text, action.text, details.text, logged_at.timestamp ) CREATE TABLE trading_platform.notifications ( notification_id.text, user_id.text, message.text, sent_at.timestamp, read_at.timestamp )
[ { "role": "user", "content": "Provide a list of all log entries recorded since the start of 2024, including the user ID, action, and the exact time the log occurred." }, { "role": "assistant", "content": "SELECT user_id, action, logged_at FROM logs WHERE logged_at >= '2024-01-01';" } ]
You are an expert in writing database language. You 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": "Show the distribution of total supply for tokens, grouped into ranges like < 1 million, 1 million to 1 billion, and > 1 billion. Count how many tokens fall into each range." }, { "role": "assistant", "content": "SELECT CASE WHEN total_supply < 1000000 THEN '< 1 mill...
You are an expert in writing database language. You 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 character varying(64) NOT NULL, employee_id character varying(64) NOT NULL UNIQUE, first_name character varying(128) NOT NULL, last_name character varying(128) NOT NULL, license_number character varying(64) NOT NULL UNIQUE, license_expiry_date date NOT NULL, contact_number character varying(32), email character varying(128) UNIQUE, hire_date date NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (driver_id) ) CREATE TABLE transportation.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) ) CREATE TABLE transportation.fuel_logs ( fuel_log_id character varying(64) NOT NULL, vehicle_id character varying(64) NOT NULL, trip_id character varying(64), log_timestamp timestamp with time zone NOT NULL, fuel_type character varying(32) NOT NULL, quantity numeric(10, 3) NOT NULL, unit character varying(16) NOT NULL, cost_per_unit numeric(8, 4), total_cost numeric(10, 2) NOT NULL, odometer_reading integer, location_id character varying(64), PRIMARY KEY (fuel_log_id) ) CREATE TABLE transportation.passengers ( passenger_id character varying(64) NOT NULL, first_name character varying(128) NOT NULL, last_name character varying(128) NOT NULL, email character varying(128) UNIQUE, phone_number character varying(32) UNIQUE, date_of_birth date, loyalty_program_id character varying(64), created_at timestamp with time zone NOT NULL, 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 booking, show the booking ID, passenger's full name, booking status, and the email of the passenger." }, { "role": "assistant", "content": "SELECT b.booking_id, p.first_name, p.last_name, b.status, p.email\nFROM transportation.bookings b\nJOIN 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 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.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, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) ) CREATE TABLE government_services.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )
[ { "role": "user", "content": "How many total documents are recorded in the system?" }, { "role": "assistant", "content": "SELECT COUNT(*) FROM government_services.documents;" }, { "role": "user", "content": "Show me the count of documents for each verification_status." }, { "...
You are an expert in writing database language. You 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, project_id character varying(32) NOT NULL, project_name character varying(128) NOT NULL, rounds_name character varying(32), investment_value numeric(38,14), investment_date character varying(128), introduction character varying(128), valuation numeric(38,14) ) 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 character varying(512) NOT NULL, -- the id of narrative", "top_3_coins text, -- the top 3 tokens in the narrative", "price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour in the narrative", "price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours in the narrative", "price_change_percentage_7d double precision, -- change in value divided by the absolute price value of the original token price in 7 days in the narrative", "market_cap double precision, -- the market cap of the narrative", "volume_24h double precision, -- the trade volume of the narrative", "trend_rank bigint, -- the trending rank of the narrative, value 1 expresses the most popular narrative", "token_num bigint, -- total token number in the narrative", ",PRIMARY KEY (narrative));" 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) ) "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));" 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": "For each fundraising round in 2022 and 2023, list the round name, the year, the total investment_value, and the count of distinct projects. Also include the average market_cap of associated tokens by matching project_name to token_symbol in token_basic_info." }, { "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 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, -- 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.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.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.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 character varying(64) NOT NULL, -- unique identifier for the notification citizen_id character varying(64) NOT NULL, -- FK to citizens table application_id character varying(64), -- FK to applications table (optional) message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail sent_at timestamp NOT NULL, status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request related_entity_id character varying(64), -- ID of the related entity PRIMARY KEY (notification_id) )
[ { "role": "user", "content": "List all applications that have at least one document with a verification status of 'Verified'. Show the application reference number and the name of the service associated with the application." }, { "role": "assistant", "content": "SELECT\n T1.reference_number,\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.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.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.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) ) 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": "List all documents uploaded for cases handled in the 'District Court' jurisdiction, showing the document name, case number, and upload timestamp." }, { "role": "assistant", "content": "SELECT d.document_name, cs.case_number, d.upload_timestamp\nFROM legal_services.d...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text ) 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 text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text ) CREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text ) CREATE TABLE legal_services.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.text, created_at.timestamp ) 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": "List all cases where the client and the lead lawyer belong to companies or law firms with the same phone number. For each such case, please show the case name, client name, client company, lead lawyer name, and the shared phone number." }, { "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 web3.events ( event_id.text, contract_id.text, event_name.text, data.text, emitted_at.timestamp, transaction_id.text, log_index.integer ) CREATE TABLE web3.transactions ( transaction_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128), value numeric(38,14) NOT NULL, gas_used integer NOT NULL, gas_price numeric(38,14) NOT NULL, block_number integer NOT NULL, timestamp timestamp NOT NULL, input_data text, status character varying(32) NOT NULL, nonce integer NOT NULL, PRIMARY KEY (transaction_id) ) CREATE TABLE web3.tokens ( token_id.text, contract_address.text, token_name.text, token_symbol.text, decimals.integer, 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 PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )
[ { "role": "user", "content": "Show the top 5 contracts by number of events emitted, including contract_id and event_count." }, { "role": "assistant", "content": "SELECT contract_id,\n COUNT(event_id) AS event_count\nFROM web3.events\nGROUP BY contract_id\nORDER BY event_count DESC\nLIMIT 5...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )
[ { "role": "user", "content": "Count how many insurance policies have an effective date in the year 2023." }, { "role": "assistant", "content": "SELECT COUNT(*) FROM healthcare.patient_insurance WHERE EXTRACT(YEAR FROM effective_date) = 2023;" } ]
You are an expert in writing database language. You 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, username text, email text, password_hash text, registration_date timestamp with time zone, last_login timestamp with time zone, country_code text, status text, profile_data jsonb ) CREATE TABLE gaming_technology.games ( game_id uuid, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text ) CREATE TABLE gaming_technology.developers ( developer_id uuid, name text, country text, founded_year integer, website text, created_at timestamp with time zone ) 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 timestamp with time zone ) CREATE TABLE gaming_technology.achievements ( achievement_id uuid, game_id uuid, name text, description text, icon_url text, points integer, hidden boolean ) CREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )
[ { "role": "user", "content": "Show all achievements for games developed in Germany, including achievement names and their point values." }, { "role": "assistant", "content": "SELECT a.name AS achievement_name, a.points\nFROM gaming_technology.achievements a\nJOIN gaming_technology.games g ON a.g...
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. ##Table Structure CREATE TABLE insurance.insurance_products ( product_id text, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )
[ { "role": "user", "content": "Show the product name, type, and creation date for products created before January 1st, 2023." }, { "role": "assistant", "content": "SELECT product_name, product_type, created_at FROM insurance.insurance_products WHERE created_at < '2023-01-01';" }, { "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 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, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text ) CREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text ) 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 nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer ) CREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text ) CREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text ) 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.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer ) 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, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal ) CREATE TABLE token_info ( 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 ( 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_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text ) 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.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text ) CREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal ) CREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )
[ { "role": "user", "content": "Find the total balance per coin_type for active SUI coins, including coin_type, symbol, name, and SUM(balance) as total_balance. Sort by total_balance descending." }, { "role": "assistant", "content": "SELECT\n c.coin_type,\n m.symbol,\n m.name,\n SUM(CAST(c.bal...
You are an expert in writing database language. You 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.securities ( security_id text PRIMARY KEY, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )
[ { "role": "user", "content": "I want to list each security alongside another security issued by the same issuer." }, { "role": "assistant", "content": "SELECT a.security_id, a.ticker_symbol, b.security_id AS other_security_id, b.ticker_symbol AS other_ticker, a.issuer_name\nFROM financial_servic...
You are an expert in writing database language. You 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.services ( service_id text PRIMARY KEY, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days int, is_active boolean, online_application_url text )
[ { "role": "user", "content": "What is the average processing time in days for each service category?" }, { "role": "assistant", "content": "SELECT category, AVG(average_processing_time_days) AS avg_processing_time\nFROM government_services.services\nGROUP BY category;" }, { "role": "user...
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
7