diff --git "a/data.jsonl" "b/data.jsonl" --- "a/data.jsonl" +++ "b/data.jsonl" @@ -1,250 +1,250 @@ -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players (\n player_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the player\n username character varying(100) NOT NULL UNIQUE, -- player's chosen display name\n email character varying(255) NOT NULL UNIQUE, -- player's email address for login/recovery\n password_hash text NOT NULL, -- securely hashed password\n registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the player account was created\n last_login timestamp with time zone, -- timestamp of the last successful login\n country_code character(2), -- player's country (ISO 3166-1 alpha-2)\n status character varying(20) NOT NULL DEFAULT 'active', -- account status (e.g., active, banned, suspended)\n profile_data jsonb, -- flexible field for avatar url, bio, preferences etc.\n PRIMARY KEY (player_id)\n)\nCREATE TABLE gaming_technology.games (\n game_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game\n title character varying(200) NOT NULL, -- official title of the game\n developer_id uuid NOT NULL, -- FK linking to the developers table\n publisher_id uuid, -- FK linking to a potential publishers table (optional)\n genre character varying(100), -- primary genre (e.g., RPG, FPS, Strategy)\n release_date date, -- official release date\n description text, -- short description or synopsis of the game\n platform character varying(50) NOT NULL, -- primary platform (e.g., PC, PlayStation 5, Xbox Series X, Mobile)\n engine character varying(100), -- game engine used (e.g., Unreal Engine 5, Unity)\n website character varying(255), -- official website URL\n PRIMARY KEY (game_id)\n -- FOREIGN KEY (developer_id) REFERENCES gaming_technology.developers(developer_id) -- Example FK constraint\n)\nCREATE TABLE gaming_technology.achievements (\n achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition\n game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to\n name character varying(150) NOT NULL, -- name of the achievement\n description text NOT NULL, -- how to unlock the achievement\n icon_url character varying(255), -- URL for the achievement's icon\n points integer DEFAULT 0, -- points awarded for unlocking (optional)\n hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked\n PRIMARY KEY (achievement_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\nCREATE TABLE gaming_technology.player_achievements (\n player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for this unlock instance\n player_id uuid NOT NULL, -- FK linking to the player who unlocked it\n achievement_id uuid NOT NULL, -- FK linking to the achievement definition\n unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the achievement was unlocked\n PRIMARY KEY (player_achievement_id),\n UNIQUE (player_id, achievement_id) -- Ensure a player can only unlock an achievement once\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (achievement_id) REFERENCES gaming_technology.achievements(achievement_id)\n)\nCREATE TABLE gaming_technology.in_game_items (\n item_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the item definition\n game_id uuid NOT NULL, -- FK linking to the game this item belongs to\n item_name character varying(150) NOT NULL, -- name of the item\n item_type character varying(50) NOT NULL, -- type (e.g., Cosmetic, Consumable, Weapon, Armor)\n description text, -- description of the item\n rarity character varying(30), -- item rarity (e.g., Common, Rare, Epic, Legendary)\n cost_currency character varying(10), -- currency code if purchasable (e.g., USD, EUR, GOLD)\n cost_amount numeric(12, 2), -- price if purchasable\n attributes jsonb, -- flexible field for item stats or properties\n PRIMARY KEY (item_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\n", "conversations": [{"role": "user", "content": "List all in-game items' names, types, and rarity along with their total cost in USD, for items that belong to games released on or after 2021-01-01."}, {"role": "assistant", "content": "SELECT i.item_name, i.item_type, i.rarity, i.cost_amount\nFROM gaming_technology.in_game_items i\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE g.release_date >= '2021-01-01' AND i.cost_currency = 'USD'\nORDER BY i.item_name;"}, {"role": "user", "content": "Please add the game's title to the results."}, {"role": "assistant", "content": "SELECT i.item_name, i.item_type, i.rarity, i.cost_amount, g.title AS game_title\nFROM gaming_technology.in_game_items i\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE g.release_date >= '2021-01-01' AND i.cost_currency = 'USD'\nORDER BY i.item_name;"}, {"role": "user", "content": "Now, show only items of rarity 'Epic' or 'Legendary'."}, {"role": "assistant", "content": "SELECT i.item_name, i.item_type, i.rarity, i.cost_amount, g.title AS game_title\nFROM gaming_technology.in_game_items i\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE g.release_date >= '2021-01-01' AND i.cost_currency = 'USD' AND i.rarity IN ('Epic', 'Legendary')\nORDER BY i.item_name;"}, {"role": "user", "content": "I got an error because some items have null cost_amount. Can you exclude those from the results?"}, {"role": "assistant", "content": "SELECT i.item_name, i.item_type, i.rarity, i.cost_amount, g.title AS game_title\nFROM gaming_technology.in_game_items i\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nWHERE g.release_date >= '2021-01-01' AND i.cost_currency = 'USD' AND i.rarity IN ('Epic', 'Legendary') AND i.cost_amount IS NOT NULL\nORDER BY i.item_name;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\nCREATE TABLE healthcare.medications (\n medication_id character varying(64) NOT NULL, -- unique identifier for the medication type\n medication_name character varying(255) NOT NULL, -- common or brand name\n generic_name character varying(255), -- generic chemical name\n manufacturer character varying(100), -- drug manufacturer\n ndc_code character varying(20) UNIQUE, -- National Drug Code (optional but useful)\n description text, -- description of the medication\n PRIMARY KEY (medication_id)\n)\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "List all appointments scheduled in the next 7 days along with the appointment_id, appointment_time, patient's full name, doctor's full name, and the patient's primary insurance plan_name."}, {"role": "assistant", "content": "SELECT ap.appointment_id,\n ap.appointment_time,\n pt.first_name || ' ' || pt.last_name AS patient_name,\n d.first_name || ' ' || d.last_name AS doctor_name,\n ip.plan_name\nFROM healthcare.appointments ap\nJOIN healthcare.patients pt ON ap.patient_id = pt.patient_id\nJOIN healthcare.doctors d ON ap.doctor_id = d.doctor_id\nJOIN healthcare.patient_insurance pi ON pt.patient_id = pi.patient_id AND pi.is_primary = TRUE\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE ap.appointment_time BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL '7 days';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, ssn_hash character varying(128), address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state character varying(50) NOT NULL, zip_code character varying(20) NOT NULL, country character varying(50) NOT NULL DEFAULT 'USA', phone_number character varying(30), email character varying(128) UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, status character varying(20) NOT NULL DEFAULT 'Active', PRIMARY KEY (customer_id) )\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text )\nCREATE TABLE insurance.agents ( agent_id text, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\nCREATE TABLE insurance.premium_payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment\n policy_id character varying(64) NOT NULL, -- identifier of the policy the payment is for (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the payment (FK to customers)\n payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the payment was received\n amount_paid numeric(12, 2) NOT NULL, -- amount of the payment\n payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check\n transaction_reference character varying(128) UNIQUE, -- reference from payment processor\n due_date date, -- due date for this payment installment\n payment_period_start date, -- start date of the period this payment covers\n payment_period_end date, -- end date of the period this payment covers\n status character varying(30) NOT NULL DEFAULT 'Completed', -- e.g., Completed, Pending, Failed, Refunded\n PRIMARY KEY (payment_id)\n)\n", "conversations": [{"role": "user", "content": "List each claim with its policy number and the selling agent's first and last name."}, {"role": "assistant", "content": "SELECT c.claim_id, p.policy_number, a.first_name, a.last_name\nFROM insurance.claims c\nJOIN insurance.policies p ON c.policy_id = p.policy_id\nLEFT JOIN insurance.agents a ON p.agent_id = a.agent_id;"}, {"role": "user", "content": "Filter to include only claims with settlement_amount not null and reported_date in 2023."}, {"role": "assistant", "content": "SELECT c.claim_id, p.policy_number, a.first_name, a.last_name\nFROM insurance.claims c\nJOIN insurance.policies p ON c.policy_id = p.policy_id\nLEFT JOIN insurance.agents a ON p.agent_id = a.agent_id\nWHERE c.settlement_amount IS NOT NULL\n AND c.reported_date >= '2023-01-01'::timestamp\n AND c.reported_date < '2024-01-01'::timestamp;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE nft_holders ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata (\n object_id varchar NOT NULL, -- object id of the coin metadata object\n coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN\n status varchar NOT NULL, -- coin status, eg. exists, deleted\n decimals bigint NOT NULL, -- decimals of the coin\n description varchar NOT NULL, -- description of the coin\n icon_url varchar NOT NULL, -- icon url of the coin\n symbol varchar NOT NULL, -- symbol of the coin\n name varchar NOT NULL -- name of the coin\n)\nCREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest (\n blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract\n address varchar(42) NOT NULL, -- address fields for the functionType in contract\n decimals bigint NOT NULL, -- decimals fields for the functionType in contract\n symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract\n price real NOT NULL, -- price fields for the functionType in contract\n timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract\n)\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE token_info (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar NOT NULL, -- Token tick\n max_supply decimal(38,0) NOT NULL, -- Max supply\n lim decimal(38,0) NOT NULL, -- Limit of each mint\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table)\n)\nCREATE TABLE mud_holesky_redstone (\n address varchar NOT NULL, -- address fields for the functionType in contract\n table_id varchar NOT NULL, -- table_id fields for the functionType in contract\n key_bytes varchar NOT NULL, -- key_bytes fields for the functionType in contract\n key0 varchar NOT NULL, -- key0 fields for the functionType in contract\n key1 varchar NOT NULL, -- key1 fields for the functionType in contract\n static_data varchar NOT NULL, -- static_data fields for the functionType in contract\n encoded_lengths varchar NOT NULL, -- encoded_lengths fields for the functionType in contract\n dynamic_data varchar NOT NULL, -- dynamic_data fields for the functionType in contract\n is_deleted boolean NOT NULL, -- is_deleted fields for the functionType in contract\n block_number bigint NOT NULL, -- Block number uniquely identifying the block\n log_index bigint NOT NULL -- Index of the log within the transaction\n)\nCREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )\nCREATE TABLE token_activities_avalanche (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n log_index integer NOT NULL, -- Index of the log within the transaction\n type varchar(20) NOT NULL, -- Operation: Type of event (deploy, mint, transfer, list)\n tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription\n id varchar(255) NOT NULL, -- Unique identifier of the inscription\n 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\"\n from_address varchar(42) NOT NULL, -- Address sending the inscription\n to_address varchar(42) NOT NULL -- Address receiving the inscription\n)\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\n", "conversations": [{"role": "user", "content": "Show all SUI coins with 'exists' status and more than 8 decimal places. Display coin_type, symbol, name, and decimals."}, {"role": "assistant", "content": "SELECT coin_type, symbol, name, decimals\nFROM sui_coins_metadata\nWHERE status = 'exists' AND decimals > 8;"}, {"role": "user", "content": "Add the total balance for each coin_type by joining with sui_coins."}, {"role": "assistant", "content": "SELECT scm.coin_type, scm.symbol, scm.name, scm.decimals, SUM(sc.balance::numeric) AS total_balance\nFROM sui_coins_metadata scm\nJOIN sui_coins sc ON scm.coin_type = sc.coin_type\nWHERE scm.status = 'exists' AND scm.decimals > 8\nGROUP BY scm.coin_type, scm.symbol, scm.name, scm.decimals;"}, {"role": "user", "content": "Can you also include only coins where the total_balance is greater than 1,000,000 and show the description?"}, {"role": "assistant", "content": "SELECT scm.coin_type, scm.symbol, scm.name, scm.decimals, scm.description, SUM(sc.balance::numeric) AS total_balance\nFROM sui_coins_metadata scm\nJOIN sui_coins sc ON scm.coin_type = sc.coin_type\nWHERE scm.status = 'exists' AND scm.decimals > 8\nGROUP BY scm.coin_type, scm.symbol, scm.name, scm.decimals, scm.description\nHAVING SUM(sc.balance::numeric) > 1000000;"}, {"role": "user", "content": "Actually, only show the top 5 coins with the highest total_balance."}, {"role": "assistant", "content": "SELECT scm.coin_type, scm.symbol, scm.name, scm.decimals, scm.description, SUM(sc.balance::numeric) AS total_balance\nFROM sui_coins_metadata scm\nJOIN sui_coins sc ON scm.coin_type = sc.coin_type\nWHERE scm.status = 'exists' AND scm.decimals > 8\nGROUP BY scm.coin_type, scm.symbol, scm.name, scm.decimals, scm.description\nHAVING SUM(sc.balance::numeric) > 1000000\nORDER BY total_balance DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id.text, first_name.text, last_name.text, specialty.text, license_number.text, phone_number.text, email.text, hospital_affiliation_id.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\nCREATE TABLE healthcare.medications ( medication_id.text, medication_name.text, generic_name.text, manufacturer.text, ndc_code.text, description.text )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )\n", "conversations": [{"role": "user", "content": "Retrieve prescription_id, medication_name, and insurance plan_name for all prescriptions."}, {"role": "assistant", "content": "SELECT p.prescription_id,\n m.medication_name,\n ip.plan_name\nFROM healthcare.prescriptions p\nJOIN healthcare.medications m\n ON p.medication_id = m.medication_id\nJOIN healthcare.patient_insurance pi\n ON p.patient_id = pi.patient_id\nJOIN healthcare.insurance_plans ip\n ON pi.plan_id = ip.plan_id;"}, {"role": "user", "content": "Only include prescriptions where the plan_type is 'HMO'."}, {"role": "assistant", "content": "SELECT p.prescription_id,\n m.medication_name,\n ip.plan_name\nFROM healthcare.prescriptions p\nJOIN healthcare.medications m\n ON p.medication_id = m.medication_id\nJOIN healthcare.patient_insurance pi\n ON p.patient_id = pi.patient_id\nJOIN healthcare.insurance_plans ip\n ON pi.plan_id = ip.plan_id\nWHERE ip.plan_type = 'HMO';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\nCREATE TABLE trading_platform.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )\nCREATE TABLE trading_platform.orders ( order_id text PRIMARY KEY, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades (\n trade_id character varying(64) NOT NULL, -- unique identifier for the trade\n order_id character varying(64) NOT NULL, -- identifier of the order that led to the trade\n buyer_id character varying(64) NOT NULL, -- identifier of the buyer\n seller_id character varying(64) NOT NULL, -- identifier of the seller\n asset_id character varying(64) NOT NULL, -- identifier of the asset being traded\n quantity numeric(38,14) NOT NULL, -- quantity of the asset in the trade\n price numeric(38,14) NOT NULL, -- price per unit of the asset\n traded_at timestamp NOT NULL, -- time when the trade was executed\n PRIMARY KEY (trade_id)\n)\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )\nCREATE TABLE trading_platform.metadata (\n metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata\n asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with\n key character varying(128) NOT NULL, -- key of the metadata\n value text NOT NULL, -- value of the metadata\n PRIMARY KEY (metadata_id)\n)\nCREATE TABLE trading_platform.kyc_audit (\n kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit\n user_id character varying(64) NOT NULL, -- identifier of the user being audited\n status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)\n reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed\n PRIMARY KEY (kyc_audit_id)\n)\n", "conversations": [{"role": "user", "content": "Provide a summary for each user, showing their user_id, username, and the total number of orders they have placed overall."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(o.order_id) AS total_orders\nFROM trading_platform.users u\nLEFT JOIN trading_platform.orders o ON u.user_id = o.user_id\nGROUP BY u.user_id, u.username;"}, {"role": "user", "content": "Now filter to include only users who have 'approved' status in the KYC audit."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(o.order_id) AS total_orders\nFROM trading_platform.users u\nJOIN trading_platform.kyc_audit k ON u.user_id = k.user_id AND k.status = 'approved'\nLEFT JOIN trading_platform.orders o ON u.user_id = o.user_id\nGROUP BY u.user_id, u.username;"}, {"role": "user", "content": "Also add the sum of quantities from their 'sell' orders."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(o.order_id) AS total_orders, SUM(CASE WHEN o.order_type = 'sell' THEN o.quantity ELSE 0 END) AS total_sell_quantity\nFROM trading_platform.users u\nJOIN trading_platform.kyc_audit k ON u.user_id = k.user_id AND k.status = 'approved'\nLEFT JOIN trading_platform.orders o ON u.user_id = o.user_id\nGROUP BY u.user_id, u.username;"}, {"role": "user", "content": "Finally, sort by total_sell_quantity descending and limit to the top 5 users."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(o.order_id) AS total_orders, SUM(CASE WHEN o.order_type = 'sell' THEN o.quantity ELSE 0 END) AS total_sell_quantity\nFROM trading_platform.users u\nJOIN trading_platform.kyc_audit k ON u.user_id = k.user_id AND k.status = 'approved'\nLEFT JOIN trading_platform.orders o ON u.user_id = o.user_id\nGROUP BY u.user_id, u.username\nORDER BY total_sell_quantity DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\nCREATE TABLE legal_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document\n case_id character varying(64) NOT NULL, -- FK to cases table\n document_name character varying(255) NOT NULL, -- name of the document file\n document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence\n storage_path text NOT NULL, -- path or reference to the document storage location\n uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it)\n upload_timestamp timestamp NOT NULL, -- time the document was uploaded\n version integer DEFAULT 1, -- document version number\n description text, -- brief description or notes about the document\n PRIMARY KEY (document_id)\n)\nCREATE TABLE legal_services.time_entries (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "List the names of all law firms along with the names (first and last) of lawyers who are partners in those firms."}, {"role": "assistant", "content": "SELECT lf.firm_name, l.first_name, l.last_name\nFROM legal_services.law_firms lf\nJOIN legal_services.lawyers l ON lf.firm_id = l.firm_id\nWHERE l.is_partner = TRUE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the total billable hours and total billed amount for each lawyer who worked on 'Civil Litigation' cases in 2023, sorted by billed amount descending."}, {"role": "assistant", "content": "SELECT te.lawyer_id,\n SUM(te.hours_spent) AS total_billable_hours,\n SUM(te.hours_spent * te.billing_rate) AS total_billed_amount\nFROM legal_services.time_entries te\nJOIN legal_services.cases c ON te.case_id = c.case_id\nWHERE te.is_billable = true\n AND te.is_billed = true\n AND c.case_type = 'Civil Litigation'\n AND te.date_worked BETWEEN '2023-01-01' AND '2023-12-31'\nGROUP BY te.lawyer_id\nORDER BY total_billed_amount DESC;"}, {"role": "user", "content": "Actually, I'd like to include only those lawyers who have at least 10 billable entries in that period."}, {"role": "assistant", "content": "SELECT te.lawyer_id,\n SUM(te.hours_spent) AS total_billable_hours,\n SUM(te.hours_spent * te.billing_rate) AS total_billed_amount\nFROM legal_services.time_entries te\nJOIN legal_services.cases c ON te.case_id = c.case_id\nWHERE te.is_billable = true\n AND te.is_billed = true\n AND c.case_type = 'Civil Litigation'\n AND te.date_worked BETWEEN '2023-01-01' AND '2023-12-31'\nGROUP BY te.lawyer_id\nHAVING COUNT(*) >= 10\nORDER BY total_billed_amount DESC;"}, {"role": "user", "content": "Also break down the report by case, listing each lawyer and case_number along with their billable hours and billed amount per case, sorted by billed amount descending."}, {"role": "assistant", "content": "SELECT te.lawyer_id,\n c.case_number,\n SUM(te.hours_spent) AS case_billable_hours,\n SUM(te.hours_spent * te.billing_rate) AS case_billed_amount\nFROM legal_services.time_entries te\nJOIN legal_services.cases c ON te.case_id = c.case_id\nWHERE te.is_billable = true\n AND te.is_billed = true\n AND c.case_type = 'Civil Litigation'\n AND te.date_worked BETWEEN '2023-01-01' AND '2023-12-31'\nGROUP BY te.lawyer_id, c.case_number\nORDER BY case_billed_amount DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, room_number character varying(10) NOT NULL, room_type_id character varying(64) NOT NULL, floor integer, status character varying(50) NOT NULL, is_smoking boolean NOT NULL DEFAULT false, features text, current_condition text, last_cleaned_at timestamp with time zone, PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )\nCREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE 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) )\nCREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all services in the 'Concierge' department along with their names, price, and whether they are currently available. Include the property name as well."}, {"role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge';"}, {"role": "user", "content": "Could you filter only those services that are not currently available and sort by price ascending?"}, {"role": "assistant", "content": "SELECT s.service_name, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge'\n AND s.is_available = false\nORDER BY s.price ASC;"}, {"role": "user", "content": "Instead, show only properties in the city of 'Miami' and add the service category to the results."}, {"role": "assistant", "content": "SELECT s.service_name, s.category, s.price, s.is_available, p.property_name\nFROM hospitality_technology.services s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.department = 'Concierge'\n AND s.is_available = false\n AND p.city = 'Miami'\nORDER BY s.price ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "List each patient's first and last name along with the insurance plan name they are enrolled in, including only primary policies. Return patient_id, first_name, last_name, and plan_name."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id AND pi.is_primary = true\nJOIN healthcare.insurance_plans AS ip ON pi.plan_id = ip.plan_id;"}, {"role": "user", "content": "Now limit to plans with plan_type 'EPO' and sort by patient last name ascending."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id AND pi.is_primary = true\nJOIN healthcare.insurance_plans AS ip ON pi.plan_id = ip.plan_id\nWHERE ip.plan_type = 'EPO'\nORDER BY p.last_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp.timestamp, block_number.bigint, transaction_hash.text, transaction_index.bigint, from_address.text, contract_address.text, symbol.text, total_supply.text, name.text, decimals.bigint, is_erc20.integer, is_erc721.integer, is_erc1155.integer, is_proxy.integer, extra_info.text, pk.integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )\nCREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )\nCREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )\nCREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer )\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar NOT NULL, -- Token tick\n max_supply decimal(38,0) NOT NULL, -- Max supply\n lim decimal(38,0) NOT NULL, -- Limit of each mint\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table)\n)\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE mud_holesky_redstone ( address varchar NOT NULL, table_id varchar NOT NULL, key_bytes varchar NOT NULL, key0 varchar NOT NULL, key1 varchar NOT NULL, static_data varchar NOT NULL, encoded_lengths varchar NOT NULL, dynamic_data varchar NOT NULL, is_deleted boolean NOT NULL, block_number bigint NOT NULL, log_index bigint NOT NULL )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )\nCREATE TABLE token_activities_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_avalanche (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar(20) NOT NULL, -- Ticker: Identifier of the inscription\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription\n amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )\n", "conversations": [{"role": "user", "content": "Show me the top 5 NFT collections on Ethereum with the highest number of unique owners, along with their names and floor prices."}, {"role": "assistant", "content": "SELECT nc.name, nc.floor_price, COUNT(DISTINCT nh.wallet_address) AS unique_owners FROM nft_collections nc JOIN nft_holders nh ON nc.contract_address = nh.contract_address WHERE nc.blockchain = 'ethereum' GROUP BY nc.name, nc.floor_price ORDER BY unique_owners DESC LIMIT 5;"}, {"role": "user", "content": "Can you modify the query to also include the banner image URL and filter to only show collections with a floor price greater than 0.5 ETH?"}, {"role": "assistant", "content": "SELECT nc.name, nc.floor_price, nc.banner_image_url, COUNT(DISTINCT nh.wallet_address) AS unique_owners FROM nft_collections nc JOIN nft_holders nh ON nc.contract_address = nh.contract_address WHERE nc.blockchain = 'ethereum' AND CAST(nc.floor_price AS decimal) > 0.5 GROUP BY nc.name, nc.floor_price, nc.banner_image_url ORDER BY unique_owners DESC LIMIT 5;"}, {"role": "user", "content": "Now join this with the token_metas table to include the contract type (ERC721 or ERC1155) for these collections."}, {"role": "assistant", "content": "SELECT nc.name, nc.floor_price, nc.banner_image_url, tm.is_erc721, tm.is_erc1155, COUNT(DISTINCT nh.wallet_address) AS unique_owners FROM nft_collections nc JOIN nft_holders nh ON nc.contract_address = nh.contract_address JOIN token_metas tm ON nc.contract_address = tm.contract_address WHERE nc.blockchain = 'ethereum' AND CAST(nc.floor_price AS decimal) > 0.5 GROUP BY nc.name, nc.floor_price, nc.banner_image_url, tm.is_erc721, tm.is_erc1155 ORDER BY unique_owners DESC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "For each appointment scheduled for '2024-08-15', return the patient's full name, the doctor's ID, and the appointment time."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, a.doctor_id, a.appointment_time\nFROM healthcare.appointments a\nJOIN healthcare.patients p ON a.patient_id = p.patient_id\nWHERE DATE(a.appointment_time) = '2024-08-15' AND a.status = 'scheduled';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.market_data (\n data_point_id bigserial NOT NULL, -- auto-incrementing primary key\n security_id character varying(64) NOT NULL, -- identifier for the security\n data_timestamp timestamp NOT NULL, -- timestamp for the data point (e.g., end of day, intraday)\n open_price numeric(19, 8), -- opening price for the period\n high_price numeric(19, 8), -- highest price during the period\n low_price numeric(19, 8), -- lowest price during the period\n close_price numeric(19, 8) NOT NULL, -- closing price for the period\n adjusted_close_price numeric(19, 8), -- closing price adjusted for dividends and splits\n volume bigint, -- trading volume during the period\n source character varying(50), -- source of the market data (e.g., Bloomberg, Refinitiv)\n PRIMARY KEY (data_point_id),\n UNIQUE (security_id, data_timestamp), -- Ensure unique data point per security per time\n FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id)\n)\n", "conversations": [{"role": "user", "content": "For each security sector, what is the average volume recorded in the market data?"}, {"role": "assistant", "content": "SELECT T2.sector, AVG(T1.volume) FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id GROUP BY T2.sector;"}, {"role": "user", "content": "Can you restrict this to data points from the last 6 months?"}, {"role": "assistant", "content": "SELECT T2.sector, AVG(T1.volume) FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.data_timestamp >= NOW() - INTERVAL '6 months' GROUP BY T2.sector;"}, {"role": "user", "content": "Also include the count of data points per sector in the result."}, {"role": "assistant", "content": "SELECT T2.sector, AVG(T1.volume), COUNT(T1.data_point_id) FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.data_timestamp >= NOW() - INTERVAL '6 months' GROUP BY T2.sector;"}, {"role": "user", "content": "Filter out sectors with fewer than 1000 data points in this period."}, {"role": "assistant", "content": "SELECT T2.sector, AVG(T1.volume), COUNT(T1.data_point_id) FROM financial_services.market_data AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.data_timestamp >= NOW() - INTERVAL '6 months' GROUP BY T2.sector HAVING COUNT(T1.data_point_id) >= 1000;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\n", "conversations": [{"role": "user", "content": "List all available services in the 'Housekeeping' department that cost less than 20."}, {"role": "assistant", "content": "SELECT service_id, service_name, price\nFROM hospitality_technology.services\nWHERE department = 'Housekeeping' AND is_available = true AND price < 20;"}, {"role": "user", "content": "Sort the results by service_name in ascending order."}, {"role": "assistant", "content": "SELECT service_id, service_name, price\nFROM hospitality_technology.services\nWHERE department = 'Housekeeping' AND is_available = true AND price < 20\nORDER BY service_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id.text, first_name.text, last_name.text, company_name.text, email.text, phone.text, address.text, date_registered.timestamp, status.text )\nCREATE TABLE legal_services.lawyers ( lawyer_id.text, first_name.text, last_name.text, bar_number.text, firm_id.text, email.text, phone.text, specialization.text, hire_date.timestamp, is_partner.boolean )\nCREATE TABLE legal_services.law_firms ( firm_id.text, firm_name.text, address.text, phone.text, website.text, founded_date.date, managing_partner_id.text )\nCREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\nCREATE TABLE legal_services.documents ( document_id.text, case_id.text, document_name.text, document_type.text, storage_path.text, uploaded_by_lawyer_id.text, upload_timestamp.timestamp, version.integer, description.text )\nCREATE TABLE legal_services.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.text, created_at.timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the subject and start time for all appointments that are related to a case that also has an invoice. Include the case number and the invoice number."}, {"role": "assistant", "content": "SELECT T1.subject, T1.start_time, T2.case_number, T3.invoice_number FROM appointments AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id JOIN invoices AS T3 ON T2.case_id = T3.case_id;"}, {"role": "user", "content": "Only include appointments scheduled in the year 2024."}, {"role": "assistant", "content": "SELECT T1.subject, T1.start_time, T2.case_number, T3.invoice_number FROM appointments AS T1 JOIN cases AS T2 ON T1.case_id = T2.case_id JOIN invoices AS T3 ON T2.case_id = T3.case_id WHERE T1.start_time >= '2024-01-01' AND T1.start_time < '2025-01-01';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\n", "conversations": [{"role": "user", "content": "Calculate the monthly total quantity of fuel consumed and the average cost_per_unit for each fuel_type in 2023."}, {"role": "assistant", "content": "SELECT date_trunc('month', log_timestamp) AS month,\n fuel_type,\n SUM(quantity) AS total_quantity,\n AVG(cost_per_unit) AS avg_cost_per_unit\nFROM transportation.fuel_logs\nWHERE log_timestamp >= '2023-01-01'\n AND log_timestamp < '2024-01-01'\nGROUP BY 1, fuel_type\nORDER BY 1, fuel_type;"}, {"role": "user", "content": "Now limit the results to fuel types where the total_quantity exceeds 1000 units in that month."}, {"role": "assistant", "content": "SELECT month,\n fuel_type,\n total_quantity,\n avg_cost_per_unit\nFROM (\n SELECT date_trunc('month', log_timestamp) AS month,\n fuel_type,\n SUM(quantity) AS total_quantity,\n AVG(cost_per_unit) AS avg_cost_per_unit\n FROM transportation.fuel_logs\n WHERE log_timestamp >= '2023-01-01'\n AND log_timestamp < '2024-01-01'\n GROUP BY 1, fuel_type\n) sub\nWHERE total_quantity > 1000\nORDER BY month, fuel_type;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\n", "conversations": [{"role": "user", "content": "Provide for each security its ticker_symbol, the most recent close_price and corresponding timestamp."}, {"role": "assistant", "content": "SELECT s.ticker_symbol, md.close_price, md.data_timestamp\nFROM financial_services.market_data md\nJOIN financial_services.securities s ON md.security_id = s.security_id\nWHERE md.data_timestamp = (\n SELECT MAX(md2.data_timestamp)\n FROM financial_services.market_data md2\n WHERE md2.security_id = md.security_id\n);"}, {"role": "user", "content": "Actually, I'd like to filter to only those securities where the latest adjusted_close_price is at least 2% higher than the previous data point."}, {"role": "assistant", "content": "WITH ranked AS (\n SELECT md.security_id, s.ticker_symbol, md.data_timestamp, md.adjusted_close_price,\n LAG(md.adjusted_close_price) OVER (PARTITION BY md.security_id ORDER BY md.data_timestamp) AS prev_adj\n FROM financial_services.market_data md\n JOIN financial_services.securities s ON md.security_id = s.security_id\n)\nSELECT r.ticker_symbol, r.data_timestamp AS latest_timestamp, r.adjusted_close_price\nFROM ranked r\nWHERE r.data_timestamp = (\n SELECT MAX(r2.data_timestamp) FROM ranked r2 WHERE r2.security_id = r.security_id\n )\n AND r.adjusted_close_price >= r.prev_adj * 1.02;"}, {"role": "user", "content": "The SQL gives errors about ambiguous column names. Please fully qualify all columns and table aliases."}, {"role": "assistant", "content": "WITH ranked AS (\n SELECT md.security_id, s.ticker_symbol, md.data_timestamp, md.adjusted_close_price,\n LAG(md.adjusted_close_price) OVER (PARTITION BY md.security_id ORDER BY md.data_timestamp) AS prev_adj\n FROM financial_services.market_data AS md\n JOIN financial_services.securities AS s ON md.security_id = s.security_id\n)\nSELECT ranked.ticker_symbol,\n ranked.data_timestamp AS latest_timestamp,\n ranked.adjusted_close_price\nFROM ranked\nWHERE ranked.data_timestamp = (\n SELECT MAX(r2.data_timestamp)\n FROM ranked AS r2\n WHERE r2.security_id = ranked.security_id\n )\n AND ranked.adjusted_close_price >= ranked.prev_adj * 1.02;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE nft_holder_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata ( object_id 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 )\nCREATE TABLE sui_nfts ( object_id varchar NOT NULL, status varchar NOT NULL, collection_type varchar NOT NULL, package_id varchar NOT NULL, previous_transaction varchar NOT NULL, display varchar NOT NULL, owner varchar NOT NULL, name varchar NOT NULL )\nCREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )\nCREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid varchar(36) NOT NULL, blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )\nCREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_balances ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\nCREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar NOT NULL, tick varchar NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE mud_holesky_redstone ( address varchar NOT NULL, table_id varchar NOT NULL, key_bytes varchar NOT NULL, key0 varchar NOT NULL, key1 varchar NOT NULL, static_data varchar NOT NULL, encoded_lengths varchar NOT NULL, dynamic_data varchar NOT NULL, is_deleted boolean NOT NULL, block_number bigint NOT NULL, log_index bigint NOT NULL )\nCREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(255) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply varchar NOT NULL, amount varchar NOT NULL )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\nCREATE 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 )\n", "conversations": [{"role": "user", "content": "List NFTs on 'Ethereum' with name, contract address, token ID, and rarity score."}, {"role": "assistant", "content": "SELECT name, contract_address, token_id, rarity_score FROM nft_metadata WHERE blockchain = 'Ethereum';"}, {"role": "user", "content": "Add the collection name and floor price for each NFT's collection."}, {"role": "assistant", "content": "SELECT nm.name, nm.contract_address, nm.token_id, nm.rarity_score, nc.name AS collection_name, nc.floor_price FROM nft_metadata AS nm JOIN nft_collections AS nc ON nm.contract_address = nc.contract_address WHERE nm.blockchain = 'Ethereum';"}, {"role": "user", "content": "Only show NFTs where the collection's total token count is greater than 5000."}, {"role": "assistant", "content": "SELECT nm.name, nm.contract_address, nm.token_id, nm.rarity_score, nc.name AS collection_name, nc.floor_price FROM nft_metadata AS nm JOIN nft_collections AS nc ON nm.contract_address = nc.contract_address WHERE nm.blockchain = 'Ethereum' AND nc.token_count > 5000;"}, {"role": "user", "content": "Order the results by NFT rarity score descending and limit to the top 10."}, {"role": "assistant", "content": "SELECT nm.name, nm.contract_address, nm.token_id, nm.rarity_score, nc.name AS collection_name, nc.floor_price FROM nft_metadata AS nm JOIN nft_collections AS nc ON nm.contract_address = nc.contract_address WHERE nm.blockchain = 'Ethereum' AND nc.token_count > 5000 ORDER BY nm.rarity_score DESC LIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.accounts ( account_id text, customer_id text, account_number text, account_type text, balance numeric, currency text, opened_date date, status text, interest_rate numeric, last_updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List accounts that were opened in the same month and year as another account for the same customer, but have a different account type. Show the account_id, customer_id, account_type, and opened_date for these accounts."}, {"role": "assistant", "content": "SELECT T1.account_id , T1.customer_id , T1.account_type , T1.opened_date FROM financial_services.accounts AS T1 JOIN financial_services.accounts AS T2 ON T1.customer_id = T2.customer_id AND date_part('year', T1.opened_date) = date_part('year', T2.opened_date) AND date_part('month', T1.opened_date) = date_part('month', T2.opened_date) WHERE T1.account_id <> T2.account_id AND T1.account_type <> T2.account_type"}, {"role": "user", "content": "Only include pairs where the first account's balance is higher than the second account's balance."}, {"role": "assistant", "content": "SELECT T1.account_id , T1.customer_id , T1.account_type , T1.opened_date FROM financial_services.accounts AS T1 JOIN financial_services.accounts AS T2 ON T1.customer_id = T2.customer_id AND date_part('year', T1.opened_date) = date_part('year', T2.opened_date) AND date_part('month', T1.opened_date) = date_part('month', T2.opened_date) WHERE T1.account_id <> T2.account_id AND T1.account_type <> T2.account_type AND T1.balance > T2.balance"}, {"role": "user", "content": "I made a mistake, I want the second account's balance to be *lower* than the first account's balance."}, {"role": "assistant", "content": "SELECT T1.account_id , T1.customer_id , T1.account_type , T1.opened_date FROM financial_services.accounts AS T1 JOIN financial_services.accounts AS T2 ON T1.customer_id = T2.customer_id AND date_part('year', T1.opened_date) = date_part('year', T2.opened_date) AND date_part('month', T1.opened_date) = date_part('month', T2.opened_date) WHERE T1.account_id <> T2.account_id AND T1.account_type <> T2.account_type AND T2.balance < T1.balance"}, {"role": "user", "content": "Also, only show results where the account_type for the first account is 'Savings'."}, {"role": "assistant", "content": "SELECT T1.account_id , T1.customer_id , T1.account_type , T1.opened_date FROM financial_services.accounts AS T1 JOIN financial_services.accounts AS T2 ON T1.customer_id = T2.customer_id AND date_part('year', T1.opened_date) = date_part('year', T2.opened_date) AND date_part('month', T1.opened_date) = date_part('month', T2.opened_date) WHERE T1.account_id <> T2.account_id AND T1.account_type <> T2.account_type AND T2.balance < T1.balance AND T1.account_type = 'Savings'"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )\n", "conversations": [{"role": "user", "content": "List all peers whose IP address ends with '.255', showing their peer_id, ip_address, and last_seen timestamp."}, {"role": "assistant", "content": "SELECT peer_id, ip_address, last_seen FROM trading_platform.peers WHERE ip_address LIKE '%.255';"}, {"role": "user", "content": "From the list of peers whose IP ends with '.255', how many distinct port numbers are being used?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT port) FROM trading_platform.peers WHERE ip_address LIKE '%.255';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.games (\n game_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game\n title character varying(200) NOT NULL, -- official title of the game\n developer_id uuid NOT NULL, -- FK linking to the developers table\n publisher_id uuid, -- FK linking to a potential publishers table (optional)\n genre character varying(100), -- primary genre (e.g., RPG, FPS, Strategy)\n release_date date, -- official release date\n description text, -- short description or synopsis of the game\n platform character varying(50) NOT NULL, -- primary platform (e.g., PC, PlayStation 5, Xbox Series X, Mobile)\n engine character varying(100), -- game engine used (e.g., Unreal Engine 5, Unity)\n website character varying(255), -- official website URL\n PRIMARY KEY (game_id)\n -- FOREIGN KEY (developer_id) REFERENCES gaming_technology.developers(developer_id) -- Example FK constraint\n)\n", "conversations": [{"role": "user", "content": "List each genre and the number of games in that genre."}, {"role": "assistant", "content": "SELECT genre,\n COUNT(*) AS game_count\nFROM gaming_technology.games\nGROUP BY genre;"}, {"role": "user", "content": "Now filter to only include genres with more than 5 games."}, {"role": "assistant", "content": "SELECT genre,\n COUNT(*) AS game_count\nFROM gaming_technology.games\nGROUP BY genre\nHAVING COUNT(*) > 5;"}, {"role": "user", "content": "Exclude entries where genre is NULL."}, {"role": "assistant", "content": "SELECT genre,\n COUNT(*) AS game_count\nFROM gaming_technology.games\nWHERE genre IS NOT NULL\nGROUP BY genre\nHAVING COUNT(*) > 5;"}, {"role": "user", "content": "Finally, order the results by game_count in descending order."}, {"role": "assistant", "content": "SELECT genre,\n COUNT(*) AS game_count\nFROM gaming_technology.games\nWHERE genre IS NOT NULL\nGROUP BY genre\nHAVING COUNT(*) > 5\nORDER BY game_count DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\n", "conversations": [{"role": "user", "content": "List all drivers along with their status and license expiry date."}, {"role": "assistant", "content": "SELECT driver_id, first_name, last_name, status, license_expiry_date\nFROM transportation.drivers;"}, {"role": "user", "content": "Only show drivers whose status is 'Active'."}, {"role": "assistant", "content": "SELECT driver_id, first_name, last_name, status, license_expiry_date\nFROM transportation.drivers\nWHERE status = 'Active';"}, {"role": "user", "content": "Also, filter to only include drivers whose license_expiry_date is in the year 2025."}, {"role": "assistant", "content": "SELECT driver_id, first_name, last_name, status, license_expiry_date\nFROM transportation.drivers\nWHERE status = 'Active'\n AND EXTRACT(YEAR FROM license_expiry_date) = 2025;"}, {"role": "user", "content": "Sorry, order the results by license_expiry_date ascending."}, {"role": "assistant", "content": "SELECT driver_id, first_name, last_name, status, license_expiry_date\nFROM transportation.drivers\nWHERE status = 'Active'\n AND EXTRACT(YEAR FROM license_expiry_date) = 2025\nORDER BY license_expiry_date ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text PRIMARY KEY, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes int, type text )\nCREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text )\nCREATE TABLE transportation.locations ( location_id text PRIMARY KEY, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\nCREATE TABLE transportation.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date )\nCREATE TABLE transportation.passengers (\n passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger\n first_name character varying(128) NOT NULL, -- passenger's first name\n last_name character varying(128) NOT NULL, -- passenger's last name\n email character varying(128) UNIQUE, -- email address\n phone_number character varying(32) UNIQUE, -- phone number\n date_of_birth date, -- passenger's date of birth\n loyalty_program_id character varying(64), -- identifier for loyalty program membership\n created_at timestamp with time zone NOT NULL, -- time when the passenger record was created\n PRIMARY KEY (passenger_id)\n)\nCREATE TABLE transportation.bookings ( booking_id text, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )\n", "conversations": [{"role": "user", "content": "For each route, list the route_number, origin city, destination city, and the total fare collected from completed bookings."}, {"role": "assistant", "content": "SELECT\n r.route_number,\n lo.city AS origin_city,\n ld.city AS destination_city,\n SUM(b.fare) AS total_fare\nFROM transportation.routes r\nJOIN transportation.locations lo ON r.origin_location_id = lo.location_id\nJOIN transportation.locations ld ON r.destination_location_id = ld.location_id\nJOIN transportation.trips t ON t.route_id = r.route_id\nJOIN transportation.bookings b ON b.trip_id = t.trip_id\nWHERE b.status = 'Completed'\nGROUP BY r.route_number, lo.city, ld.city;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE project_fundraising_record ( id character varying(32) NOT NULL, -- fundraising record id project_id character varying(32) NOT NULL, -- the invested project's id project_name character varying(128) NOT NULL, -- name of the invested project rounds_name character varying(32), -- name of the fundraising round investment_value numeric(38,14), -- amount of the fundraising in USD investment_date character varying(128), -- the date of the investment happened introduction character varying(128), -- the introduction of the invested project valuation numeric(38,14), -- the valuation of the project in USD when invested )\n", "conversations": [{"role": "user", "content": "For projects that have completed more than one fundraising round, calculate the average investment value across all their recorded rounds. Display the project name and this average value."}, {"role": "assistant", "content": "SELECT project_name, AVG(investment_value) AS average_investment FROM project_fundraising_record GROUP BY project_name HAVING COUNT(*) > 1;"}, {"role": "user", "content": "Can you modify this to only show projects where the average investment value is greater than 10 million USD and order the results by average investment value descending?"}, {"role": "assistant", "content": "SELECT project_name, AVG(investment_value) AS average_investment FROM project_fundraising_record GROUP BY project_name HAVING COUNT(*) > 1 AND AVG(investment_value) > 10000000 ORDER BY average_investment DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text PRIMARY KEY, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )\nCREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) )\n", "conversations": [{"role": "user", "content": "List all active prescriptions for medication 'ibuprofen' with dosage greater than 200mg, including patient ID and doctor details."}, {"role": "assistant", "content": "SELECT p.patient_id, d.first_name, d.last_name, d.specialty, m.medication_name, p.dosage, p.start_date, p.end_date FROM healthcare.prescriptions p JOIN healthcare.doctors d ON p.doctor_id = d.doctor_id JOIN healthcare.medications m ON p.medication_id = m.medication_id WHERE m.medication_name = 'ibuprofen' AND p.dosage LIKE '%200mg%' AND (p.end_date IS NULL OR p.end_date > CURRENT_DATE);"}, {"role": "user", "content": "Actually, I need to see only prescriptions issued in the last 3 months."}, {"role": "assistant", "content": "SELECT p.patient_id, d.first_name, d.last_name, d.specialty, m.medication_name, p.dosage, p.start_date, p.end_date FROM healthcare.prescriptions p JOIN healthcare.doctors d ON p.doctor_id = d.doctor_id JOIN healthcare.medications m ON p.medication_id = m.medication_id WHERE m.medication_name = 'ibuprofen' AND p.dosage LIKE '%200mg%' AND p.start_date >= CURRENT_DATE - INTERVAL '3 months' AND (p.end_date IS NULL OR p.end_date > CURRENT_DATE);"}, {"role": "user", "content": "Can you also include the prescription frequency in the results?"}, {"role": "assistant", "content": "SELECT p.patient_id, d.first_name, d.last_name, d.specialty, m.medication_name, p.dosage, p.frequency, p.start_date, p.end_date FROM healthcare.prescriptions p JOIN healthcare.doctors d ON p.doctor_id = d.doctor_id JOIN healthcare.medications m ON p.medication_id = m.medication_id WHERE m.medication_name = 'ibuprofen' AND p.dosage LIKE '%200mg%' AND p.start_date >= CURRENT_DATE - INTERVAL '3 months' AND (p.end_date IS NULL OR p.end_date > CURRENT_DATE);"}]} -{"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE train_station_management.train_cars (\n car_id character varying(64) NOT NULL, -- Unique identifier for the train car\n train_id character varying(64) NOT NULL, -- Foreign key referencing trains\n car_number character varying(10) NOT NULL, -- Identifier of the car within the train set\n car_type character varying(64) NOT NULL, -- e.g., Locomotive, Passenger, Sleeper, Dining, Baggage\n class character varying(32), -- e.g., First, Business, Economy (null for non-passenger cars)\n capacity integer, -- Passenger capacity of this specific car (null for non-passenger cars)\n features text, -- Comma-separated list of features (e.g., 'WiFi', 'Power Outlet', 'Accessible Restroom')\n PRIMARY KEY (car_id),\n FOREIGN KEY (train_id) REFERENCES train_station_management.trains(train_id)\n)\n", "conversations": [{"role": "user", "content": "What is the current location of a specific train car with car_id 'TC123'?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide the current location of a specific train car as this information is not stored in the database table. The table only contains static details about train cars such as car type, capacity, and features. For real-time location data, please refer to the train tracking system or contact the relevant department."}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "List the user ID, theme, and updated_at for users who have updated their settings in the last 90 days and have their theme set to 'dark'."}, {"role": "assistant", "content": "SELECT user_id, theme, updated_at FROM social_media.user_settings WHERE updated_at >= NOW() - INTERVAL '90 days' AND theme = 'dark';"}, {"role": "user", "content": "Refine the list to only show users who have also disabled push notifications."}, {"role": "assistant", "content": "SELECT user_id, theme, updated_at FROM social_media.user_settings WHERE updated_at >= NOW() - INTERVAL '90 days' AND theme = 'dark' AND push_notifications_enabled = FALSE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List all insurance products with their product name and base premium, where the product description contains the word 'accident'."}, {"role": "assistant", "content": "SELECT product_name, base_premium FROM insurance.insurance_products WHERE description ILIKE '%accident%';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers (\n customer_id character varying(64) NOT NULL, -- unique identifier for the customer\n first_name character varying(100) NOT NULL, -- customer's first name\n last_name character varying(100) NOT NULL, -- customer's last name\n date_of_birth date NOT NULL, -- customer's date of birth\n ssn_hash character varying(128), -- Hashed social security number (or national ID)\n address_line1 character varying(255) NOT NULL,\n address_line2 character varying(255),\n city character varying(100) NOT NULL,\n state character varying(50) NOT NULL,\n zip_code character varying(20) NOT NULL,\n country character varying(50) NOT NULL DEFAULT 'USA',\n phone_number character varying(30),\n email character varying(128) UNIQUE, -- unique email address\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the customer record was created\n updated_at timestamp, -- when the customer record was last updated\n status character varying(20) NOT NULL DEFAULT 'Active', -- e.g., Active, Inactive, Prospect\n PRIMARY KEY (customer_id)\n)\n", "conversations": [{"role": "user", "content": "List all pairs of customers who live in the same zip_code. Show customer1_id, customer2_id, and zip_code."}, {"role": "assistant", "content": "SELECT\n c1.customer_id AS customer1_id,\n c2.customer_id AS customer2_id,\n c1.zip_code\nFROM insurance.customers c1\nJOIN insurance.customers c2\n ON c1.zip_code = c2.zip_code\n AND c1.customer_id <> c2.customer_id;"}, {"role": "user", "content": "Please also include both customers' email addresses in the results."}, {"role": "assistant", "content": "SELECT\n c1.customer_id AS customer1_id,\n c2.customer_id AS customer2_id,\n c1.zip_code,\n c1.email AS email1,\n c2.email AS email2\nFROM insurance.customers c1\nJOIN insurance.customers c2\n ON c1.zip_code = c2.zip_code\n AND c1.customer_id <> c2.customer_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\n", "conversations": [{"role": "user", "content": "Give me the list of DApp names and URLs whose description contains any asset symbol from the assets table."}, {"role": "assistant", "content": "SELECT DISTINCT d.name, d.url\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a ON d.description ILIKE '%' || a.symbol || '%';"}, {"role": "user", "content": "Could you also add the matching asset symbol in the result?"}, {"role": "assistant", "content": "SELECT DISTINCT d.name AS dapp_name, d.url, a.symbol AS asset_symbol\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a ON d.description ILIKE '%' || a.symbol || '%';"}, {"role": "user", "content": "Show only those DApps where the description contains more than one different asset symbol."}, {"role": "assistant", "content": "SELECT d.name AS dapp_name, d.url, COUNT(DISTINCT a.symbol) AS asset_symbol_count\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a ON d.description ILIKE '%' || a.symbol || '%'\nGROUP BY d.name, d.url\nHAVING COUNT(DISTINCT a.symbol) > 1;"}, {"role": "user", "content": "Now show for each such DApp: its name, URL, and the comma-separated list of matching asset symbols."}, {"role": "assistant", "content": "SELECT d.name AS dapp_name, d.url, STRING_AGG(DISTINCT a.symbol, ', ') AS asset_symbols\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a ON d.description ILIKE '%' || a.symbol || '%'\nGROUP BY d.name, d.url\nHAVING COUNT(DISTINCT a.symbol) > 1;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "List all patients who have had appointments with doctors specializing in 'Oncology', showing patient ID, patient first name, patient last name, doctor ID, doctor first name, and doctor last name."}, {"role": "assistant", "content": "SELECT\n p.patient_id,\n p.first_name AS patient_first_name,\n p.last_name AS patient_last_name,\n d.doctor_id,\n d.first_name AS doctor_first_name,\n d.last_name AS doctor_last_name\nFROM healthcare.patients AS p\nJOIN healthcare.appointments AS a\n ON p.patient_id = a.patient_id\nJOIN healthcare.doctors AS d\n ON a.doctor_id = d.doctor_id\nWHERE\n d.specialty = 'Oncology';"}, {"role": "user", "content": "From this list, only include appointments that occurred in the year 2024."}, {"role": "assistant", "content": "SELECT\n p.patient_id,\n p.first_name AS patient_first_name,\n p.last_name AS patient_last_name,\n d.doctor_id,\n d.first_name AS doctor_first_name,\n d.last_name AS doctor_last_name\nFROM healthcare.patients AS p\nJOIN healthcare.appointments AS a\n ON p.patient_id = a.patient_id\nJOIN healthcare.doctors AS d\n ON a.doctor_id = d.doctor_id\nWHERE\n d.specialty = 'Oncology' AND a.appointment_time >= '2024-01-01 00:00:00' AND a.appointment_time < '2025-01-01 00:00:00';"}, {"role": "user", "content": "Now, only show patients who have had at least 2 such appointments with Oncology doctors in 2024. Display patient ID, patient full name, and the count of these appointments."}, {"role": "assistant", "content": "SELECT\n p.patient_id,\n p.first_name,\n p.last_name,\n COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients AS p\nJOIN healthcare.appointments AS a\n ON p.patient_id = a.patient_id\nJOIN healthcare.doctors AS d\n ON a.doctor_id = d.doctor_id\nWHERE\n d.specialty = 'Oncology' AND a.appointment_time >= '2024-01-01 00:00:00' AND a.appointment_time < '2025-01-01 00:00:00'\nGROUP BY\n p.patient_id,\n p.first_name,\n p.last_name\nHAVING\n COUNT(a.appointment_id) >= 2;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc1155_approval_for_all (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction\n transaction_index integer NOT NULL, -- Index of the transaction within the block\n transaction_hash varchar(66) NOT NULL, -- Transaction hash\n log_index integer NOT NULL, -- Log index\n contract_address varchar(42) NOT NULL -- Event contract address\n)\nCREATE TABLE erc20_balances_historical (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract\n amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height\n pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))\n)\nCREATE TABLE nft_holders ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk varchar )\nCREATE TABLE sui_coins ( object_id varchar, status varchar, coin_type varchar, balance varchar, owner varchar )\nCREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_balances (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar NOT NULL, -- Token tick\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply decimal(38,0) NOT NULL, -- Max supply\n amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_info_avalanche (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar(20) NOT NULL, -- Ticker: Identifier of the inscription\n max_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription\n lim decimal(38,0) NOT NULL, -- Mint limit: limit per inscription\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL, -- Address originating the inscription (matches from_address in transactions table)\n minted decimal(38,0) NOT NULL, -- Sum of minted amount\n holders decimal(38,0) NOT NULL, -- Count of holders\n txs decimal(38,0) NOT NULL, -- Count of transactions\n updated_timestamp timestamp(3) NOT NULL, -- Timestamp of update\n completed_timestamp timestamp(3) NOT NULL, -- Timestamp of minted completed\n id varchar(255) NOT NULL -- id fields for the functionType in contract asc20\n)\n", "conversations": [{"role": "user", "content": "Show me the total balance and number of distinct holders for each Avalanche token, including its tick and creator address."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, SUM(tb.amount) AS total_balance, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nGROUP BY ti.tick, ti.creator;"}, {"role": "user", "content": "I also want to see the max_supply for each token in the result."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, ti.max_supply, SUM(tb.amount) AS total_balance, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nGROUP BY ti.tick, ti.creator, ti.max_supply;"}, {"role": "user", "content": "Only include tokens where max_supply is greater than 10000 and sort by total_balance descending."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, ti.max_supply, SUM(tb.amount) AS total_balance, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nWHERE ti.max_supply > 10000\nGROUP BY ti.tick, ti.creator, ti.max_supply\nORDER BY total_balance DESC;"}, {"role": "user", "content": "Add a column for the difference between max_supply and total_balance, call it available_supply."}, {"role": "assistant", "content": "SELECT ti.tick, ti.creator, ti.max_supply, SUM(tb.amount) AS total_balance, (ti.max_supply - SUM(tb.amount)) AS available_supply, COUNT(DISTINCT tb.wallet_address) AS holder_count\nFROM token_balances tb\nJOIN token_info_avalanche ti ON tb.tick = ti.tick\nWHERE ti.max_supply > 10000\nGROUP BY ti.tick, ti.creator, ti.max_supply\nORDER BY total_balance DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.agencies ( agency_id text PRIMARY KEY, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )\nCREATE TABLE government_services.services ( service_id.text, agency_id.text, service_name.text, description.text, category.text, eligibility_criteria.text, standard_fee.numeric, average_processing_time_days.integer, is_active.boolean, online_application_url.text )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text )\n", "conversations": [{"role": "user", "content": "Count the number of active services provided by each agency. Return the agency_name and the count of active services for each."}, {"role": "assistant", "content": "SELECT a.agency_name, COUNT(*) AS active_service_count\nFROM government_services.agencies AS a\nJOIN government_services.services AS s ON a.agency_id = s.agency_id\nWHERE s.is_active = TRUE\nGROUP BY a.agency_name;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List each reservation along with the next reservation for the same guest. Show the original reservation_id, its check_out_date, the next_reservation_id, and the next reservation's check_in_date."}, {"role": "assistant", "content": "SELECT r1.reservation_id,\n r1.check_out_date,\n r2.reservation_id AS next_reservation_id,\n r2.check_in_date AS next_check_in_date\nFROM hospitality_technology.reservations r1\nLEFT JOIN hospitality_technology.reservations r2\n ON r2.guest_id = r1.guest_id\n AND r2.check_in_date = (\n SELECT MIN(r3.check_in_date)\n FROM hospitality_technology.reservations r3\n WHERE r3.guest_id = r1.guest_id\n AND r3.check_in_date > r1.check_out_date\n );"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE train_station_management.train_cars (\n car_id character varying(64) NOT NULL, -- Unique identifier for the train car\n train_id character varying(64) NOT NULL, -- Foreign key referencing trains\n car_number character varying(10) NOT NULL, -- Identifier of the car within the train set\n car_type character varying(64) NOT NULL, -- e.g., Locomotive, Passenger, Sleeper, Dining, Baggage\n class character varying(32), -- e.g., First, Business, Economy (null for non-passenger cars)\n capacity integer, -- Passenger capacity of this specific car (null for non-passenger cars)\n features text, -- Comma-separated list of features (e.g., 'WiFi', 'Power Outlet', 'Accessible Restroom')\n PRIMARY KEY (car_id),\n FOREIGN KEY (train_id) REFERENCES train_station_management.trains(train_id)\n)\nCREATE TABLE train_station_management.routes (\n route_id character varying(64) NOT NULL, -- Unique identifier for the route\n route_name character varying(128) NOT NULL, -- Name of the route (e.g., 'Northeast Corridor')\n description text, -- Description of the route\n origin_station_id character varying(64) NOT NULL, -- Starting station\n destination_station_id character varying(64) NOT NULL, -- Final station\n is_active boolean NOT NULL DEFAULT true, -- Is the route currently operational?\n PRIMARY KEY (route_id),\n FOREIGN KEY (origin_station_id) REFERENCES train_station_management.stations(station_id),\n FOREIGN KEY (destination_station_id) REFERENCES train_station_management.stations(station_id)\n)\nCREATE TABLE train_station_management.tickets (\n ticket_id character varying(64) NOT NULL, -- Unique identifier for the ticket\n booking_id character varying(64) NOT NULL, -- Foreign key referencing the booking\n car_id character varying(64) NOT NULL, -- Foreign key referencing the train car\n seat_number character varying(10), -- Assigned seat number (e.g., '12A')\n ticket_type character varying(32) NOT NULL DEFAULT 'Adult', -- e.g., Adult, Child, Senior, Student\n price numeric(10, 2) NOT NULL, -- Price of this specific ticket\n is_checked_in boolean NOT NULL DEFAULT false, -- Has the passenger checked in with this ticket?\n qr_code_data text, -- Data for generating a QR code for the ticket\n PRIMARY KEY (ticket_id),\n FOREIGN KEY (booking_id) REFERENCES train_station_management.bookings(booking_id),\n FOREIGN KEY (car_id) REFERENCES train_station_management.train_cars(car_id)\n)\n", "conversations": [{"role": "user", "content": "Can you help me find the total passenger capacity for each train car on a specific route with route_id 'RT123'?"}, {"role": "assistant", "content": "SELECT tc.train_id, tc.car_id, tc.car_number, tc.capacity\nFROM train_station_management.train_cars tc\nJOIN train_station_management.trains t ON tc.train_id = t.train_id\nJOIN train_station_management.routes r ON t.route_id = r.route_id\nWHERE r.route_id = 'RT123' AND tc.capacity IS NOT NULL;"}, {"role": "user", "content": "Can you modify the query to include only passenger cars with a capacity greater than 50?"}, {"role": "assistant", "content": "SELECT tc.train_id, tc.car_id, tc.car_number, tc.capacity\nFROM train_station_management.train_cars tc\nJOIN train_station_management.trains t ON tc.train_id = t.train_id\nJOIN train_station_management.routes r ON t.route_id = r.route_id\nWHERE r.route_id = 'RT123' AND tc.capacity IS NOT NULL AND tc.capacity > 50;"}, {"role": "user", "content": "Can you also add the route name and description to the result?"}, {"role": "assistant", "content": "SELECT tc.train_id, tc.car_id, tc.car_number, tc.capacity, r.route_name, r.description\nFROM train_station_management.train_cars tc\nJOIN train_station_management.trains t ON tc.train_id = t.train_id\nJOIN train_station_management.routes r ON t.route_id = r.route_id\nWHERE r.route_id = 'RT123' AND tc.capacity IS NOT NULL AND tc.capacity > 50;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.payments ( payment_id.text, application_id.text, citizen_id.text, service_id.text, amount.numeric, currency.text, payment_method.text, payment_provider_reference.text, payment_timestamp.timestamp, status.text, notes.text )\n", "conversations": [{"role": "user", "content": "For each service ID, show the average and maximum payment amount for payments made in the last 90 days."}, {"role": "assistant", "content": "SELECT service_id, AVG(amount), MAX(amount) FROM government_services.payments WHERE payment_timestamp >= NOW() - INTERVAL '90 days' GROUP BY service_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )\n", "conversations": [{"role": "user", "content": "How many addresses on the Ethereum chain have an ROI between 2 and 4?"}, {"role": "assistant", "content": "SELECT COUNT(*) AS address_count FROM smart_money_profit WHERE chain = 'Ethereum' AND roi >= 2 AND roi <= 4;"}, {"role": "user", "content": "Could you also show their average profit?"}, {"role": "assistant", "content": "SELECT AVG(profit) AS avg_profit FROM smart_money_profit WHERE chain = 'Ethereum' AND roi >= 2 AND roi <= 4;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers (\n customer_id character varying(64) NOT NULL, -- unique identifier for the customer\n first_name character varying(100) NOT NULL, -- customer's first name\n last_name character varying(100) NOT NULL, -- customer's last name\n date_of_birth date NOT NULL, -- customer's date of birth\n ssn_hash character varying(128), -- Hashed social security number (or national ID)\n address_line1 character varying(255) NOT NULL,\n address_line2 character varying(255),\n city character varying(100) NOT NULL,\n state character varying(50) NOT NULL,\n zip_code character varying(20) NOT NULL,\n country character varying(50) NOT NULL DEFAULT 'USA',\n phone_number character varying(30),\n email character varying(128) UNIQUE, -- unique email address\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the customer record was created\n updated_at timestamp, -- when the customer record was last updated\n status character varying(20) NOT NULL DEFAULT 'Active', -- e.g., Active, Inactive, Prospect\n PRIMARY KEY (customer_id)\n)\nCREATE 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) )\nCREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, amount_paid numeric(12, 2) NOT NULL, payment_method character varying(50), transaction_reference character varying(128) UNIQUE, due_date date, payment_period_start date, payment_period_end date, status character varying(30) NOT NULL DEFAULT 'Completed', PRIMARY KEY (payment_id) )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "List all agents along with the first and last name of their manager."}, {"role": "assistant", "content": "SELECT a1.first_name AS agent_first_name, a1.last_name AS agent_last_name, a2.first_name AS manager_first_name, a2.last_name AS manager_last_name FROM insurance.agents AS a1 LEFT JOIN insurance.agents AS a2 ON a1.manager_id = a2.agent_id;"}, {"role": "user", "content": "Only include agents who were hired after the start of 2022."}, {"role": "assistant", "content": "SELECT a1.first_name AS agent_first_name, a1.last_name AS agent_last_name, a2.first_name AS manager_first_name, a2.last_name AS manager_last_name FROM insurance.agents AS a1 LEFT JOIN insurance.agents AS a2 ON a1.manager_id = a2.agent_id WHERE a1.hire_date > '2022-01-01';"}, {"role": "user", "content": "Order the results first by manager's last name, then by agent's last name."}, {"role": "assistant", "content": "SELECT a1.first_name AS agent_first_name, a1.last_name AS agent_last_name, a2.first_name AS manager_first_name, a2.last_name AS manager_last_name FROM insurance.agents AS a1 LEFT JOIN insurance.agents AS a2 ON a1.manager_id = a2.agent_id WHERE a1.hire_date > '2022-01-01' ORDER BY a2.last_name ASC, a1.last_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "List all wallets created before '2024-01-01', including the wallet_id, user_id, and creation date."}, {"role": "assistant", "content": "SELECT wallet_id, user_id, created_at FROM wallets WHERE created_at < '2024-01-01';"}, {"role": "user", "content": "Now, from that list, only include wallets belonging to users who also have created at least one wallet on or after '2024-01-01'."}, {"role": "assistant", "content": "SELECT w1.wallet_id, w1.user_id, w1.created_at FROM wallets w1 JOIN wallets w2 ON w1.user_id = w2.user_id WHERE w1.created_at < '2024-01-01' AND w2.created_at >= '2024-01-01' GROUP BY w1.wallet_id, w1.user_id, w1.created_at;"}, {"role": "user", "content": "For these users, show their user ID, the creation date of their earliest wallet created *before* '2024-01-01', and the creation date of their latest wallet created *on or after* '2024-01-01'."}, {"role": "assistant", "content": "SELECT user_id, MIN(CASE WHEN created_at < '2024-01-01' THEN created_at ELSE NULL END) AS earliest_before_2024, MAX(CASE WHEN created_at >= '2024-01-01' THEN created_at ELSE NULL END) AS latest_from_2024 FROM wallets GROUP BY user_id HAVING MIN(CASE WHEN created_at < '2024-01-01' THEN created_at ELSE NULL END) IS NOT NULL AND MAX(CASE WHEN created_at >= '2024-01-01' THEN created_at ELSE NULL END) IS NOT NULL;"}, {"role": "user", "content": "How many such users are there?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT user_id) FROM ( SELECT user_id FROM wallets WHERE created_at < '2024-01-01' GROUP BY user_id ) t1 JOIN ( SELECT user_id FROM wallets WHERE created_at >= '2024-01-01' GROUP BY user_id ) t2 ON t1.user_id = t2.user_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )\n", "conversations": [{"role": "user", "content": "Show me all group chats with their names and the time they were last active."}, {"role": "assistant", "content": "SELECT group_name, last_message_at FROM social_media.conversations WHERE is_group_chat = TRUE;"}, {"role": "user", "content": "Only show those group chats that were created after March 1, 2024."}, {"role": "assistant", "content": "SELECT group_name, last_message_at FROM social_media.conversations WHERE is_group_chat = TRUE AND created_at > '2024-03-01';"}, {"role": "user", "content": "Can you sort the results by last_message_at in descending order?"}, {"role": "assistant", "content": "SELECT group_name, last_message_at FROM social_media.conversations WHERE is_group_chat = TRUE AND created_at > '2024-03-01' ORDER BY last_message_at DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me the number of direct replies each top-level comment has on post 'P200'."}, {"role": "assistant", "content": "SELECT c.comment_id, COUNT(r.comment_id) AS reply_count FROM comments AS c LEFT JOIN comments AS r ON r.parent_comment_id = c.comment_id WHERE c.post_id = 'P200' AND c.parent_comment_id IS NULL GROUP BY c.comment_id;"}, {"role": "user", "content": "Order by reply_count descending and limit to top 5."}, {"role": "assistant", "content": "SELECT c.comment_id, COUNT(r.comment_id) AS reply_count FROM comments AS c LEFT JOIN comments AS r ON r.parent_comment_id = c.comment_id WHERE c.post_id = 'P200' AND c.parent_comment_id IS NULL GROUP BY c.comment_id ORDER BY reply_count DESC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.hashtags (\n hashtag_id character varying(64) NOT NULL, -- unique identifier for the hashtag\n tag_name character varying(100) NOT NULL UNIQUE, -- the actual hashtag text (without '#')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when the hashtag was first used\n PRIMARY KEY (hashtag_id)\n)\n", "conversations": [{"role": "user", "content": "List all hashtags created after '2024-06-01', showing hashtag_id and tag_name."}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name\nFROM social_media.hashtags\nWHERE created_at > '2024-06-01';"}, {"role": "user", "content": "Now also include the created_at timestamp and sort by created_at ascending."}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name, created_at\nFROM social_media.hashtags\nWHERE created_at > '2024-06-01'\nORDER BY created_at ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.fuel_logs (\n fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled\n trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred\n log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred\n fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type)\n quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh)\n unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh)\n cost_per_unit numeric(8, 4), -- price per unit of fuel\n total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase\n odometer_reading integer, -- vehicle mileage at time of fueling\n location_id character varying(64), -- identifier of the fueling station/location\n PRIMARY KEY (fuel_log_id)\n)\n", "conversations": [{"role": "user", "content": "For each trip, provide the trip_id, the total fuel quantity refueled, and the number of refueling events that occurred during the trip."}, {"role": "assistant", "content": "SELECT trip_id, SUM(quantity) AS total_fuel_quantity, COUNT(*) AS refuel_event_count\nFROM transportation.fuel_logs\nWHERE trip_id IS NOT NULL\nGROUP BY trip_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.passengers (\n passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger\n first_name character varying(128) NOT NULL, -- passenger's first name\n last_name character varying(128) NOT NULL, -- passenger's last name\n email character varying(128) UNIQUE, -- email address\n phone_number character varying(32) UNIQUE, -- phone number\n date_of_birth date, -- passenger's date of birth\n loyalty_program_id character varying(64), -- identifier for loyalty program membership\n created_at timestamp with time zone NOT NULL, -- time when the passenger record was created\n PRIMARY KEY (passenger_id)\n)\n", "conversations": [{"role": "user", "content": "Show the first and last name of each passenger along with the total number of bookings they have made."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(b.booking_id) AS booking_count FROM transportation.passengers p LEFT JOIN transportation.bookings b ON p.passenger_id = b.passenger_id GROUP BY p.passenger_id, p.first_name, p.last_name;"}, {"role": "user", "content": "Now, only include passengers who have made more than 5 bookings."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(b.booking_id) AS booking_count FROM transportation.passengers p JOIN transportation.bookings b ON p.passenger_id = b.passenger_id GROUP BY p.passenger_id, p.first_name, p.last_name HAVING COUNT(b.booking_id) > 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.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 )\n", "conversations": [{"role": "user", "content": "Show the number of staff members in each position and the average access level, grouping by position."}, {"role": "assistant", "content": "SELECT position,\n COUNT(*) AS staff_count,\n AVG(access_level) AS avg_access_level\nFROM hospitality_technology.staff\nGROUP BY position;"}, {"role": "user", "content": "Filter to only include positions where the average access level is greater than 4."}, {"role": "assistant", "content": "SELECT position,\n COUNT(*) AS staff_count,\n AVG(access_level) AS avg_access_level\nFROM hospitality_technology.staff\nGROUP BY position\nHAVING AVG(access_level) > 4;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date )\nCREATE TABLE transportation.passengers (\n passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger\n first_name character varying(128) NOT NULL, -- passenger's first name\n last_name character varying(128) NOT NULL, -- passenger's last name\n email character varying(128) UNIQUE, -- email address\n phone_number character varying(32) UNIQUE, -- phone number\n date_of_birth date, -- passenger's date of birth\n loyalty_program_id character varying(64), -- identifier for loyalty program membership\n created_at timestamp with time zone NOT NULL, -- time when the passenger record was created\n PRIMARY KEY (passenger_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the date of birth and email for all passengers."}, {"role": "assistant", "content": "SELECT date_of_birth, email FROM transportation.passengers;"}, {"role": "user", "content": "Can you also include their phone number and creation date?"}, {"role": "assistant", "content": "SELECT date_of_birth, email, phone_number, created_at FROM transportation.passengers;"}, {"role": "user", "content": "Only show passengers who were created after '2022-06-01'."}, {"role": "assistant", "content": "SELECT date_of_birth, email, phone_number, created_at FROM transportation.passengers WHERE created_at >= '2022-06-01';"}, {"role": "user", "content": "Order the results by creation date in descending order and limit to 10."}, {"role": "assistant", "content": "SELECT date_of_birth, email, phone_number, created_at FROM transportation.passengers WHERE created_at >= '2022-06-01' ORDER BY created_at DESC LIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.insurance_products ( product_id character varying(64) NOT NULL, product_name character varying(150) NOT NULL, product_type character varying(50) NOT NULL, description text, base_premium numeric(10, 2) NOT NULL, coverage_details text, underwriting_rules text, is_active boolean NOT NULL DEFAULT true, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, PRIMARY KEY (product_id) )\n", "conversations": [{"role": "user", "content": "Show the policy number, policy start date, and the name and type of the insurance product for all active policies."}, {"role": "assistant", "content": "SELECT p.policy_number, p.start_date, ip.product_name, ip.product_type FROM insurance.policies p JOIN insurance.insurance_products ip ON p.product_id = ip.product_id WHERE p.status = 'active';"}, {"role": "user", "content": "Could you also include the base premium of the product and only show policies where the product is also active?"}, {"role": "assistant", "content": "SELECT p.policy_number, p.start_date, ip.product_name, ip.product_type, ip.base_premium FROM insurance.policies p JOIN insurance.insurance_products ip ON p.product_id = ip.product_id WHERE p.status = 'active' AND ip.is_active = true;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.token_transfers (\n transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer\n token_id character varying(64) NOT NULL, -- identifier of the token being transferred\n from_address character varying(128) NOT NULL, -- address of the sender\n to_address character varying(128) NOT NULL, -- address of the receiver\n value numeric(38,14) NOT NULL, -- amount of tokens transferred\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer\n log_index integer NOT NULL, -- index of the transfer log in the transaction\n PRIMARY KEY (transfer_id)\n)\n", "conversations": [{"role": "user", "content": "Find cases where an address received tokens in one transfer and then sent tokens in another. List the receive transfer_id, the send transfer_id, the address, and both transfer values."}, {"role": "assistant", "content": "SELECT recv.transfer_id AS receive_transfer_id,\n send.transfer_id AS send_transfer_id,\n recv.to_address AS address,\n recv.value AS received_value,\n send.value AS sent_value\nFROM web3.token_transfers recv\nJOIN web3.token_transfers send\n ON recv.to_address = send.from_address;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE train_station_management.train_cars (\n car_id character varying(64) NOT NULL, -- Unique identifier for the train car\n train_id character varying(64) NOT NULL, -- Foreign key referencing trains\n car_number character varying(10) NOT NULL, -- Identifier of the car within the train set\n car_type character varying(64) NOT NULL, -- e.g., Locomotive, Passenger, Sleeper, Dining, Baggage\n class character varying(32), -- e.g., First, Business, Economy (null for non-passenger cars)\n capacity integer, -- Passenger capacity of this specific car (null for non-passenger cars)\n features text, -- Comma-separated list of features (e.g., 'WiFi', 'Power Outlet', 'Accessible Restroom')\n PRIMARY KEY (car_id),\n FOREIGN KEY (train_id) REFERENCES train_station_management.trains(train_id)\n)\nCREATE TABLE train_station_management.routes (\n route_id character varying(64) NOT NULL, -- Unique identifier for the route\n route_name character varying(128) NOT NULL, -- Name of the route (e.g., 'Northeast Corridor')\n description text, -- Description of the route\n origin_station_id character varying(64) NOT NULL, -- Starting station\n destination_station_id character varying(64) NOT NULL, -- Final station\n is_active boolean NOT NULL DEFAULT true, -- Is the route currently operational?\n PRIMARY KEY (route_id),\n FOREIGN KEY (origin_station_id) REFERENCES train_station_management.stations(station_id),\n FOREIGN KEY (destination_station_id) REFERENCES train_station_management.stations(station_id)\n)\nCREATE TABLE train_station_management.route_stations (\n route_station_id character varying(64) NOT NULL, -- Unique ID for this route-station link\n route_id character varying(64) NOT NULL, -- Foreign key referencing routes\n station_id character varying(64) NOT NULL, -- Foreign key referencing stations\n sequence_order integer NOT NULL, -- Order of the station in the route (1 for origin, 2, 3...)\n distance_from_previous_km numeric(10, 2), -- Distance from the previous station in the sequence\n typical_stop_duration_minutes integer, -- Typical dwell time at this station\n PRIMARY KEY (route_station_id),\n UNIQUE (route_id, station_id),\n UNIQUE (route_id, sequence_order),\n FOREIGN KEY (route_id) REFERENCES train_station_management.routes(route_id),\n FOREIGN KEY (station_id) REFERENCES train_station_management.stations(station_id)\n)\nCREATE TABLE train_station_management.schedules (\n schedule_id character varying(64) NOT NULL, -- Unique identifier for a specific scheduled trip\n train_id character varying(64) NOT NULL, -- Foreign key referencing the train used\n route_id character varying(64) NOT NULL, -- Foreign key referencing the route taken\n departure_datetime timestamp with time zone NOT NULL, -- Scheduled departure time from origin station\n arrival_datetime timestamp with time zone NOT NULL, -- Scheduled arrival time at destination station\n status character varying(32) NOT NULL DEFAULT 'Scheduled', -- e.g., Scheduled, On Time, Delayed, Cancelled, Arrived\n notes text, -- Any notes regarding this specific trip (e.g., reason for delay)\n PRIMARY KEY (schedule_id),\n FOREIGN KEY (train_id) REFERENCES train_station_management.trains(train_id),\n FOREIGN KEY (route_id) REFERENCES train_station_management.routes(route_id)\n)\nCREATE TABLE train_station_management.passengers (\n passenger_id character varying(64) NOT NULL, -- Unique identifier for the passenger\n first_name character varying(100) NOT NULL, -- Passenger's first name\n last_name character varying(100) NOT NULL, -- Passenger's last name\n email character varying(128) UNIQUE, -- Passenger's email address\n phone_number character varying(32) UNIQUE, -- Passenger's phone number\n date_of_birth date, -- Passenger's date of birth\n loyalty_program_id character varying(64), -- ID for loyalty program, if applicable\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- When the passenger record was created\n PRIMARY KEY (passenger_id)\n)\nCREATE TABLE train_station_management.bookings (\n booking_id character varying(64) NOT NULL, -- Unique identifier for the booking\n passenger_id character varying(64) NOT NULL, -- Foreign key referencing the passenger\n schedule_id character varying(64) NOT NULL, -- Foreign key referencing the scheduled trip\n booking_datetime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- When the booking was made\n status character varying(32) NOT NULL DEFAULT 'Confirmed', -- e.g., Confirmed, Cancelled, Pending\n total_price numeric(12, 2) NOT NULL, -- Total price for all tickets in this booking\n currency_code character varying(3) NOT NULL DEFAULT 'USD', -- Currency of the price\n special_requests text, -- Any special requests (e.g., wheelchair assistance)\n PRIMARY KEY (booking_id),\n FOREIGN KEY (passenger_id) REFERENCES train_station_management.passengers(passenger_id),\n FOREIGN KEY (schedule_id) REFERENCES train_station_management.schedules(schedule_id)\n)\nCREATE TABLE train_station_management.staff (\n staff_id character varying(64) NOT NULL, -- Unique identifier for the staff member\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n role character varying(64) NOT NULL, -- e.g., Station Master, Ticket Agent, Conductor, Engineer, Maintenance Crew\n primary_station_id character varying(64), -- Base station for the staff member (nullable for mobile staff)\n employee_number character varying(32) UNIQUE NOT NULL, -- Unique employee identifier\n hire_date date NOT NULL,\n contact_email character varying(128) UNIQUE,\n contact_phone character varying(32),\n is_active boolean NOT NULL DEFAULT true, -- Is the staff member currently employed?\n PRIMARY KEY (staff_id),\n FOREIGN KEY (primary_station_id) REFERENCES train_station_management.stations(station_id)\n)\n", "conversations": [{"role": "user", "content": "Can you assist me in finding all staff members assigned to schedules for a specific route with route_id 'RT456', including the train details and schedule status?"}, {"role": "assistant", "content": "SELECT st.staff_id, st.first_name, st.last_name, st.role, s.schedule_id, s.status, t.train_id\nFROM train_station_management.staff st\nJOIN train_station_management.schedules s ON s.train_id = st.primary_station_id\nJOIN train_station_management.trains t ON s.train_id = t.train_id\nWHERE s.route_id = 'RT456';"}, {"role": "user", "content": "I noticed the query might not be correct. Can you revise it to ensure it connects staff to schedules properly through their primary station or related data?"}, {"role": "assistant", "content": "SELECT st.staff_id, st.first_name, st.last_name, st.role, s.schedule_id, s.status, t.train_id\nFROM train_station_management.staff st\nJOIN train_station_management.route_stations rs ON st.primary_station_id = rs.station_id\nJOIN train_station_management.schedules s ON s.route_id = rs.route_id\nJOIN train_station_management.trains t ON s.train_id = t.train_id\nWHERE s.route_id = 'RT456';"}, {"role": "user", "content": "Can you filter the results to include only staff with the role of 'Engineer' and schedules with status 'On Time'?"}, {"role": "assistant", "content": "SELECT st.staff_id, st.first_name, st.last_name, st.role, s.schedule_id, s.status, t.train_id\nFROM train_station_management.staff st\nJOIN train_station_management.route_stations rs ON st.primary_station_id = rs.station_id\nJOIN train_station_management.schedules s ON s.route_id = rs.route_id\nJOIN train_station_management.trains t ON s.train_id = t.train_id\nWHERE s.route_id = 'RT456' AND st.role = 'Engineer' AND s.status = 'On Time';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.employees ( employee_id.text, agency_id.text, first_name.text, last_name.text, job_title.text, department.text, work_email.text, work_phone.text, hire_date.date, termination_date.date, access_level.text, manager_employee_id.text )\n", "conversations": [{"role": "user", "content": "For each access level, count the number of employees. Return access_level and the corresponding employee_count."}, {"role": "assistant", "content": "SELECT access_level, COUNT(*) AS employee_count FROM government_services.employees GROUP BY access_level;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "List all reservations that have made multiple payment transactions. Return reservation_id and payment_id for each occurrence."}, {"role": "assistant", "content": "SELECT DISTINCT p1.reservation_id, p1.payment_id\nFROM hospitality_technology.payments p1\nJOIN hospitality_technology.payments p2\n ON p1.reservation_id = p2.reservation_id\n AND p1.payment_id != p2.payment_id\nORDER BY p1.reservation_id, p1.payment_id;"}, {"role": "user", "content": "Now show only those reservation groups where at least one payment has status 'Failed'."}, {"role": "assistant", "content": "SELECT DISTINCT p1.reservation_id, p1.payment_id\nFROM hospitality_technology.payments p1\nJOIN hospitality_technology.payments p2\n ON p1.reservation_id = p2.reservation_id\nWHERE EXISTS (\n SELECT 1 FROM hospitality_technology.payments pm\n WHERE pm.reservation_id = p1.reservation_id AND pm.status = 'Failed'\n)\nORDER BY p1.reservation_id, p1.payment_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.comments ( comment_id text, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )\nCREATE TABLE social_media.likes ( like_id text, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.follows ( follow_id text, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.messages ( message_id text, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp )\nCREATE TABLE social_media.conversations ( conversation_id text, created_at timestamp, last_message_at timestamp, is_group_chat boolean, group_name text )\nCREATE TABLE social_media.conversation_participants ( participant_id text, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\n", "conversations": [{"role": "user", "content": "I need to find users who follow both 'U100' and 'U200'. Show the follower_user_id and the creation dates of both follow events."}, {"role": "assistant", "content": "SELECT f1.follower_user_id,\n f1.created_at AS follow_u100_at,\n f2.created_at AS follow_u200_at\nFROM social_media.follows f1\nJOIN social_media.follows f2\n ON f1.follower_user_id = f2.follower_user_id\nWHERE f1.following_user_id = 'U100'\n AND f2.following_user_id = 'U200';"}, {"role": "user", "content": "Actually, only include cases where both follow events occurred in the same calendar month."}, {"role": "assistant", "content": "SELECT f1.follower_user_id,\n f1.created_at AS follow_u100_at,\n f2.created_at AS follow_u200_at\nFROM social_media.follows f1\nJOIN social_media.follows f2\n ON f1.follower_user_id = f2.follower_user_id\n AND DATE_TRUNC('month', f1.created_at) = DATE_TRUNC('month', f2.created_at)\nWHERE f1.following_user_id = 'U100'\n AND f2.following_user_id = 'U200';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.services ( service_id text 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 )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\nCREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "Show the full name and contact email of citizens who have submitted at least one application for services that are currently inactive."}, {"role": "assistant", "content": "SELECT DISTINCT c.first_name || ' ' || c.last_name AS full_name, c.contact_email\nFROM government_services.citizens c\nJOIN government_services.applications a ON c.citizen_id = a.citizen_id\nJOIN government_services.services s ON a.service_id = s.service_id\nWHERE s.is_active = FALSE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.game_sessions ( session_id.uuid, player_id.uuid, game_id.uuid, server_id.uuid, start_time.timestamptz, end_time.timestamptz, duration_seconds.integer, score.integer, session_data.jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\n", "conversations": [{"role": "user", "content": "How many servers are in each region, and what's the average number of current players for those servers?"}, {"role": "assistant", "content": "SELECT\n region,\n COUNT(server_id) AS server_count,\n AVG(current_players) AS average_current_players\nFROM gaming_technology.servers\nGROUP BY\n region;"}, {"role": "user", "content": "Only include regions with more than 5 servers."}, {"role": "assistant", "content": "SELECT\n region,\n COUNT(server_id) AS server_count,\n AVG(current_players) AS average_current_players\nFROM gaming_technology.servers\nGROUP BY\n region\nHAVING\n COUNT(server_id) > 5;"}, {"role": "user", "content": "Also, include the total maximum players capacity for each of these regions."}, {"role": "assistant", "content": "SELECT\n region,\n COUNT(server_id) AS server_count,\n AVG(current_players) AS average_current_players,\n SUM(max_players) AS total_max_players\nFROM gaming_technology.servers\nGROUP BY\n region\nHAVING\n COUNT(server_id) > 5;"}, {"role": "user", "content": "Order the results by the average current players in descending order."}, {"role": "assistant", "content": "SELECT\n region,\n COUNT(server_id) AS server_count,\n AVG(current_players) AS average_current_players,\n SUM(max_players) AS total_max_players\nFROM gaming_technology.servers\nGROUP BY\n region\nHAVING\n COUNT(server_id) > 5\nORDER BY\n average_current_players DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool )\n", "conversations": [{"role": "user", "content": "How many users have non-empty full_name and bio fields? Return only the count."}, {"role": "assistant", "content": "SELECT COUNT(*)\nFROM social_media.users\nWHERE full_name IS NOT NULL\n AND full_name <> ''\n AND bio IS NOT NULL\n AND bio <> '';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\n", "conversations": [{"role": "user", "content": "List all room numbers, their type names, and base rates for rooms located on floor 5."}, {"role": "assistant", "content": "SELECT T1.room_number, T2.type_name, T2.base_rate FROM hospitality_technology.rooms AS T1 JOIN hospitality_technology.room_types AS T2 ON T1.room_type_id = T2.room_type_id WHERE T1.floor = 5;"}, {"role": "user", "content": "Now, only include those with the feature 'Sea View' and are currently 'Available'. Sort the results by base rate ascending."}, {"role": "assistant", "content": "SELECT T1.room_number, T2.type_name, T2.base_rate FROM hospitality_technology.rooms AS T1 JOIN hospitality_technology.room_types AS T2 ON T1.room_type_id = T2.room_type_id WHERE T1.floor = 5 AND T1.features LIKE '%Sea View%' AND T1.status = 'Available' ORDER BY T2.base_rate ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\nCREATE TABLE gaming_technology.achievements ( achievement_id uuid, game_id uuid, name text, description text, icon_url text, points integer, hidden boolean )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid, player_id uuid, item_id uuid, quantity integer, acquired_at timestamp with time zone, instance_data jsonb )\n", "conversations": [{"role": "user", "content": "Can you show me each player's total number of achievements unlocked and the total quantity of items they have in inventory for each game they've played?"}, {"role": "assistant", "content": "SELECT pa.player_id, a.game_id, COUNT(DISTINCT pa.achievement_id) AS achievements_unlocked, COALESCE(SUM(pi.quantity),0) AS total_items\nFROM gaming_technology.player_achievements pa\nJOIN gaming_technology.achievements a ON pa.achievement_id = a.achievement_id\nLEFT JOIN gaming_technology.in_game_items i ON a.game_id = i.game_id\nLEFT JOIN gaming_technology.player_inventory pi ON pi.player_id = pa.player_id AND pi.item_id = i.item_id\nGROUP BY pa.player_id, a.game_id;"}, {"role": "user", "content": "Can you filter the results to only include games where the player has unlocked at least 5 achievements?"}, {"role": "assistant", "content": "SELECT pa.player_id, a.game_id, COUNT(DISTINCT pa.achievement_id) AS achievements_unlocked, COALESCE(SUM(pi.quantity),0) AS total_items\nFROM gaming_technology.player_achievements pa\nJOIN gaming_technology.achievements a ON pa.achievement_id = a.achievement_id\nLEFT JOIN gaming_technology.in_game_items i ON a.game_id = i.game_id\nLEFT JOIN gaming_technology.player_inventory pi ON pi.player_id = pa.player_id AND pi.item_id = i.item_id\nGROUP BY pa.player_id, a.game_id\nHAVING COUNT(DISTINCT pa.achievement_id) >= 5;"}, {"role": "user", "content": "Also, for each player and game, show the total score the player achieved across all sessions in that game."}, {"role": "assistant", "content": "SELECT res.player_id, res.game_id, res.achievements_unlocked, res.total_items,\n COALESCE(SUM(gs.score),0) AS total_score\nFROM (\n SELECT pa.player_id, a.game_id, COUNT(DISTINCT pa.achievement_id) AS achievements_unlocked, COALESCE(SUM(pi.quantity),0) AS total_items\n FROM gaming_technology.player_achievements pa\n JOIN gaming_technology.achievements a ON pa.achievement_id = a.achievement_id\n LEFT JOIN gaming_technology.in_game_items i ON a.game_id = i.game_id\n LEFT JOIN gaming_technology.player_inventory pi ON pi.player_id = pa.player_id AND pi.item_id = i.item_id\n GROUP BY pa.player_id, a.game_id\n HAVING COUNT(DISTINCT pa.achievement_id) >= 5\n) res\nLEFT JOIN gaming_technology.game_sessions gs ON res.player_id = gs.player_id AND res.game_id = gs.game_id\nGROUP BY res.player_id, res.game_id, res.achievements_unlocked, res.total_items;"}, {"role": "user", "content": "Limit the results to only show player-game pairs where total_score is greater than 500."}, {"role": "assistant", "content": "SELECT res.player_id, res.game_id, res.achievements_unlocked, res.total_items,\n COALESCE(SUM(gs.score),0) AS total_score\nFROM (\n SELECT pa.player_id, a.game_id, COUNT(DISTINCT pa.achievement_id) AS achievements_unlocked, COALESCE(SUM(pi.quantity),0) AS total_items\n FROM gaming_technology.player_achievements pa\n JOIN gaming_technology.achievements a ON pa.achievement_id = a.achievement_id\n LEFT JOIN gaming_technology.in_game_items i ON a.game_id = i.game_id\n LEFT JOIN gaming_technology.player_inventory pi ON pi.player_id = pa.player_id AND pi.item_id = i.item_id\n GROUP BY pa.player_id, a.game_id\n HAVING COUNT(DISTINCT pa.achievement_id) >= 5\n) res\nLEFT JOIN gaming_technology.game_sessions gs ON res.player_id = gs.player_id AND res.game_id = gs.game_id\nGROUP BY res.player_id, res.game_id, res.achievements_unlocked, res.total_items\nHAVING COALESCE(SUM(gs.score),0) > 500;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "For each patient, find the next appointment after each one. Return patient_id, appointment_id AS current_appointment, next_appointment_id, and waiting_time in minutes."}, {"role": "assistant", "content": "SELECT a.patient_id,\n a.appointment_id AS current_appointment,\n b.appointment_id AS next_appointment_id,\n EXTRACT(EPOCH FROM (b.appointment_time - a.appointment_time)) / 60 AS waiting_time\nFROM healthcare.appointments a\nJOIN healthcare.appointments b\n ON a.patient_id = b.patient_id\n AND b.appointment_time = (\n SELECT MIN(appointment_time)\n FROM healthcare.appointments\n WHERE patient_id = a.patient_id\n AND appointment_time > a.appointment_time\n ) ;"}, {"role": "user", "content": "Only include waiting times less than 30 minutes."}, {"role": "assistant", "content": "SELECT a.patient_id,\n a.appointment_id AS current_appointment,\n b.appointment_id AS next_appointment_id,\n EXTRACT(EPOCH FROM (b.appointment_time - a.appointment_time)) / 60 AS waiting_time\nFROM healthcare.appointments a\nJOIN healthcare.appointments b\n ON a.patient_id = b.patient_id\n AND b.appointment_time = (\n SELECT MIN(appointment_time)\n FROM healthcare.appointments\n WHERE patient_id = a.patient_id\n AND appointment_time > a.appointment_time\n )\nWHERE EXTRACT(EPOCH FROM (b.appointment_time - a.appointment_time)) / 60 < 30;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all appointments for the client with ID 'client_001' showing the lawyer's ID, appointment subject, and start time."}, {"role": "assistant", "content": "SELECT a.lawyer_id, a.subject, a.start_time\nFROM legal_services.appointments a\nWHERE a.client_id = 'client_001';"}, {"role": "user", "content": "Actually, please also include the case ID in the results."}, {"role": "assistant", "content": "SELECT a.lawyer_id, a.subject, a.start_time, a.case_id\nFROM legal_services.appointments a\nWHERE a.client_id = 'client_001';"}, {"role": "user", "content": "Now, sort the results by start time from newest to oldest."}, {"role": "assistant", "content": "SELECT a.lawyer_id, a.subject, a.start_time, a.case_id\nFROM legal_services.appointments a\nWHERE a.client_id = 'client_001'\nORDER BY a.start_time DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )\n", "conversations": [{"role": "user", "content": "Can you find all mutual follows in the system by joining the table with itself? For each mutual follow, show both user IDs and the date when the follow occurred."}, {"role": "assistant", "content": "SELECT f1.follower_user_id AS user_a, f1.following_user_id AS user_b, f1.created_at\nFROM social_media.follows f1\nJOIN social_media.follows f2\n ON f1.follower_user_id = f2.following_user_id\n AND f1.following_user_id = f2.follower_user_id;"}, {"role": "user", "content": "Only include mutual follows that were established in 2024."}, {"role": "assistant", "content": "SELECT f1.follower_user_id AS user_a, f1.following_user_id AS user_b, f1.created_at\nFROM social_media.follows f1\nJOIN social_media.follows f2\n ON f1.follower_user_id = f2.following_user_id\n AND f1.following_user_id = f2.follower_user_id\nWHERE DATE_PART('year', f1.created_at) = 2024;"}, {"role": "user", "content": "Sort the results by creation date descending."}, {"role": "assistant", "content": "SELECT f1.follower_user_id AS user_a, f1.following_user_id AS user_b, f1.created_at\nFROM social_media.follows f1\nJOIN social_media.follows f2\n ON f1.follower_user_id = f2.following_user_id\n AND f1.following_user_id = f2.follower_user_id\nWHERE DATE_PART('year', f1.created_at) = 2024\nORDER BY f1.created_at DESC;"}, {"role": "user", "content": "Also include the follow IDs of both entries in the output."}, {"role": "assistant", "content": "SELECT f1.follow_id AS follow_id_a, f2.follow_id AS follow_id_b, f1.follower_user_id AS user_a, f1.following_user_id AS user_b, f1.created_at\nFROM social_media.follows f1\nJOIN social_media.follows f2\n ON f1.follower_user_id = f2.following_user_id\n AND f1.following_user_id = f2.follower_user_id\nWHERE DATE_PART('year', f1.created_at) = 2024\nORDER BY f1.created_at DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.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 )\n", "conversations": [{"role": "user", "content": "List all posts where the content mentions 'meeting'."}, {"role": "assistant", "content": "SELECT post_id, user_id, content, created_at FROM social_media.posts WHERE content LIKE '%meeting%'"}, {"role": "user", "content": "Also, only include those posts that are public."}, {"role": "assistant", "content": "SELECT post_id, user_id, content, created_at FROM social_media.posts WHERE content LIKE '%meeting%' AND visibility = 'public'"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.documents ( document_id.text, case_id.text, document_name.text, document_type.text, storage_path.text, uploaded_by_lawyer_id.text, upload_timestamp.timestamp, version.integer, description.text )\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Give me the case_id and the count of appointments and documents for each case where at least one appointment exists."}, {"role": "assistant", "content": "SELECT a.case_id, COUNT(DISTINCT a.appointment_id) AS appointment_count, COUNT(DISTINCT d.document_id) AS document_count\nFROM legal_services.appointments a\nLEFT JOIN legal_services.documents d ON a.case_id = d.case_id\nGROUP BY a.case_id\nHAVING COUNT(DISTINCT a.appointment_id) > 0;"}, {"role": "user", "content": "Only show cases where the document count is at least 2 and order by document_count descending."}, {"role": "assistant", "content": "SELECT a.case_id, COUNT(DISTINCT a.appointment_id) AS appointment_count, COUNT(DISTINCT d.document_id) AS document_count\nFROM legal_services.appointments a\nLEFT JOIN legal_services.documents d ON a.case_id = d.case_id\nGROUP BY a.case_id\nHAVING COUNT(DISTINCT d.document_id) >= 2\nORDER BY document_count DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id text, license_plate text, vin text, make text, model text, year integer, type text, capacity integer, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.maintenance_logs ( log_id text, vehicle_id text, service_date date, odometer_reading integer, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text )\nCREATE TABLE transportation.passengers ( passenger_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\nCREATE TABLE transportation.bookings ( booking_id text, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )\n", "conversations": [{"role": "user", "content": "List all bookings with the first and last name of the passenger and trip_id."}, {"role": "assistant", "content": "SELECT b.booking_id, b.trip_id, p.first_name, p.last_name\nFROM transportation.bookings b\nJOIN transportation.passengers p ON b.passenger_id = p.passenger_id;"}, {"role": "user", "content": "Add the date when the booking was made and the booking status."}, {"role": "assistant", "content": "SELECT b.booking_id, b.trip_id, p.first_name, p.last_name, b.booking_time, b.status\nFROM transportation.bookings b\nJOIN transportation.passengers p ON b.passenger_id = p.passenger_id;"}, {"role": "user", "content": "Filter to only show bookings where the status is either 'Pending' or 'Confirmed'."}, {"role": "assistant", "content": "SELECT b.booking_id, b.trip_id, p.first_name, p.last_name, b.booking_time, b.status\nFROM transportation.bookings b\nJOIN transportation.passengers p ON b.passenger_id = p.passenger_id\nWHERE b.status IN ('Pending', 'Confirmed');"}, {"role": "user", "content": "Can you sort the results by booking_time in descending order and limit to the 10 most recent?"}, {"role": "assistant", "content": "SELECT b.booking_id, b.trip_id, p.first_name, p.last_name, b.booking_time, b.status\nFROM transportation.bookings b\nJOIN transportation.passengers p ON b.passenger_id = p.passenger_id\nWHERE b.status IN ('Pending', 'Confirmed')\nORDER BY b.booking_time DESC\nLIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\n", "conversations": [{"role": "user", "content": "List all service orders with quantity greater than 3, showing the order ID, total price, and the staff member who placed the order."}, {"role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered\nFROM hospitality_technology.service_orders\nWHERE quantity > 3;"}, {"role": "user", "content": "Please add the delivery timestamp, and only show orders that were actually delivered (delivery_timestamp is not null)."}, {"role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered, delivery_timestamp\nFROM hospitality_technology.service_orders\nWHERE quantity > 3\n AND delivery_timestamp IS NOT NULL;"}, {"role": "user", "content": "Now, show only those orders where the delivered staff is different from the ordered staff, and sort by delivery timestamp ascending."}, {"role": "assistant", "content": "SELECT order_id, total_price, staff_id_ordered, staff_id_delivered, delivery_timestamp\nFROM hospitality_technology.service_orders\nWHERE quantity > 3\n AND delivery_timestamp IS NOT NULL\n AND staff_id_ordered <> staff_id_delivered\nORDER BY delivery_timestamp ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE train_station_management.train_cars (\n car_id character varying(64) NOT NULL, -- Unique identifier for the train car\n train_id character varying(64) NOT NULL, -- Foreign key referencing trains\n car_number character varying(10) NOT NULL, -- Identifier of the car within the train set\n car_type character varying(64) NOT NULL, -- e.g., Locomotive, Passenger, Sleeper, Dining, Baggage\n class character varying(32), -- e.g., First, Business, Economy (null for non-passenger cars)\n capacity integer, -- Passenger capacity of this specific car (null for non-passenger cars)\n features text, -- Comma-separated list of features (e.g., 'WiFi', 'Power Outlet', 'Accessible Restroom')\n PRIMARY KEY (car_id),\n FOREIGN KEY (train_id) REFERENCES train_station_management.trains(train_id)\n)\nCREATE TABLE train_station_management.routes (\n route_id character varying(64) NOT NULL, -- Unique identifier for the route\n route_name character varying(128) NOT NULL, -- Name of the route (e.g., 'Northeast Corridor')\n description text, -- Description of the route\n origin_station_id character varying(64) NOT NULL, -- Starting station\n destination_station_id character varying(64) NOT NULL, -- Final station\n is_active boolean NOT NULL DEFAULT true, -- Is the route currently operational?\n PRIMARY KEY (route_id),\n FOREIGN KEY (origin_station_id) REFERENCES train_station_management.stations(station_id),\n FOREIGN KEY (destination_station_id) REFERENCES train_station_management.stations(station_id)\n)\nCREATE TABLE train_station_management.tickets (\n ticket_id character varying(64) NOT NULL, -- Unique identifier for the ticket\n booking_id character varying(64) NOT NULL, -- Foreign key referencing the booking\n car_id character varying(64) NOT NULL, -- Foreign key referencing the train car\n seat_number character varying(10), -- Assigned seat number (e.g., '12A')\n ticket_type character varying(32) NOT NULL DEFAULT 'Adult', -- e.g., Adult, Child, Senior, Student\n price numeric(10, 2) NOT NULL, -- Price of this specific ticket\n is_checked_in boolean NOT NULL DEFAULT false, -- Has the passenger checked in with this ticket?\n qr_code_data text, -- Data for generating a QR code for the ticket\n PRIMARY KEY (ticket_id),\n FOREIGN KEY (booking_id) REFERENCES train_station_management.bookings(booking_id),\n FOREIGN KEY (car_id) REFERENCES train_station_management.train_cars(car_id)\n)\n", "conversations": [{"role": "user", "content": "Can you retrieve the total number of tickets sold for each car type?"}, {"role": "assistant", "content": "SELECT tc.car_type, COUNT(t.ticket_id) AS total_tickets\nFROM train_station_management.train_cars tc\nJOIN train_station_management.tickets t ON tc.car_id = t.car_id\nGROUP BY tc.car_type;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk integer )\nCREATE TABLE nft_holders ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk varchar )\nCREATE TABLE sui_coins ( object_id varchar, status varchar, coin_type varchar, balance varchar, owner varchar )\nCREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar )\nCREATE TABLE nft_metadata ( blockchain varchar, contract_address varchar, token_id varchar, contract_name varchar, erc_type varchar, amount bigint, minter varchar, owner varchar, mint_block_number bigint, mint_time bigint, mint_transaction_hash varchar, mint_price varchar, token_uri varchar, metadata varchar, name varchar, image_uri varchar, traits varchar, updated_at bigint, status varchar, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE nft_collections ( blockchain varchar, contract_address varchar, name varchar, symbol varchar, deploy_block_number bigint, deploy_block_time bigint, erc_type varchar, owner varchar, traits varchar, description varchar, slug varchar, media_info varchar, image_url varchar, banner_image_url varchar, updated_at bigint, banner varchar, token_count bigint, floor_price varchar, floor_price_symbol varchar, floor_price_contract varchar, pk integer )\nCREATE TABLE token_prices ( uuid varchar, blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest ( blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\nCREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE mud_holesky_redstone ( address varchar, table_id varchar, key_bytes varchar, key0 varchar, key1 varchar, static_data varchar, encoded_lengths varchar, dynamic_data varchar, is_deleted boolean, block_number bigint, log_index bigint )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )\n", "conversations": [{"role": "user", "content": "Get the total transfer volume and number of transfers for each Avalanche token tick over the past 7 days."}, {"role": "assistant", "content": "SELECT a.tick,\n SUM(a.amt) AS total_volume,\n COUNT(*) AS transfer_count\nFROM token_activities_avalanche a\nWHERE a.block_timestamp >= CURRENT_TIMESTAMP - INTERVAL '7 days'\nGROUP BY a.tick;"}, {"role": "user", "content": "Include the creator for each token by joining with token_info_avalanche."}, {"role": "assistant", "content": "SELECT a.tick,\n ti.creator,\n SUM(a.amt) AS total_volume,\n COUNT(*) AS transfer_count\nFROM token_activities_avalanche a\nJOIN token_info_avalanche ti\n ON a.tick = ti.tick\nWHERE a.block_timestamp >= CURRENT_TIMESTAMP - INTERVAL '7 days'\nGROUP BY a.tick, ti.creator;"}, {"role": "user", "content": "Only show tokens with total_volume > 10000 and sort by total_volume descending."}, {"role": "assistant", "content": "SELECT a.tick,\n ti.creator,\n SUM(a.amt) AS total_volume,\n COUNT(*) AS transfer_count\nFROM token_activities_avalanche a\nJOIN token_info_avalanche ti\n ON a.tick = ti.tick\nWHERE a.block_timestamp >= CURRENT_TIMESTAMP - INTERVAL '7 days'\nGROUP BY a.tick, ti.creator\nHAVING SUM(a.amt) > 10000\nORDER BY total_volume DESC;"}, {"role": "user", "content": "Limit the results to the top 10 tokens."}, {"role": "assistant", "content": "SELECT a.tick,\n ti.creator,\n SUM(a.amt) AS total_volume,\n COUNT(*) AS transfer_count\nFROM token_activities_avalanche a\nJOIN token_info_avalanche ti\n ON a.tick = ti.tick\nWHERE a.block_timestamp >= CURRENT_TIMESTAMP - INTERVAL '7 days'\nGROUP BY a.tick, ti.creator\nHAVING SUM(a.amt) > 10000\nORDER BY total_volume DESC\nLIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nIndex 'aircraft_models'. Mapping: { properties: { model_id: { type: 'keyword' }, model_name: { type: 'text', fields: { keyword: { type: 'keyword', ignore_above: 256 } } }, manufacturer: { type: 'keyword' }, passenger_capacity: { type: 'integer' }, max_range_km: { type: 'integer' }, engine_type: { type: 'keyword' }, wingspan_m: { type: 'float' }, status: { type: 'keyword' }, first_flight_date: { type: 'date' } } }. Document _id can be set to model_id.\nIndex 'components'. Mapping: { properties: { component_id: { type: 'keyword' }, part_number: { type: 'keyword' }, component_name: { type: 'text', fields: { keyword: { type: 'keyword', ignore_above: 256 } } }, description: { type: 'text' }, material_id: { type: 'keyword' }, supplier_id: { type: 'keyword' }, weight_kg: { type: 'scaled_float', scaling_factor: 1000 }, cost_usd: { type: 'scaled_float', scaling_factor: 100 }, criticality_level: { type: 'keyword' } } }. Document _id can be component_id.\nIndex 'materials'. Mapping: { properties: { material_id: { type: 'keyword' }, material_name: { type: 'text', fields: { keyword: { type: 'keyword', ignore_above: 256 } } }, specification: { type: 'keyword' }, description: { type: 'text' }, density_kg_m3: { type: 'float' }, tensile_strength_mpa: { type: 'integer' } } }. Document _id can be material_id.\nIndex 'assembly_lines'. Mapping: { properties: { line_id: { type: 'keyword' }, line_name: { type: 'text', fields: { keyword: { type: 'keyword', ignore_above: 256 } } }, location_building: { type: 'keyword' }, location_area: { type: 'keyword' }, aircraft_model_id: { type: 'keyword' }, capacity_units_per_month: { type: 'integer' }, status: { type: 'keyword' } } }. Document _id can be line_id.\nIndex 'assembly_steps'. Mapping: { properties: { step_id: { type: 'keyword' }, line_id: { type: 'keyword' }, step_number: { type: 'integer' }, step_name: { type: 'text', fields: { keyword: { type: 'keyword', ignore_above: 256 } } }, description: { type: 'text' }, standard_duration_hours: { type: 'float' }, required_skill_level: { type: 'keyword' }, workstation: { type: 'keyword' } } }. Document _id can be step_id.\nIndex 'aircraft_builds'. Mapping: { properties: { build_id: { type: 'keyword' }, serial_number: { type: 'keyword' }, model_id: { type: 'keyword' }, assembly_line_id: { type: 'keyword' }, build_start_date: { type: 'date' }, estimated_completion_date: { type: 'date' }, actual_completion_date: { type: 'date' }, current_status: { type: 'keyword' }, customer_order_id: { type: 'keyword' } } }. Document _id can be build_id.\nIndex 'inspections'. Mapping: { properties: { inspection_id: { type: 'keyword' }, build_id: { type: 'keyword' }, component_id: { type: 'keyword' }, step_id: { type: 'keyword' }, inspection_type: { type: 'keyword' }, inspector_employee_id: { type: 'keyword' }, inspection_timestamp: { type: 'date' }, result: { type: 'keyword' }, remarks: { type: 'text' } } }. Document _id can be inspection_id. Consider parent/child relationship with build_id for routing.\nIndex 'component_inventory'. Mapping: { properties: { inventory_record_id: { type: 'keyword' }, component_id: { type: 'keyword' }, quantity: { type: 'integer' }, location_warehouse: { type: 'keyword' }, location_bin: { type: 'keyword' }, received_date: { type: 'date' }, expiry_date: { type: 'date' }, batch_number: { type: 'keyword' }, last_updated: { type: 'date' } } }. Document _id can be inventory_record_id.\n", "conversations": [{"role": "user", "content": "I need to get the total quantity of components in inventory for a specific warehouse location. Can you help with that?"}, {"role": "assistant", "content": "SELECT location_warehouse, SUM(quantity) AS total_quantity\nFROM component_inventory\nWHERE location_warehouse = 'specific_warehouse'\nGROUP BY location_warehouse;"}, {"role": "user", "content": "Can you also include the component names for the inventory records in that warehouse?"}, {"role": "assistant", "content": "SELECT ci.location_warehouse, c.component_name, SUM(ci.quantity) AS total_quantity\nFROM component_inventory ci\nJOIN components c ON ci.component_id = c.component_id\nWHERE ci.location_warehouse = 'specific_warehouse'\nGROUP BY ci.location_warehouse, c.component_name;"}, {"role": "user", "content": "What if I want to filter out components with a total quantity less than 20?"}, {"role": "assistant", "content": "SELECT ci.location_warehouse, c.component_name, SUM(ci.quantity) AS total_quantity\nFROM component_inventory ci\nJOIN components c ON ci.component_id = c.component_id\nWHERE ci.location_warehouse = 'specific_warehouse'\nGROUP BY ci.location_warehouse, c.component_name\nHAVING SUM(ci.quantity) >= 20;"}, {"role": "user", "content": "Can you sort the results by total quantity in descending order?"}, {"role": "assistant", "content": "SELECT ci.location_warehouse, c.component_name, SUM(ci.quantity) AS total_quantity\nFROM component_inventory ci\nJOIN components c ON ci.component_id = c.component_id\nWHERE ci.location_warehouse = 'specific_warehouse'\nGROUP BY ci.location_warehouse, c.component_name\nHAVING SUM(ci.quantity) >= 20\nORDER BY total_quantity DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash text, transaction_index bigint, from_address text, contract_address text, symbol text, total_supply text, name text, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info text, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )\nCREATE TABLE nft_holder_historical ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk integer )\nCREATE TABLE sui_coins ( object_id text, status text, coin_type text, balance text, owner text )\nCREATE TABLE sui_coins_metadata ( object_id text, coin_type text, status text, decimals bigint, description text, icon_url text, symbol text, name text )\nCREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_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 )\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE mud_holesky_redstone ( address text, table_id text, key_bytes text, key0 text, key1 text, static_data text, encoded_lengths text, dynamic_data text, is_deleted boolean, block_number bigint, log_index bigint )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )\n", "conversations": [{"role": "user", "content": "Show me the balance history of wallet '0xdeadbeef' for token at contract '0xaaaa...' ."}, {"role": "assistant", "content": "SELECT block_number, amount\nFROM erc20_balances_historical\nWHERE wallet_address = '0xdeadbeef'\n AND contract_address = '0xaaaa...';"}, {"role": "user", "content": "Only include entries after block 12000000."}, {"role": "assistant", "content": "SELECT block_number, amount\nFROM erc20_balances_historical\nWHERE wallet_address = '0xdeadbeef'\n AND contract_address = '0xaaaa...'\n AND block_number > 12000000;"}, {"role": "user", "content": "Add the token symbol and decimals from token_metas."}, {"role": "assistant", "content": "SELECT b.block_number,\n b.amount,\n m.symbol,\n m.decimals\nFROM erc20_balances_historical b\nJOIN token_metas m\n ON b.contract_address = m.contract_address\nWHERE b.wallet_address = '0xdeadbeef'\n AND b.contract_address = '0xaaaa...'\n AND b.block_number > 12000000;"}, {"role": "user", "content": "Also include the latest price for each entry by joining with token_prices_latest."}, {"role": "assistant", "content": "SELECT b.block_number,\n b.amount,\n m.symbol,\n m.decimals,\n p.price\nFROM erc20_balances_historical b\nJOIN token_metas m\n ON b.contract_address = m.contract_address\nJOIN token_prices_latest p\n ON b.contract_address = p.address\nWHERE b.wallet_address = '0xdeadbeef'\n AND b.contract_address = '0xaaaa...'\n AND b.block_number > 12000000;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id text, license_plate text, vin text, make text, model text, year integer, type text, capacity integer, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.trips ( trip_id text, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count integer, cargo_manifest_id text )\nCREATE TABLE transportation.locations ( location_id text, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text )\nCREATE TABLE transportation.bookings ( booking_id text, passenger_id text, trip_id text, seat_number text, booking_time timestamp, status text, fare numeric, payment_transaction_id text, special_requests text )\n", "conversations": [{"role": "user", "content": "Give me the booking_id, passenger_id, trip_id, and special_requests for bookings that have any special_requests."}, {"role": "assistant", "content": "SELECT booking_id, passenger_id, trip_id, special_requests\nFROM transportation.bookings\nWHERE special_requests IS NOT NULL AND special_requests <> '';"}, {"role": "user", "content": "Also include the fare and booking_time in the results."}, {"role": "assistant", "content": "SELECT booking_id,\n passenger_id,\n trip_id,\n special_requests,\n fare,\n booking_time\nFROM transportation.bookings\nWHERE special_requests IS NOT NULL AND special_requests <> '';"}, {"role": "user", "content": "Only include bookings with status 'Confirmed' or 'Pending'."}, {"role": "assistant", "content": "SELECT booking_id,\n passenger_id,\n trip_id,\n special_requests,\n fare,\n booking_time\nFROM transportation.bookings\nWHERE special_requests IS NOT NULL\n AND special_requests <> ''\n AND status IN ('Confirmed', 'Pending');"}, {"role": "user", "content": "Order by booking_time descending and limit to 5 records."}, {"role": "assistant", "content": "SELECT booking_id,\n passenger_id,\n trip_id,\n special_requests,\n fare,\n booking_time\nFROM transportation.bookings\nWHERE special_requests IS NOT NULL\n AND special_requests <> ''\n AND status IN ('Confirmed', 'Pending')\nORDER BY booking_time DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.law_firms ( firm_id character varying(64) NOT NULL, firm_name character varying(200) NOT NULL, address text NOT NULL, phone character varying(32), website character varying(255), founded_date date, managing_partner_id character varying(64), PRIMARY KEY (firm_id) )\n", "conversations": [{"role": "user", "content": "Show me the names, founding dates, and websites of all law firms whose name contains the word 'Legal' and were founded after the year 2005. Sort the results by their founding date."}, {"role": "assistant", "content": "SELECT firm_name, founded_date, website FROM legal_services.law_firms WHERE firm_name LIKE '%Legal%' AND founded_date > '2005-12-31' ORDER BY founded_date ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_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) )\n", "conversations": [{"role": "user", "content": "For each chain, show the total token_amount and usd_value for selling transactions (type=2)."}, {"role": "assistant", "content": "SELECT chain, SUM(token_amount) AS total_sold_amount, SUM(usd_value) AS total_sold_usd_value\nFROM smart_money_token_inflow\nWHERE type = 2\nGROUP BY chain;"}, {"role": "user", "content": "Can you break down these results further by narrative as well?"}, {"role": "assistant", "content": "SELECT chain, narrative, SUM(token_amount) AS total_sold_amount, SUM(usd_value) AS total_sold_usd_value\nFROM smart_money_token_inflow\nWHERE type = 2\nGROUP BY chain, narrative;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, submitted_at timestamp NOT NULL, status character varying(50) NOT NULL, last_updated_at timestamp NOT NULL, assigned_employee_id character varying(64), decision_date date, notes text, reference_number character varying(100) UNIQUE, PRIMARY KEY (application_id) )\n", "conversations": [{"role": "user", "content": "List the reference number and status for applications where the notes contain the keyword 'urgent'."}, {"role": "assistant", "content": "SELECT reference_number, status FROM government_services.applications WHERE notes ILIKE '%urgent%';"}, {"role": "user", "content": "Among those, show only the applications with a status of 'Pending'."}, {"role": "assistant", "content": "SELECT reference_number, status FROM government_services.applications WHERE notes ILIKE '%urgent%' AND status = 'Pending';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Can you provide the mechanic name, service date, and service type for each maintenance log, along with the vehicle's odometer reading for all logs with a cost greater than 1000?"}, {"role": "assistant", "content": "SELECT mechanic_name, service_date, service_type, odometer_reading FROM transportation.maintenance_logs WHERE cost > 1000;"}, {"role": "user", "content": "What about only logs where the next_service_due_date is before '2024-08-01' and sort the results by service_date descending?"}, {"role": "assistant", "content": "SELECT mechanic_name, service_date, service_type, odometer_reading FROM transportation.maintenance_logs WHERE cost > 1000 AND next_service_due_date < '2024-08-01' ORDER BY service_date DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "Find pairs of notifications for the same application where one was sent via 'Email' and the other via 'SMS'. Display the application_id, email_notification_id, sms_notification_id, email_sent_at, and sms_sent_at."}, {"role": "assistant", "content": "SELECT\n n_email.application_id,\n n_email.notification_id AS email_notification_id,\n n_sms.notification_id AS sms_notification_id,\n n_email.sent_at AS email_sent_at,\n n_sms.sent_at AS sms_sent_at\nFROM government_services.notifications n_email\nJOIN government_services.notifications n_sms\n ON n_email.application_id = n_sms.application_id\n AND n_email.channel = 'Email'\n AND n_sms.channel = 'SMS';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.payments ( payment_id text, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\nCREATE TABLE government_services.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\nCREATE TABLE government_services.notifications ( notification_id text, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "For each employee, show their first name, last name, and the total payment amount for applications they have been assigned to process."}, {"role": "assistant", "content": "SELECT e.first_name, e.last_name, SUM(p.amount) AS total_payment_amount\nFROM government_services.employees e\nJOIN government_services.applications a ON e.employee_id = a.assigned_employee_id\nJOIN government_services.payments p ON a.application_id = p.application_id\nGROUP BY e.employee_id, e.first_name, e.last_name;"}, {"role": "user", "content": "Only consider payments with status 'Succeeded' and made after January 1, 2024."}, {"role": "assistant", "content": "SELECT e.first_name, e.last_name, SUM(p.amount) AS total_payment_amount\nFROM government_services.employees e\nJOIN government_services.applications a ON e.employee_id = a.assigned_employee_id\nJOIN government_services.payments p ON a.application_id = p.application_id\nWHERE p.status = 'Succeeded'\n AND p.payment_timestamp > '2024-01-01'\nGROUP BY e.employee_id, e.first_name, e.last_name;"}, {"role": "user", "content": "I got an error: missing column 'amount' in select list."}, {"role": "assistant", "content": "SELECT e.first_name, e.last_name, COALESCE(SUM(p.amount), 0) AS total_payment_amount\nFROM government_services.employees e\nJOIN government_services.applications a ON e.employee_id = a.assigned_employee_id\nLEFT JOIN government_services.payments p ON a.application_id = p.application_id AND p.status = 'Succeeded' AND p.payment_timestamp > '2024-01-01'\nGROUP BY e.employee_id, e.first_name, e.last_name;"}, {"role": "user", "content": "Instead of total payment, show the average payment amount per application for each employee."}, {"role": "assistant", "content": "SELECT e.first_name, e.last_name, AVG(sub.app_payment_amount) AS avg_payment_per_application\nFROM government_services.employees e\nJOIN government_services.applications a ON e.employee_id = a.assigned_employee_id\nLEFT JOIN (\n SELECT application_id, SUM(amount) AS app_payment_amount\n FROM government_services.payments\n WHERE status = 'Succeeded' AND payment_timestamp > '2024-01-01'\n GROUP BY application_id\n) sub ON a.application_id = sub.application_id\nGROUP BY e.employee_id, e.first_name, e.last_name;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players ( player_id uuid NOT NULL DEFAULT gen_random_uuid(), username character varying(100) NOT NULL UNIQUE, email character varying(255) NOT NULL UNIQUE, password_hash text NOT NULL, registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, last_login timestamp with time zone, country_code character(2), status character varying(20) NOT NULL DEFAULT 'active', profile_data jsonb, PRIMARY KEY (player_id) )\nCREATE TABLE gaming_technology.games ( game_id uuid NOT NULL DEFAULT gen_random_uuid(), title character varying(200) NOT NULL, developer_id uuid NOT NULL, publisher_id uuid, genre character varying(100), release_date date, description text, platform character varying(50) NOT NULL, engine character varying(100), website character varying(255), PRIMARY KEY (game_id) )\nCREATE TABLE gaming_technology.developers ( developer_id uuid NOT NULL DEFAULT gen_random_uuid(), name character varying(150) NOT NULL UNIQUE, country character varying(100), founded_year integer, website character varying(255), created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (developer_id) )\nCREATE TABLE gaming_technology.servers ( server_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, server_name character varying(150), region character varying(50) NOT NULL, ip_address character varying(45), port integer, current_players integer NOT NULL DEFAULT 0, max_players integer NOT NULL, status character varying(30) NOT NULL DEFAULT 'offline', last_heartbeat timestamp with time zone, PRIMARY KEY (server_id) )\nCREATE TABLE gaming_technology.achievements ( achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, name character varying(150) NOT NULL, description text NOT NULL, icon_url character varying(255), points integer DEFAULT 0, hidden boolean DEFAULT false, PRIMARY KEY (achievement_id) )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, achievement_id uuid NOT NULL, unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, item_name character varying(150) NOT NULL, item_type character varying(50) NOT NULL, description text, rarity character varying(30), cost_currency character varying(10), cost_amount numeric(12, 2), attributes jsonb, PRIMARY KEY (item_id) )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, item_id uuid NOT NULL, quantity integer NOT NULL DEFAULT 1, acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, instance_data jsonb, PRIMARY KEY (inventory_id) )\n", "conversations": [{"role": "user", "content": "Count how many achievements were unlocked on each calendar day. Show the date and the count."}, {"role": "assistant", "content": "SELECT DATE(unlocked_at) AS unlock_date, COUNT(*) AS achievement_count FROM gaming_technology.player_achievements GROUP BY unlock_date;"}, {"role": "user", "content": "Only include dates where more than 50 achievements were unlocked."}, {"role": "assistant", "content": "SELECT DATE(unlocked_at) AS unlock_date, COUNT(*) AS achievement_count FROM gaming_technology.player_achievements GROUP BY unlock_date HAVING COUNT(*) > 50;"}, {"role": "user", "content": "Additionally, include the number of *distinct players* who unlocked achievements on each of those dates."}, {"role": "assistant", "content": "SELECT DATE(unlocked_at) AS unlock_date, COUNT(*) AS achievement_count, COUNT(DISTINCT player_id) AS distinct_players FROM gaming_technology.player_achievements GROUP BY unlock_date HAVING COUNT(*) > 50;"}, {"role": "user", "content": "Order the results by the distinct player count in descending order."}, {"role": "assistant", "content": "SELECT DATE(unlocked_at) AS unlock_date, COUNT(*) AS achievement_count, COUNT(DISTINCT player_id) AS distinct_players FROM gaming_technology.player_achievements GROUP BY unlock_date HAVING COUNT(*) > 50 ORDER BY distinct_players DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.orders ( order_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, wallet_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, order_type character varying(32) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, status character varying(32) NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (order_id) )\nCREATE TABLE trading_platform.trades ( trade_id character varying(64) NOT NULL, order_id character varying(64) NOT NULL, buyer_id character varying(64) NOT NULL, seller_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, traded_at timestamp NOT NULL, PRIMARY KEY (trade_id) )\nCREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )\nCREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, status character varying(32) NOT NULL, reviewed_at timestamp NOT NULL, PRIMARY KEY (kyc_audit_id) )\nCREATE TABLE trading_platform.logs ( log_id character varying(64) NOT NULL, user_id character varying(64), action character varying(128) NOT NULL, details text NOT NULL, logged_at timestamp NOT NULL, PRIMARY KEY (log_id) )\nCREATE TABLE trading_platform.notifications ( notification_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, message text NOT NULL, sent_at timestamp NOT NULL, read_at timestamp, PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "Show each user_id for users with 'pending' KYC status along with the count of unread notifications they have."}, {"role": "assistant", "content": "SELECT k.user_id, COUNT(n.notification_id) AS unread_count\nFROM trading_platform.kyc_audit k\nJOIN trading_platform.notifications n ON k.user_id = n.user_id AND n.read_at IS NULL\nWHERE k.status = 'pending'\nGROUP BY k.user_id;"}, {"role": "user", "content": "The query doesn't include users with zero unread notifications. Please include users with zero unread notifications too."}, {"role": "assistant", "content": "SELECT k.user_id, COALESCE(COUNT(n.notification_id),0) AS unread_count\nFROM trading_platform.kyc_audit k\nLEFT JOIN trading_platform.notifications n ON k.user_id = n.user_id AND n.read_at IS NULL\nWHERE k.status = 'pending'\nGROUP BY k.user_id;"}, {"role": "user", "content": "Also include the date of the most recent notification sent for each user, whether read or unread."}, {"role": "assistant", "content": "SELECT k.user_id,\n COALESCE(COUNT(n.notification_id),0) AS unread_count,\n MAX(n.sent_at) AS last_notification_at\nFROM trading_platform.kyc_audit k\nLEFT JOIN trading_platform.notifications n ON k.user_id = n.user_id\nWHERE k.status = 'pending'\nGROUP BY k.user_id;"}, {"role": "user", "content": "Now only show users who have more than 1 unread notification, and order by unread_count descending."}, {"role": "assistant", "content": "SELECT user_id, unread_count, last_notification_at\nFROM (\n SELECT k.user_id,\n COALESCE(COUNT(n.notification_id),0) AS unread_count,\n MAX(n.sent_at) AS last_notification_at\n FROM trading_platform.kyc_audit k\n LEFT JOIN trading_platform.notifications n ON k.user_id = n.user_id AND n.read_at IS NULL\n WHERE k.status = 'pending'\n GROUP BY k.user_id\n) t\nWHERE unread_count > 1\nORDER BY unread_count DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "List all pairs of beneficiaries on the same policy, showing policy_id, beneficiary1_id, beneficiary1 first_name, beneficiary1 last_name, beneficiary2_id, beneficiary2 first_name, and beneficiary2 last_name."}, {"role": "assistant", "content": "SELECT b1.policy_id,\n b1.beneficiary_id AS beneficiary1_id,\n b1.first_name AS beneficiary1_first,\n b1.last_name AS beneficiary1_last,\n b2.beneficiary_id AS beneficiary2_id,\n b2.first_name AS beneficiary2_first,\n b2.last_name AS beneficiary2_last\nFROM insurance.policy_beneficiaries b1\nJOIN insurance.policy_beneficiaries b2\n ON b1.policy_id = b2.policy_id\n AND b1.beneficiary_id < b2.beneficiary_id;"}, {"role": "user", "content": "Actually, only include pairs where the first beneficiary\u2019s relationship is 'Spouse'."}, {"role": "assistant", "content": "SELECT b1.policy_id,\n b1.beneficiary_id AS beneficiary1_id,\n b1.first_name AS beneficiary1_first,\n b1.last_name AS beneficiary1_last,\n b2.beneficiary_id AS beneficiary2_id,\n b2.first_name AS beneficiary2_first,\n b2.last_name AS beneficiary2_last\nFROM insurance.policy_beneficiaries b1\nJOIN insurance.policy_beneficiaries b2\n ON b1.policy_id = b2.policy_id\n AND b1.beneficiary_id < b2.beneficiary_id\nWHERE b1.relationship = 'Spouse';"}, {"role": "user", "content": "And also filter to only include cases where the spouse's percentage_share is above 25%."}, {"role": "assistant", "content": "SELECT b1.policy_id,\n b1.beneficiary_id AS beneficiary1_id,\n b1.first_name AS beneficiary1_first,\n b1.last_name AS beneficiary1_last,\n b2.beneficiary_id AS beneficiary2_id,\n b2.first_name AS beneficiary2_first,\n b2.last_name AS beneficiary2_last\nFROM insurance.policy_beneficiaries b1\nJOIN insurance.policy_beneficiaries b2\n ON b1.policy_id = b2.policy_id\n AND b1.beneficiary_id < b2.beneficiary_id\nWHERE b1.relationship = 'Spouse'\n AND b1.percentage_share > 25;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts ( contract_id character varying(64) NOT NULL, address character varying(128) NOT NULL, abi text NOT NULL, bytecode text NOT NULL, deployer_address character varying(128) NOT NULL, deployed_at timestamp NOT NULL, network_id character varying(64) NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (contract_id) )\nCREATE 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) )\nCREATE TABLE web3.tokens ( token_id character varying(64) NOT NULL, contract_address character varying(128) NOT NULL, token_name character varying(128) NOT NULL, token_symbol character varying(32) NOT NULL, decimals integer NOT NULL, total_supply numeric(38,14) NOT NULL, PRIMARY KEY (token_id) )\nCREATE TABLE web3.token_transfers ( transfer_id character varying(64) NOT NULL, token_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128) NOT NULL, value numeric(38,14) NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (transfer_id) )\nCREATE TABLE web3.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\n", "conversations": [{"role": "user", "content": "Find all contracts deployed by users who have also conducted transactions with a value greater than 1 ETH (where 1 ETH = 1e18 wei)."}, {"role": "assistant", "content": "SELECT DISTINCT c.contract_id, c.address, c.deployer_address FROM web3.contracts c JOIN web3.transactions t ON c.deployer_address = t.from_address WHERE t.value > 1e18;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.agencies ( agency_id text PRIMARY KEY, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )\nCREATE TABLE government_services.documents ( document_id text PRIMARY KEY, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "List the full name (first name and last name) of all citizens who have uploaded documents whose expiry date is in the past."}, {"role": "assistant", "content": "SELECT DISTINCT T1.first_name, T1.last_name FROM government_services.citizens AS T1 INNER JOIN government_services.documents AS T2 ON T1.citizen_id = T2.citizen_id WHERE T2.expiry_date < CURRENT_DATE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\n", "conversations": [{"role": "user", "content": "Find all guests who live in the same city and list each guest's name along with the name of another guest in that city."}, {"role": "assistant", "content": "SELECT g1.first_name || ' ' || g1.last_name AS guest_name,\n g2.first_name || ' ' || g2.last_name AS other_guest_name,\n g1.city\nFROM guests g1\nJOIN guests g2\n ON g1.city = g2.city\n AND g1.guest_id <> g2.guest_id;"}, {"role": "user", "content": "Now restrict to only cities with more than two guests and order by city ascending."}, {"role": "assistant", "content": "SELECT pairs.city,\n pairs.guest_name,\n pairs.other_guest_name\nFROM (\n SELECT g1.first_name || ' ' || g1.last_name AS guest_name,\n g2.first_name || ' ' || g2.last_name AS other_guest_name,\n g1.city\n FROM guests g1\n JOIN guests g2\n ON g1.city = g2.city\n AND g1.guest_id <> g2.guest_id\n) AS pairs\nJOIN (\n SELECT city\n FROM guests\n GROUP BY city\n HAVING COUNT(*) > 2\n) AS multi\n ON pairs.city = multi.city\nORDER BY pairs.city ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE project_fundraising_record ( id character varying(32) NOT NULL, project_id character varying(32) NOT NULL, project_name character varying(128) NOT NULL, rounds_name character varying(32), investment_value numeric(38,14), investment_date character varying(128), introduction character varying(128), valuation numeric(38,14) )\n", "conversations": [{"role": "user", "content": "Can you list each fundraising round name along with the project that raised the smallest amount in that round? Show the project name, round, and investment value."}, {"role": "assistant", "content": "SELECT t1.rounds_name, t1.project_name, t1.investment_value\nFROM project_fundraising_record t1\nJOIN (\n SELECT rounds_name, MIN(investment_value) AS min_value\n FROM project_fundraising_record\n WHERE rounds_name IS NOT NULL\n GROUP BY rounds_name\n) t2\nON t1.rounds_name = t2.rounds_name AND t1.investment_value = t2.min_value;"}, {"role": "user", "content": "That's helpful! Now, can you also include the project introduction and the valuation if available in the results?"}, {"role": "assistant", "content": "SELECT t1.rounds_name, t1.project_name, t1.investment_value, t1.introduction, t1.valuation\nFROM project_fundraising_record t1\nJOIN (\n SELECT rounds_name, MIN(investment_value) AS min_value\n FROM project_fundraising_record\n WHERE rounds_name IS NOT NULL\n GROUP BY rounds_name\n) t2\nON t1.rounds_name = t2.rounds_name AND t1.investment_value = t2.min_value;"}, {"role": "user", "content": "I want to filter the results to only show projects with a valuation above 50 million. Can you adjust the query?"}, {"role": "assistant", "content": "SELECT t1.rounds_name, t1.project_name, t1.investment_value, t1.introduction, t1.valuation\nFROM project_fundraising_record t1\nJOIN (\n SELECT rounds_name, MIN(investment_value) AS min_value\n FROM project_fundraising_record\n WHERE rounds_name IS NOT NULL\n GROUP BY rounds_name\n) t2\nON t1.rounds_name = t2.rounds_name AND t1.investment_value = t2.min_value\nWHERE t1.valuation > 50000000;"}, {"role": "user", "content": "Can you also order the results by investment value ascending?"}, {"role": "assistant", "content": "SELECT t1.rounds_name, t1.project_name, t1.investment_value, t1.introduction, t1.valuation\nFROM project_fundraising_record t1\nJOIN (\n SELECT rounds_name, MIN(investment_value) AS min_value\n FROM project_fundraising_record\n WHERE rounds_name IS NOT NULL\n GROUP BY rounds_name\n) t2\nON t1.rounds_name = t2.rounds_name AND t1.investment_value = t2.min_value\nWHERE t1.valuation > 50000000\nORDER BY t1.investment_value ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\nCREATE TABLE legal_services.cases ( case_id character varying(64) NOT NULL, case_number character varying(100) UNIQUE, case_name text NOT NULL, client_id character varying(64) NOT NULL, lead_lawyer_id character varying(64) NOT NULL, case_type character varying(100) NOT NULL, status character varying(50) NOT NULL, date_opened timestamp NOT NULL, date_closed timestamp, description text, court_jurisdiction character varying(128), PRIMARY KEY (case_id) )\nCREATE TABLE legal_services.time_entries ( entry_id character varying(64) NOT NULL, case_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, date_worked date NOT NULL, hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), billing_rate numeric(10, 2) NOT NULL, description text NOT NULL, is_billable boolean DEFAULT true, is_billed boolean DEFAULT false, invoice_id character varying(64), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (entry_id) )\nCREATE TABLE legal_services.appointments ( appointment_id character varying(64) NOT NULL, client_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, case_id character varying(64), start_time timestamp NOT NULL, end_time timestamp NOT NULL, location text, subject character varying(255), notes text, status character varying(50) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (appointment_id) )\n", "conversations": [{"role": "user", "content": "List all time entries with their entry ID, lawyer ID, and the billing rate where the hours spent is greater than 4."}, {"role": "assistant", "content": "SELECT entry_id, lawyer_id, billing_rate\nFROM legal_services.time_entries\nWHERE hours_spent > 4;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts (\n contract_id character varying(64) NOT NULL, -- unique identifier for the contract\n address character varying(128) NOT NULL, -- address of the deployed contract\n abi text NOT NULL, -- application binary interface of the contract\n bytecode text NOT NULL, -- bytecode of the contract\n deployer_address character varying(128) NOT NULL, -- address of the deployer\n deployed_at timestamp NOT NULL, -- time when the contract was deployed\n network_id character varying(64) NOT NULL, -- identifier of the network where the contract is deployed\n status character varying(32) NOT NULL, -- status of the contract (e.g., active, deprecated)\n PRIMARY KEY (contract_id)\n)\n", "conversations": [{"role": "user", "content": "Count the number of contracts per network and status."}, {"role": "assistant", "content": "SELECT\n network_id,\n status,\n COUNT(*) AS contract_count\nFROM web3.contracts\nGROUP BY network_id, status;"}, {"role": "user", "content": "Actually, please only include statuses with more than 10 contracts."}, {"role": "assistant", "content": "SELECT\n network_id,\n status,\n COUNT(*) AS contract_count\nFROM web3.contracts\nGROUP BY network_id, status\nHAVING COUNT(*) > 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE nft_holder_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata ( object_id 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 )\nCREATE TABLE sui_nfts ( object_id varchar NOT NULL, status varchar NOT NULL, collection_type varchar NOT NULL, package_id varchar NOT NULL, previous_transaction varchar NOT NULL, display varchar NOT NULL, owner varchar NOT NULL, name varchar NOT NULL )\nCREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )\nCREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid varchar(36) NOT NULL, blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )\nCREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_balances ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\nCREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar NOT NULL, tick varchar NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE mud_holesky_redstone ( address varchar NOT NULL, table_id varchar NOT NULL, key_bytes varchar NOT NULL, key0 varchar NOT NULL, key1 varchar NOT NULL, static_data varchar NOT NULL, encoded_lengths varchar NOT NULL, dynamic_data varchar NOT NULL, is_deleted boolean NOT NULL, block_number bigint NOT NULL, log_index bigint NOT NULL )\nCREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(255) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply varchar NOT NULL, amount varchar NOT NULL )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\nCREATE 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 )\n", "conversations": [{"role": "user", "content": "List SUI coins with owner, coin type, balance, and status."}, {"role": "assistant", "content": "SELECT owner, coin_type, balance, status FROM sui_coins;"}, {"role": "user", "content": "Only include coins where status is 'exists' and balance is greater than '100000000'."}, {"role": "assistant", "content": "SELECT owner, coin_type, balance, status FROM sui_coins WHERE status = 'exists' AND CAST(balance AS DECIMAL) > 100000000;"}, {"role": "user", "content": "Add symbol and name from metadata, only for metadata entries where status is also 'exists'."}, {"role": "assistant", "content": "SELECT sc.owner, sc.coin_type, CAST(sc.balance AS DECIMAL), sc.status, scm.symbol, scm.name FROM sui_coins AS sc JOIN sui_coins_metadata AS scm ON sc.coin_type = scm.coin_type WHERE sc.status = 'exists' AND CAST(sc.balance AS DECIMAL) > 100000000 AND scm.status = 'exists';"}, {"role": "user", "content": "Order by balance descending and limit to 5."}, {"role": "assistant", "content": "SELECT sc.owner, sc.coin_type, CAST(sc.balance AS DECIMAL), sc.status, scm.symbol, scm.name FROM sui_coins AS sc JOIN sui_coins_metadata AS scm ON sc.coin_type = scm.coin_type WHERE sc.status = 'exists' AND CAST(sc.balance AS DECIMAL) > 100000000 AND scm.status = 'exists' ORDER BY CAST(sc.balance AS DECIMAL) DESC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.documents ( document_id.text, case_id.text, document_name.text, document_type.text, storage_path.text, uploaded_by_lawyer_id.text, upload_timestamp.timestamp, version.integer, description.text )\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me all documents along with the appointment subjects for appointments related to the same case."}, {"role": "assistant", "content": "SELECT d.document_name, d.case_id, a.subject\nFROM legal_services.documents d\nJOIN legal_services.appointments a ON d.case_id = a.case_id;"}, {"role": "user", "content": "Actually, only include cases where the document type is 'Brief' and the appointment status is 'scheduled'."}, {"role": "assistant", "content": "SELECT d.document_name, d.case_id, a.subject\nFROM legal_services.documents d\nJOIN legal_services.appointments a ON d.case_id = a.case_id\nWHERE d.document_type = 'Brief' AND a.status = 'scheduled';"}, {"role": "user", "content": "Can you also show the upload timestamp for the documents and sort the results by upload_timestamp descending?"}, {"role": "assistant", "content": "SELECT d.document_name, d.case_id, a.subject, d.upload_timestamp\nFROM legal_services.documents d\nJOIN legal_services.appointments a ON d.case_id = a.case_id\nWHERE d.document_type = 'Brief' AND a.status = 'scheduled'\nORDER BY d.upload_timestamp DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Show me the first_name, last_name, and firm_id of all lawyers whose email domain is 'legalfirm.com'."}, {"role": "assistant", "content": "SELECT first_name,\n last_name,\n firm_id\nFROM legal_services.lawyers\nWHERE SPLIT_PART(email, '@', 2) = 'legalfirm.com';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\n", "conversations": [{"role": "user", "content": "List all post IDs that have more than one hashtag associated with them."}, {"role": "assistant", "content": "SELECT post_id FROM social_media.post_hashtags GROUP BY post_id HAVING COUNT(hashtag_id) > 1;"}, {"role": "user", "content": "For each of these posts that have multiple hashtags, show the post ID and all associated hashtag IDs."}, {"role": "assistant", "content": "SELECT DISTINCT t1.post_id, t1.hashtag_id FROM social_media.post_hashtags AS t1 JOIN social_media.post_hashtags AS t2 ON t1.post_id = t2.post_id WHERE t1.post_hashtag_id != t2.post_hashtag_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "Count how many insurance plans exist for each plan type."}, {"role": "assistant", "content": "SELECT plan_type, COUNT(*) AS plan_count\nFROM healthcare.insurance_plans\nGROUP BY plan_type;"}, {"role": "user", "content": "Now filter to only show plan types with more than 2 plans."}, {"role": "assistant", "content": "SELECT plan_type, COUNT(*) AS plan_count\nFROM healthcare.insurance_plans\nGROUP BY plan_type\nHAVING COUNT(*) > 2;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id character varying(64) NOT NULL, national_id_number character varying(128) NOT NULL UNIQUE, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(20), primary_address text NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), registration_date timestamp NOT NULL, is_verified boolean DEFAULT false, PRIMARY KEY (citizen_id) )\nCREATE TABLE government_services.services ( service_id.text, agency_id.text, service_name.text, description.text, category.text, eligibility_criteria.text, standard_fee.numeric, average_processing_time_days.integer, is_active.boolean, online_application_url.text )\n", "conversations": [{"role": "user", "content": "Which services have 'Eligibility' mentioned in their eligibility_criteria field?"}, {"role": "assistant", "content": "SELECT service_name, eligibility_criteria\nFROM government_services.services\nWHERE eligibility_criteria ILIKE '%Eligibility%';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )\n", "conversations": [{"role": "user", "content": "Retrieve the average base_rate and maximum occupancy for room types grouped by bed_type."}, {"role": "assistant", "content": "SELECT bed_type,\n AVG(base_rate) AS avg_base_rate,\n MAX(max_occupancy) AS max_occupancy\nFROM hospitality_technology.room_types\nGROUP BY bed_type;"}, {"role": "user", "content": "Now only include bed types where the average base_rate is above 100 and order by average_base_rate descending."}, {"role": "assistant", "content": "SELECT bed_type,\n AVG(base_rate) AS avg_base_rate,\n MAX(max_occupancy) AS max_occupancy\nFROM hospitality_technology.room_types\nGROUP BY bed_type\nHAVING AVG(base_rate) > 100\nORDER BY avg_base_rate DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id text, post_id text, hashtag_id text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, recipient_user_id character varying(64) NOT NULL, sender_user_id character varying(64), notification_type character varying(30) NOT NULL, target_entity_id character varying(64), target_entity_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (notification_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List usernames and email addresses of users who have enabled both email and push notifications."}, {"role": "assistant", "content": "SELECT T1.username, T1.email FROM social_media.users AS T1 INNER JOIN social_media.user_settings AS T2 ON T1.user_id = T2.user_id WHERE T2.email_notifications_enabled = TRUE AND T2.push_notifications_enabled = TRUE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "List all insurance policies that are set as secondary (is_primary = false) and expired before today, showing the policy number, expiration date, patient ID, and the corresponding plan name."}, {"role": "assistant", "content": "SELECT pi.policy_number, pi.expiration_date, pi.patient_id, ip.plan_name\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = false\n AND pi.expiration_date IS NOT NULL\n AND pi.expiration_date < CURRENT_DATE;"}, {"role": "user", "content": "Also include the insurance provider in the output and sort results by expiration date descending."}, {"role": "assistant", "content": "SELECT pi.policy_number, pi.expiration_date, pi.patient_id, ip.plan_name, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = false\n AND pi.expiration_date IS NOT NULL\n AND pi.expiration_date < CURRENT_DATE\nORDER BY pi.expiration_date DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens (\n citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen\n national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n date_of_birth date NOT NULL,\n gender character varying(20),\n primary_address text NOT NULL, -- full primary residential address\n contact_email character varying(128) UNIQUE,\n contact_phone character varying(32),\n registration_date timestamp NOT NULL, -- when the citizen profile was created\n is_verified boolean DEFAULT false, -- whether identity has been officially verified\n PRIMARY KEY (citizen_id)\n)\nCREATE TABLE government_services.employees ( employee_id.text, agency_id.text, first_name.text, last_name.text, job_title.text, department.text, work_email.text, work_phone.text, hire_date.date, termination_date.date, access_level.text, manager_employee_id.text )\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "Show me the first and last names of citizens and the number of appointments they have scheduled with the employee whose last name is 'Smith'."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM government_services.citizens c\nJOIN government_services.appointments a ON c.citizen_id = a.citizen_id\nJOIN government_services.employees e ON a.employee_id = e.employee_id\nWHERE e.last_name = 'Smith'\nGROUP BY c.citizen_id, c.first_name, c.last_name;"}, {"role": "user", "content": "Include only those citizens who have more than one appointment with an employee named 'Smith'."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM government_services.citizens c\nJOIN government_services.appointments a ON c.citizen_id = a.citizen_id\nJOIN government_services.employees e ON a.employee_id = e.employee_id\nWHERE e.last_name = 'Smith'\nGROUP BY c.citizen_id, c.first_name, c.last_name\nHAVING COUNT(a.appointment_id) > 1;"}, {"role": "user", "content": "Actually, I only want to see citizens whose appointments are scheduled for a future date."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM government_services.citizens c\nJOIN government_services.appointments a ON c.citizen_id = a.citizen_id\nJOIN government_services.employees e ON a.employee_id = e.employee_id\nWHERE e.last_name = 'Smith' AND a.scheduled_start_time > NOW()\nGROUP BY c.citizen_id, c.first_name, c.last_name\nHAVING COUNT(a.appointment_id) > 1;"}, {"role": "user", "content": "Now add each citizen's contact email to the result."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, c.contact_email, COUNT(a.appointment_id) AS appointment_count\nFROM government_services.citizens c\nJOIN government_services.appointments a ON c.citizen_id = a.citizen_id\nJOIN government_services.employees e ON a.employee_id = e.employee_id\nWHERE e.last_name = 'Smith' AND a.scheduled_start_time > NOW()\nGROUP BY c.citizen_id, c.first_name, c.last_name, c.contact_email\nHAVING COUNT(a.appointment_id) > 1;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens (\n citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen\n national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n date_of_birth date NOT NULL,\n gender character varying(20),\n primary_address text NOT NULL, -- full primary residential address\n contact_email character varying(128) UNIQUE,\n contact_phone character varying(32),\n registration_date timestamp NOT NULL, -- when the citizen profile was created\n is_verified boolean DEFAULT false, -- whether identity has been officially verified\n PRIMARY KEY (citizen_id)\n)\nCREATE TABLE government_services.agencies (\n agency_id character varying(64) NOT NULL, -- unique identifier for the agency\n agency_name character varying(255) NOT NULL, -- full name of the government agency\n jurisdiction_level character varying(50) NOT NULL, -- e.g., Federal, State, County, City\n primary_contact_email character varying(128),\n main_phone_number character varying(32),\n website_url character varying(255),\n established_date date,\n parent_agency_id character varying(64), -- FK to self for hierarchical structure\n PRIMARY KEY (agency_id)\n)\nCREATE TABLE government_services.services (\n service_id character varying(64) NOT NULL, -- unique identifier for the service\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n service_name character varying(255) NOT NULL, -- name of the service (e.g., Driver's License Renewal)\n description text,\n category character varying(100), -- e.g., Licensing, Benefits, Taxation, Permits\n eligibility_criteria text, -- description of who is eligible\n standard_fee numeric(10, 2) DEFAULT 0.00, -- typical fee for the service\n average_processing_time_days integer, -- estimated processing time\n is_active boolean DEFAULT true, -- whether the service is currently offered\n online_application_url character varying(255),\n PRIMARY KEY (service_id)\n)\nCREATE TABLE government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n employee_id character varying(64), -- FK to employees table (optional, if assigned)\n location_id character varying(64), -- FK to service_locations table (if physical)\n service_id character varying(64), -- FK to services table (optional, if related to specific service)\n scheduled_start_time timestamp NOT NULL,\n scheduled_end_time timestamp,\n purpose text NOT NULL, -- reason for the appointment\n status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show\n booking_method character varying(50), -- e.g., Online, Phone, In-Person\n created_at timestamp NOT NULL, -- when the appointment was booked\n notes text,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE government_services.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n application_id character varying(64), -- FK to applications table (optional)\n message_subject character varying(255),\n message_body text NOT NULL,\n channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail\n sent_at timestamp NOT NULL,\n status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read\n related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request\n related_entity_id character varying(64), -- ID of the related entity\n PRIMARY KEY (notification_id)\n)\n", "conversations": [{"role": "user", "content": "For citizens who registered before January 1, 2023, show the total number of notifications sent to them for each channel. List the citizen's first name, last name, the channel, and the count of notifications."}, {"role": "assistant", "content": "SELECT\n T1.first_name,\n T1.last_name,\n T2.channel,\n COUNT(T2.notification_id) AS notification_count\nFROM government_services.citizens AS T1\nINNER JOIN government_services.notifications AS T2\n ON T1.citizen_id = T2.citizen_id\nWHERE\n T1.registration_date < '2023-01-01'\nGROUP BY\n T1.citizen_id,\n T1.first_name,\n T1.last_name,\n T2.channel;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE blockchain.nodes ( node_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )\n", "conversations": [{"role": "user", "content": "Show me all nodes that were last seen in the past 30 days, along with their IP addresses and ports."}, {"role": "assistant", "content": "SELECT node_id, ip_address, port, last_seen FROM blockchain.nodes WHERE last_seen >= NOW() - INTERVAL '30 days';"}, {"role": "user", "content": "Now, filter these results to only show nodes with port numbers between 8000 and 9000."}, {"role": "assistant", "content": "SELECT node_id, ip_address, port, last_seen FROM blockchain.nodes WHERE last_seen >= NOW() - INTERVAL '30 days' AND port BETWEEN 8000 AND 9000;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp(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 )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE nft_holders ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE nft_holder_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata ( object_id 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 )\nCREATE TABLE sui_nfts ( object_id varchar NOT NULL, status varchar NOT NULL, collection_type varchar NOT NULL, package_id varchar NOT NULL, previous_transaction varchar NOT NULL, display varchar NOT NULL, owner varchar NOT NULL, name varchar NOT NULL )\nCREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid varchar(36) NOT NULL, blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )\nCREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_balances ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\nCREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar NOT NULL, tick varchar NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(255) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply varchar NOT NULL, amount varchar NOT NULL )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(62) NOT NULL, to_address varchar(62) NOT NULL )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE token_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 )\n", "conversations": [{"role": "user", "content": "List all SUI coins, showing object ID, owner address, and balance."}, {"role": "assistant", "content": "SELECT object_id, owner, balance FROM sui_coins;"}, {"role": "user", "content": "Include the coin symbol and name by joining with the metadata table. Also show the status from both tables."}, {"role": "assistant", "content": "SELECT sc.object_id, sc.owner, sc.balance, sc.coin_type, sm.symbol, sm.name, sc.status AS sui_coins_status, sm.status AS metadata_status FROM sui_coins sc JOIN sui_coins_metadata sm ON sc.coin_type = sm.coin_type;"}, {"role": "user", "content": "Only show coins where both statuses are 'exists' and the balance is greater than '100000000'."}, {"role": "assistant", "content": "SELECT sc.object_id, sc.owner, sc.balance, sc.coin_type, sm.symbol, sm.name, sc.status AS sui_coins_status, sm.status AS metadata_status FROM sui_coins sc JOIN sui_coins_metadata sm ON sc.coin_type = sm.coin_type WHERE sc.status = 'exists' AND sm.status = 'exists' AND CAST(sc.balance AS DECIMAL) > 100000000;"}, {"role": "user", "content": "Order the results by balance descending and limit to the top 10."}, {"role": "assistant", "content": "SELECT sc.object_id, sc.owner, sc.balance, sc.coin_type, sm.symbol, sm.name, sc.status AS sui_coins_status, sm.status AS metadata_status FROM sui_coins sc JOIN sui_coins_metadata sm ON sc.coin_type = sm.coin_type WHERE sc.status = 'exists' AND sm.status = 'exists' AND CAST(sc.balance AS DECIMAL) > 100000000 ORDER BY CAST(sc.balance AS DECIMAL) DESC LIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp.timestamp, block_number.bigint, transaction_hash.text, transaction_index.bigint, from_address.text, contract_address.text, symbol.text, total_supply.text, name.text, decimals.bigint, is_erc20.integer, is_erc721.integer, is_erc1155.integer, is_proxy.integer, extra_info.text, pk.integer )\nCREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text )\nCREATE TABLE erc20_balances_historical ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.integer )\nCREATE TABLE nft_holders ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )\nCREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )\nCREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )\nCREATE TABLE nft_metadata ( blockchain.text, contract_address.text, token_id.text, contract_name.text, erc_type.text, amount.bigint, minter.text, owner.text, mint_block_number.bigint, mint_time.bigint, mint_transaction_hash.text, mint_price.text, token_uri.text, metadata.text, name.text, image_uri.text, traits.text, updated_at.bigint, status.text, rarity_score.real, rarity_rank.integer, unique_attribute_count.integer, pk.integer )\nCREATE TABLE nft_collections ( blockchain.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer )\nCREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )\nCREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE token_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 )\nCREATE TABLE mud_holesky_redstone ( address.text, table_id.text, key_bytes.text, key0.text, key1.text, static_data.text, encoded_lengths.text, dynamic_data.text, is_deleted.boolean, block_number.bigint, log_index.bigint )\nCREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )\nCREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )\nCREATE TABLE token_activities_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\n", "conversations": [{"role": "user", "content": "Calculate the total transfer volume and number of transfers for each Avalanche token tick over the past 7 days."}, {"role": "assistant", "content": "SELECT ta.tick,\n SUM(ta.amt) AS total_volume,\n COUNT(*) AS transfer_count\nFROM token_activities_avalanche ta\nWHERE ta.block_timestamp >= NOW() - INTERVAL '7 days'\nGROUP BY ta.tick;"}, {"role": "user", "content": "Now include the creator from token_info and filter to tokens with total_volume > 500."}, {"role": "assistant", "content": "SELECT sub.tick,\n sub.total_volume,\n sub.transfer_count,\n ti.creator\nFROM (\n SELECT ta.tick,\n SUM(ta.amt) AS total_volume,\n COUNT(*) AS transfer_count\n FROM token_activities_avalanche ta\n WHERE ta.block_timestamp >= NOW() - INTERVAL '7 days'\n GROUP BY ta.tick\n) sub\nJOIN token_info ti ON sub.tick = ti.tick\nWHERE sub.total_volume > 500;"}, {"role": "user", "content": "Also add the current total_supply from token_balances_avalanche for each tick."}, {"role": "assistant", "content": "SELECT sub.tick,\n sub.total_volume,\n sub.transfer_count,\n ti.creator,\n tb.total_supply\nFROM (\n SELECT ta.tick,\n SUM(ta.amt) AS total_volume,\n COUNT(*) AS transfer_count\n FROM token_activities_avalanche ta\n WHERE ta.block_timestamp >= NOW() - INTERVAL '7 days'\n GROUP BY ta.tick\n) sub\nJOIN token_info ti ON sub.tick = ti.tick\nJOIN token_balances_avalanche tb ON sub.tick = tb.tick\nWHERE sub.total_volume > 500;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.time_entries ( entry_id.text, case_id.text, lawyer_id.text, date_worked.date, hours_spent.numeric, billing_rate.numeric, description.text, is_billable.boolean, is_billed.boolean, invoice_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Find pairs of time entries for the same invoice where one entry is billed and the other is not."}, {"role": "assistant", "content": "SELECT a.invoice_id,\n a.entry_id AS billed_entry,\n b.entry_id AS unbilled_entry\nFROM legal_services.time_entries a\nJOIN legal_services.time_entries b\n ON a.invoice_id = b.invoice_id\n AND a.entry_id <> b.entry_id\nWHERE a.is_billed = TRUE\n AND b.is_billed = FALSE;"}, {"role": "user", "content": "Also show the number of days between the billed and unbilled entry dates."}, {"role": "assistant", "content": "SELECT a.invoice_id,\n a.entry_id AS billed_entry,\n b.entry_id AS unbilled_entry,\n ABS(DATE_PART('day', a.date_worked - b.date_worked)) AS days_between\nFROM legal_services.time_entries a\nJOIN legal_services.time_entries b\n ON a.invoice_id = b.invoice_id\n AND a.entry_id <> b.entry_id\nWHERE a.is_billed = TRUE\n AND b.is_billed = FALSE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean )\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.messages ( message_id.text, conversation_id.text, sender_user_id.text, content.text, media_url.text, media_type.text, sent_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the earliest and latest creation timestamps recorded in the posts table."}, {"role": "assistant", "content": "SELECT MIN(created_at), MAX(created_at) FROM social_media.posts"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id.text, reservation_id.text, guest_id.text, service_id.text, staff_id_ordered.text, staff_id_delivered.text, order_timestamp.timestamp, delivery_timestamp.timestamp, quantity.integer, unit_price.numeric, total_price.numeric, status.text, notes.text, bill_id.text )\nCREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "List all available rooms with their room number, property_name, type_name, and the number of days since they were last cleaned."}, {"role": "assistant", "content": "SELECT p.property_name,\n r.room_number,\n rt.type_name,\n date_part('day', current_timestamp - r.last_cleaned_at) AS days_since_cleaned\nFROM hospitality_technology.rooms r\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nWHERE r.status = 'Available';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.maintenance_logs (\n log_id character varying(64) NOT NULL, -- unique identifier for the maintenance record\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle serviced\n service_date date NOT NULL, -- date the service was performed\n odometer_reading integer, -- vehicle mileage at time of service\n service_type character varying(128) NOT NULL, -- type of service (e.g., Oil Change, Tire Rotation, Engine Repair)\n description text NOT NULL, -- detailed description of work done\n cost numeric(10, 2), -- cost of the service\n mechanic_name character varying(128), -- name or ID of the mechanic/shop\n next_service_due_date date, -- recommended date for next service\n PRIMARY KEY (log_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all vehicles that are due for their next service before the end of this month, along with their last service type and date."}, {"role": "assistant", "content": "SELECT vehicle_id, service_type, service_date FROM transportation.maintenance_logs WHERE next_service_due_date <= DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' - INTERVAL '1 day';"}, {"role": "user", "content": "Can you include the mechanic who performed the last service and order by how soon the next service is due?"}, {"role": "assistant", "content": "SELECT vehicle_id, service_type, service_date, mechanic_name, next_service_due_date FROM transportation.maintenance_logs WHERE next_service_due_date <= DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' - INTERVAL '1 day' ORDER BY next_service_due_date ASC;"}, {"role": "user", "content": "There seems to be a typo in your SQL - it should be 'INTERVAL' not 'INTERVAL'. Also, can you include the cost of the last service?"}, {"role": "assistant", "content": "SELECT vehicle_id, service_type, service_date, mechanic_name, next_service_due_date, cost FROM transportation.maintenance_logs WHERE next_service_due_date <= DATE_TRUNC('month', CURRENT_DATE) + INTERVAL '1 month' - INTERVAL '1 day' ORDER BY next_service_due_date ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id.text, customer_id.text, product_id.text, agent_id.text, policy_number.text, start_date.date, end_date.date, premium_amount.numeric, coverage_limit.numeric, deductible.numeric, status.text, issued_at.timestamp, cancellation_date.date, cancellation_reason.text )\n", "conversations": [{"role": "user", "content": "Show the agent_id and the total number of policies managed by each agent, but only include agents with at least 5 policies."}, {"role": "assistant", "content": "SELECT agent_id, COUNT(*) AS policy_count FROM insurance.policies GROUP BY agent_id HAVING COUNT(*) >= 5;"}, {"role": "user", "content": "For those agents, can you also show the total combined premium_amount across all their policies, labeled as total_premium?"}, {"role": "assistant", "content": "SELECT agent_id, COUNT(*) AS policy_count, SUM(premium_amount) AS total_premium FROM insurance.policies GROUP BY agent_id HAVING COUNT(*) >= 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE narrative_info ( narrative text, top_3_coins text, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, market_cap numeric, volume_24h numeric, trend_rank numeric, token_num numeric )\n", "conversations": [{"role": "user", "content": "Show the top 5 narratives ranked by trend_rank (lowest is better). Include the narrative, trend rank, and number of tokens."}, {"role": "assistant", "content": "SELECT narrative, trend_rank, token_num FROM narrative_info ORDER BY trend_rank ASC LIMIT 5;"}, {"role": "user", "content": "Can you also add their 24h and 7d price change percentages in the output?"}, {"role": "assistant", "content": "SELECT narrative, trend_rank, token_num, price_change_percentage_24h, price_change_percentage_7d FROM narrative_info ORDER BY trend_rank ASC LIMIT 5;"}, {"role": "user", "content": "Now, I want to see only those narratives where the total 24h trading volume is above $10 million."}, {"role": "assistant", "content": "SELECT narrative, trend_rank, token_num, price_change_percentage_24h, price_change_percentage_7d, volume_24h FROM narrative_info WHERE volume_24h > 10000000 ORDER BY trend_rank ASC LIMIT 5;"}, {"role": "user", "content": "Can you show trend_rank as the last column?"}, {"role": "assistant", "content": "SELECT narrative, token_num, price_change_percentage_24h, price_change_percentage_7d, volume_24h, trend_rank FROM narrative_info WHERE volume_24h > 10000000 ORDER BY trend_rank ASC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id.text, employee_id.text, first_name.text, last_name.text, license_number.text, license_expiry_date.date, contact_number.text, email.text, hire_date.date, status.text )\n", "conversations": [{"role": "user", "content": "Calculate the total number of drivers for each status."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS driver_count\nFROM transportation.drivers\nGROUP BY status;"}, {"role": "user", "content": "Now only include statuses with more than 10 drivers."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS driver_count\nFROM transportation.drivers\nGROUP BY status\nHAVING COUNT(*) > 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address.text, city.text, state.text, zip_code.text, country.text, email.text, phone_number.text, created_at.timestamp, status.text, risk_profile.text )\nCREATE TABLE financial_services.accounts (\n account_id character varying(64) NOT NULL, -- unique identifier for the account\n customer_id character varying(64) NOT NULL, -- foreign key linking to the customer\n account_number character varying(128) NOT NULL UNIQUE, -- unique account number visible to customer\n account_type character varying(50) NOT NULL, -- e.g., Checking, Savings, Investment, Loan, Credit Card\n balance numeric(19, 4) NOT NULL DEFAULT 0.00, -- current account balance\n currency character varying(3) NOT NULL, -- currency code (e.g., USD, EUR)\n opened_date date NOT NULL, -- date the account was opened\n status character varying(32) NOT NULL, -- e.g., Open, Closed, Frozen\n interest_rate numeric(5, 4), -- annual interest rate, if applicable\n last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last account update\n PRIMARY KEY (account_id),\n FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id)\n)\nCREATE TABLE financial_services.securities ( security_id text PRIMARY KEY, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )\nCREATE TABLE financial_services.employees ( employee_id text PRIMARY KEY, first_name text, last_name text, job_title text, department text, branch_id text, email text, phone_extension text, hire_date date, termination_date date, manager_id text, status text )\n", "conversations": [{"role": "user", "content": "Which customers have accounts in more than one state? Please show their customer_id, full name, and the list of states where they hold accounts."}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name || ' ' || c.last_name AS full_name, STRING_AGG(DISTINCT c.state, ', ') AS states\nFROM financial_services.customers c\nJOIN financial_services.accounts a ON c.customer_id = a.customer_id\nGROUP BY c.customer_id, c.first_name, c.last_name\nHAVING COUNT(DISTINCT c.state) > 1;"}, {"role": "user", "content": "Can you also include the total number of accounts each customer has?"}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name || ' ' || c.last_name AS full_name, STRING_AGG(DISTINCT c.state, ', ') AS states, COUNT(a.account_id) AS total_accounts\nFROM financial_services.customers c\nJOIN financial_services.accounts a ON c.customer_id = a.customer_id\nGROUP BY c.customer_id, c.first_name, c.last_name\nHAVING COUNT(DISTINCT c.state) > 1;"}, {"role": "user", "content": "It seems like it's listing the customer state info rather than the account's. Can you instead show which states are associated with their accounts' addresses?"}, {"role": "assistant", "content": "SELECT c.customer_id, c.first_name || ' ' || c.last_name AS full_name, STRING_AGG(DISTINCT ca.state, ', ') AS account_states, COUNT(a.account_id) AS total_accounts\nFROM financial_services.customers c\nJOIN financial_services.accounts a ON c.customer_id = a.customer_id\nJOIN financial_services.customers ca ON ca.customer_id = a.customer_id\nGROUP BY c.customer_id, c.first_name, c.last_name\nHAVING COUNT(DISTINCT ca.state) > 1;"}, {"role": "user", "content": "Actually, can you pull the state value from the accounts table instead if possible?"}, {"role": "assistant", "content": "-- Assuming accounts table has a 'state' field, otherwise this cannot be done directly as accounts does not have state info per schema.\n-- If not, we must take it from customers as previously, since only customers has 'state'."}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )\nCREATE TABLE trading_platform.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )\nCREATE TABLE trading_platform.orders ( order_id text, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades ( trade_id character varying(64) NOT NULL, order_id character varying(64) NOT NULL, buyer_id character varying(64) NOT NULL, seller_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, traded_at timestamp NOT NULL, PRIMARY KEY (trade_id) )\nCREATE TABLE trading_platform.assets ( asset_id text, name text, symbol text, type text )\nCREATE TABLE trading_platform.dapps ( dapp_id text, name text, description text, url text )\nCREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )\nCREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )\nCREATE TABLE trading_platform.notifications ( notification_id text, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "List all unique actions that have been logged in the system."}, {"role": "assistant", "content": "SELECT DISTINCT action FROM trading_platform.logs;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players ( player_id uuid PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id.uuid, player_id.uuid, item_id.uuid, quantity.integer, acquired_at.timestamptz, instance_data.jsonb )\n", "conversations": [{"role": "user", "content": "Which players have acquired more than 3 different items in their inventory? Show player_id and the count of unique item_ids."}, {"role": "assistant", "content": "SELECT pi.player_id, COUNT(DISTINCT pi.item_id) AS unique_items\nFROM gaming_technology.player_inventory pi\nGROUP BY pi.player_id\nHAVING COUNT(DISTINCT pi.item_id) > 3;"}, {"role": "user", "content": "Please also show the usernames of these players."}, {"role": "assistant", "content": "SELECT p.player_id, p.username, COUNT(DISTINCT pi.item_id) AS unique_items\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nGROUP BY p.player_id, p.username\nHAVING COUNT(DISTINCT pi.item_id) > 3;"}, {"role": "user", "content": "Add the total quantity of all items each player owns."}, {"role": "assistant", "content": "SELECT p.player_id, p.username, COUNT(DISTINCT pi.item_id) AS unique_items, SUM(pi.quantity) AS total_quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nGROUP BY p.player_id, p.username\nHAVING COUNT(DISTINCT pi.item_id) > 3;"}, {"role": "user", "content": "Only show players where the total_quantity is at least 100. Sort by total_quantity descending."}, {"role": "assistant", "content": "SELECT p.player_id, p.username, COUNT(DISTINCT pi.item_id) AS unique_items, SUM(pi.quantity) AS total_quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nGROUP BY p.player_id, p.username\nHAVING COUNT(DISTINCT pi.item_id) > 3\n AND SUM(pi.quantity) >= 100\nORDER BY total_quantity DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text )\n", "conversations": [{"role": "user", "content": "Show me all claims handled by agent 'AG123' along with their settlement details."}, {"role": "assistant", "content": "SELECT claim_id, policy_id, customer_id, settlement_amount, settlement_date FROM insurance.claims WHERE claim_handler_id = 'AG123';"}, {"role": "user", "content": "I want to see only claims that were settled for more than $10,000."}, {"role": "assistant", "content": "SELECT claim_id, policy_id, customer_id, settlement_amount, settlement_date FROM insurance.claims WHERE claim_handler_id = 'AG123' AND settlement_amount > 10000;"}, {"role": "user", "content": "Now include the time it took to settle these claims (difference between reported_date and settlement_date)."}, {"role": "assistant", "content": "SELECT claim_id, policy_id, customer_id, settlement_amount, settlement_date, DATEDIFF(settlement_date, reported_date) AS days_to_settle FROM insurance.claims WHERE claim_handler_id = 'AG123' AND settlement_amount > 10000;"}, {"role": "user", "content": "Finally, order the results by the longest settlement time first."}, {"role": "assistant", "content": "SELECT claim_id, policy_id, customer_id, settlement_amount, settlement_date, DATEDIFF(settlement_date, reported_date) AS days_to_settle FROM insurance.claims WHERE claim_handler_id = 'AG123' AND settlement_amount > 10000 ORDER BY days_to_settle DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nUse Hashes. Key pattern: 'component:'. Example: HSET component:LGSTRUT01 part_number \"PN-5521-A\" component_name \"Landing Gear Strut\" material_id \"mat:TI64\" supplier_id \"sup:ACME_AERO\" ... Consider Sets for reverse lookups (e.g., 'material_components:' -> Set).\n", "conversations": [{"role": "user", "content": "Can you help me get a list of components and their associated materials, including the supplier information for each component?"}, {"role": "assistant", "content": "SMEMBERS material_components:\nHGETALL component:\nHGET component: supplier_id\nHGET component: material_id"}, {"role": "user", "content": "Can you filter this to show only components from a specific material ID?"}, {"role": "assistant", "content": "SMEMBERS material_components:mat:TI64\nHGETALL component:\nHGET component: supplier_id\nHGET component: material_id"}, {"role": "user", "content": "What if I want to see only components from a specific supplier as well?"}, {"role": "assistant", "content": "SMEMBERS material_components:mat:TI64\nHGETALL component:\nHGET component: supplier_id\nIF HGET component: supplier_id = 'sup:ACME_AERO' THEN INCLUDE\nHGET component: material_id"}, {"role": "user", "content": "Can you also include the component name and sort the results by component name?"}, {"role": "assistant", "content": "SMEMBERS material_components:mat:TI64\nHGETALL component:\nHGET component: supplier_id\nIF HGET component: supplier_id = 'sup:ACME_AERO' THEN INCLUDE\nHGET component: material_id\nHGET component: component_name\nSORT BY component_name ASC"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid PRIMARY KEY, player_id uuid, game_id uuid, server_id uuid, start_time timestamptz, end_time timestamptz, duration_seconds int, score int, session_data jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, achievement_id uuid NOT NULL, unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id.uuid, player_id.uuid, item_id.uuid, quantity.integer, acquired_at.timestamptz, instance_data.jsonb )\n", "conversations": [{"role": "user", "content": "List the total number of items acquired by each player, grouped by rarity, for items that have been acquired at least twice."}, {"role": "assistant", "content": "SELECT pi.player_id, igi.rarity, SUM(pi.quantity) AS total_acquired\nFROM gaming_technology.player_inventory pi\nJOIN gaming_technology.in_game_items igi ON pi.item_id = igi.item_id\nGROUP BY pi.player_id, igi.rarity\nHAVING SUM(pi.quantity) >= 2;"}, {"role": "user", "content": "Also show only rarities that are 'Epic' or 'Legendary'."}, {"role": "assistant", "content": "SELECT pi.player_id, igi.rarity, SUM(pi.quantity) AS total_acquired\nFROM gaming_technology.player_inventory pi\nJOIN gaming_technology.in_game_items igi ON pi.item_id = igi.item_id\nWHERE igi.rarity IN ('Epic', 'Legendary')\nGROUP BY pi.player_id, igi.rarity\nHAVING SUM(pi.quantity) >= 2;"}, {"role": "user", "content": "Can you also include the most recent acquisition date for each (player, rarity) pair?"}, {"role": "assistant", "content": "SELECT pi.player_id, igi.rarity, SUM(pi.quantity) AS total_acquired, MAX(pi.acquired_at) AS last_acquired_at\nFROM gaming_technology.player_inventory pi\nJOIN gaming_technology.in_game_items igi ON pi.item_id = igi.item_id\nWHERE igi.rarity IN ('Epic', 'Legendary')\nGROUP BY pi.player_id, igi.rarity\nHAVING SUM(pi.quantity) >= 2;"}, {"role": "user", "content": "Sort the result by total_acquired descending, then by last_acquired_at descending."}, {"role": "assistant", "content": "SELECT pi.player_id, igi.rarity, SUM(pi.quantity) AS total_acquired, MAX(pi.acquired_at) AS last_acquired_at\nFROM gaming_technology.player_inventory pi\nJOIN gaming_technology.in_game_items igi ON pi.item_id = igi.item_id\nWHERE igi.rarity IN ('Epic', 'Legendary')\nGROUP BY pi.player_id, igi.rarity\nHAVING SUM(pi.quantity) >= 2\nORDER BY total_acquired DESC, last_acquired_at DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.documents ( document_id text PRIMARY KEY, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version int, description text )\n", "conversations": [{"role": "user", "content": "Can you list all documents along with their upload timestamp and the lawyer ID who uploaded them, for documents of type 'Memorandum'?"}, {"role": "assistant", "content": "SELECT document_name, upload_timestamp, uploaded_by_lawyer_id FROM legal_services.documents WHERE document_type = 'Memorandum';"}, {"role": "user", "content": "Actually, I want to see only those documents that have a version greater than 1."}, {"role": "assistant", "content": "SELECT document_name, upload_timestamp, uploaded_by_lawyer_id FROM legal_services.documents WHERE document_type = 'Memorandum' AND version > 1;"}, {"role": "user", "content": "Can you also include the case ID, and sort the results by upload_timestamp in descending order?"}, {"role": "assistant", "content": "SELECT document_name, case_id, upload_timestamp, uploaded_by_lawyer_id FROM legal_services.documents WHERE document_type = 'Memorandum' AND version > 1 ORDER BY upload_timestamp DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\n", "conversations": [{"role": "user", "content": "List all pairs of achievements unlocked by the same player, showing player_id, achievement1, and achievement2."}, {"role": "assistant", "content": "SELECT pa1.player_id,\n pa1.achievement_id AS achievement1,\n pa2.achievement_id AS achievement2\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.player_id = pa2.player_id\n AND pa1.unlocked_at < pa2.unlocked_at;"}, {"role": "user", "content": "Now include only pairs where the second achievement was unlocked within 7 days of the first."}, {"role": "assistant", "content": "SELECT pa1.player_id,\n pa1.achievement_id AS achievement1,\n pa2.achievement_id AS achievement2\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.player_id = pa2.player_id\n AND pa1.unlocked_at < pa2.unlocked_at\n AND pa2.unlocked_at <= pa1.unlocked_at + INTERVAL '7 days';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )\nCREATE TABLE social_media.comments ( comment_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, parent_comment_id character varying(64), content text NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (comment_id) )\nCREATE TABLE social_media.likes ( like_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, post_id character varying(64), comment_id character varying(64), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (like_id), CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, hashtag_id character varying(64) NOT NULL, PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) )\nCREATE TABLE social_media.user_settings ( setting_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL UNIQUE, theme character varying(20) DEFAULT 'light', email_notifications_enabled boolean DEFAULT true, push_notifications_enabled boolean DEFAULT true, private_profile boolean DEFAULT false, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (setting_id) )\n", "conversations": [{"role": "user", "content": "List all posts that have received at least one like and at least one comment, showing the post_id and the total number of likes and comments each has."}, {"role": "assistant", "content": "SELECT p.post_id, COUNT(DISTINCT l.like_id) AS like_count, COUNT(DISTINCT c.comment_id) AS comment_count\nFROM social_media.likes l\nJOIN social_media.comments c ON l.post_id = c.post_id\nJOIN (SELECT DISTINCT post_id FROM social_media.likes) p ON p.post_id = l.post_id\nGROUP BY p.post_id;"}, {"role": "user", "content": "Also, show the usernames of the users who created each post."}, {"role": "assistant", "content": "SELECT p.post_id, u.username, COUNT(DISTINCT l.like_id) AS like_count, COUNT(DISTINCT c.comment_id) AS comment_count\nFROM social_media.likes l\nJOIN social_media.comments c ON l.post_id = c.post_id\nJOIN posts p ON p.post_id = l.post_id\nJOIN social_media.users u ON p.user_id = u.user_id\nGROUP BY p.post_id, u.username;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.utxos (\n utxo_id character varying(64) NOT NULL, -- unique identifier for the UTXO\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction that created the UTXO\n output_index integer NOT NULL, -- index of the output in the transaction\n address character varying(128) NOT NULL, -- address that can spend the UTXO\n amount numeric(38,14) NOT NULL, -- amount of the asset in the UTXO\n spent boolean NOT NULL, -- whether the UTXO has been spent\n PRIMARY KEY (utxo_id)\n)\nCREATE TABLE trading_platform.dapps (\n dapp_id character varying(64) NOT NULL, -- unique identifier for the DApp\n name character varying(128) NOT NULL, -- name of the DApp\n description text NOT NULL, -- description of the DApp\n url character varying(256) NOT NULL, -- URL of the DApp\n PRIMARY KEY (dapp_id)\n)\n", "conversations": [{"role": "user", "content": "I want a list of DApp names and the asset symbols mentioned in their descriptions."}, {"role": "assistant", "content": "SELECT d.name AS dapp_name,\n a.symbol AS asset_symbol\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a\n ON d.description ILIKE '%' || a.symbol || '%';"}, {"role": "user", "content": "Now, only include DApps where the description mentions more than one distinct asset symbol."}, {"role": "assistant", "content": "SELECT d.name AS dapp_name,\n COUNT(DISTINCT a.symbol) AS symbol_count\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a\n ON d.description ILIKE '%' || a.symbol || '%'\nGROUP BY d.name\nHAVING COUNT(DISTINCT a.symbol) > 1;"}, {"role": "user", "content": "Also show the comma-separated list of these symbols."}, {"role": "assistant", "content": "SELECT d.name AS dapp_name,\n COUNT(DISTINCT a.symbol) AS symbol_count,\n STRING_AGG(DISTINCT a.symbol, ',') AS symbols_list\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a\n ON d.description ILIKE '%' || a.symbol || '%'\nGROUP BY d.name\nHAVING COUNT(DISTINCT a.symbol) > 1;"}, {"role": "user", "content": "Finally, order the result by number of mentioned assets descending and limit to top 3."}, {"role": "assistant", "content": "SELECT d.name AS dapp_name,\n COUNT(DISTINCT a.symbol) AS symbol_count,\n STRING_AGG(DISTINCT a.symbol, ',') AS symbols_list\nFROM trading_platform.dapps d\nJOIN trading_platform.assets a\n ON d.description ILIKE '%' || a.symbol || '%'\nGROUP BY d.name\nHAVING COUNT(DISTINCT a.symbol) > 1\nORDER BY symbol_count DESC\nLIMIT 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id text PRIMARY KEY, property_id text, room_number text, room_type_id text, floor int, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\n", "conversations": [{"role": "user", "content": "Get all non-smoking rooms with status 'Available'."}, {"role": "assistant", "content": "SELECT room_id, property_id, room_number, floor\nFROM hospitality_technology.rooms\nWHERE is_smoking = FALSE\n AND status = 'Available';"}, {"role": "user", "content": "Now include the property_name for each room."}, {"role": "assistant", "content": "SELECT r.room_id, r.room_number, p.property_name, r.floor\nFROM hospitality_technology.rooms r\nJOIN hospitality_technology.properties p\n ON r.property_id = p.property_id\nWHERE r.is_smoking = FALSE\n AND r.status = 'Available';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE project_fundraising_record ( id.text, project_id.text, project_name.text, rounds_name.text, investment_value.numeric, investment_date.text, introduction.text, valuation.numeric )\nCREATE TABLE token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )\nCREATE TABLE narrative_info ( narrative.text, top_3_coins.text, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, market_cap.numeric, volume_24h.numeric, trend_rank.numeric, token_num.numeric )\nCREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )\nCREATE TABLE cex_token_balance ( snapshot_time.text, chain.text, address.text, exchange.text, token_address.text, token_symbol.text, balance.numeric, usd_value.numeric, price.numeric )\nCREATE TABLE smart_money_profit ( address.text, rank.numeric, profit.numeric, roi.numeric, realized_ratio.numeric, most_profit_token.text, last_trade_time.text, chain.text )\nCREATE TABLE smart_money_token_inflow ( token_address.text, token_symbol.text, token_amount.numeric, usd_value.numeric, avg_price.numeric, type.numeric, address_amount.numeric, narrative.text, chain.text )\n", "conversations": [{"role": "user", "content": "Show me the top 3 tokens with the highest 7-day price change percentage. Display their symbol, chain, and 7d price change."}, {"role": "assistant", "content": "SELECT token_symbol, chain, price_change_percentage_7d\nFROM token_basic_info\nORDER BY price_change_percentage_7d DESC\nLIMIT 3"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.law_firms (\n firm_id character varying(64) NOT NULL, -- unique identifier for the law firm\n firm_name character varying(200) NOT NULL, -- official name of the law firm\n address text NOT NULL, -- primary address of the firm\n phone character varying(32), -- firm's main phone number\n website character varying(255), -- firm's website URL\n founded_date date, -- date the firm was established\n managing_partner_id character varying(64), -- FK to lawyers table (optional)\n PRIMARY KEY (firm_id)\n)\nCREATE TABLE legal_services.cases (\n case_id character varying(64) NOT NULL, -- unique identifier for the case/matter\n case_number character varying(100) UNIQUE, -- official case number (court or internal)\n case_name text NOT NULL, -- descriptive name or title for the case\n client_id character varying(64) NOT NULL, -- FK to clients table\n lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)\n case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP\n status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed\n date_opened timestamp NOT NULL, -- date the case was formally opened\n date_closed timestamp, -- date the case was closed (nullable)\n description text, -- detailed description of the case\n court_jurisdiction character varying(128), -- court or jurisdiction if applicable\n PRIMARY KEY (case_id)\n)\nCREATE TABLE legal_services.time_entries (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\nCREATE TABLE legal_services.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "For each lead_lawyer_id, list the case_number along with the total unbilled hours and the total unbilled amount for that case."}, {"role": "assistant", "content": "SELECT\n c.lead_lawyer_id,\n c.case_number,\n SUM(te.hours_spent) AS total_unbilled_hours,\n SUM(te.hours_spent * te.billing_rate) AS total_unbilled_amount\nFROM legal_services.cases AS c\nJOIN legal_services.time_entries AS te\n ON c.case_id = te.case_id\nWHERE te.is_billed = false\nGROUP BY c.lead_lawyer_id, c.case_number;"}, {"role": "user", "content": "Actually, restrict the calculation to time entries recorded in 2024 only."}, {"role": "assistant", "content": "SELECT\n c.lead_lawyer_id,\n c.case_number,\n SUM(te.hours_spent) AS total_unbilled_hours,\n SUM(te.hours_spent * te.billing_rate) AS total_unbilled_amount\nFROM legal_services.cases AS c\nJOIN legal_services.time_entries AS te\n ON c.case_id = te.case_id\nWHERE te.is_billed = false\n AND te.date_worked >= '2024-01-01'\n AND te.date_worked < '2025-01-01'\nGROUP BY c.lead_lawyer_id, c.case_number;"}, {"role": "user", "content": "Also only include cases where there are at least 3 unbilled time entries per lead lawyer."}, {"role": "assistant", "content": "SELECT\n c.lead_lawyer_id,\n c.case_number,\n SUM(te.hours_spent) AS total_unbilled_hours,\n SUM(te.hours_spent * te.billing_rate) AS total_unbilled_amount\nFROM legal_services.cases AS c\nJOIN legal_services.time_entries AS te\n ON c.case_id = te.case_id\nWHERE te.is_billed = false\n AND te.date_worked >= '2024-01-01'\n AND te.date_worked < '2025-01-01'\nGROUP BY c.lead_lawyer_id, c.case_number\nHAVING COUNT(te.entry_id) >= 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )\nCREATE TABLE trading_platform.wallets ( wallet_id text PRIMARY KEY, user_id text, address text, private_key text, created_at timestamp )\nCREATE TABLE trading_platform.orders ( order_id text PRIMARY KEY, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades ( trade_id text PRIMARY KEY, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp )\nCREATE TABLE trading_platform.peers ( peer_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id text PRIMARY KEY, asset_id text, key text, value text )\nCREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )\nCREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "Find all users who have wallets but have never logged any actions, along with their wallet creation date."}, {"role": "assistant", "content": "SELECT u.user_id, u.email, w.created_at AS wallet_created_at FROM trading_platform.users u JOIN trading_platform.wallets w ON u.user_id = w.user_id LEFT JOIN trading_platform.logs l ON u.user_id = l.user_id WHERE l.log_id IS NULL"}, {"role": "user", "content": "Now include the count of wallets each user has and filter for users created in the last year."}, {"role": "assistant", "content": "SELECT u.user_id, u.email, COUNT(w.wallet_id) AS wallet_count, MAX(w.created_at) AS latest_wallet_created_at FROM trading_platform.users u JOIN trading_platform.wallets w ON u.user_id = w.user_id LEFT JOIN trading_platform.logs l ON u.user_id = l.user_id WHERE l.log_id IS NULL AND u.created_at >= NOW() - INTERVAL '1 year' GROUP BY u.user_id, u.email"}, {"role": "user", "content": "Actually, I want to see only users with more than 1 wallet, ordered by wallet count descending."}, {"role": "assistant", "content": "SELECT u.user_id, u.email, COUNT(w.wallet_id) AS wallet_count, MAX(w.created_at) AS latest_wallet_created_at FROM trading_platform.users u JOIN trading_platform.wallets w ON u.user_id = w.user_id LEFT JOIN trading_platform.logs l ON u.user_id = l.user_id WHERE l.log_id IS NULL AND u.created_at >= NOW() - INTERVAL '1 year' GROUP BY u.user_id, u.email HAVING COUNT(w.wallet_id) > 1 ORDER BY wallet_count DESC"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n// Use Hashes for platform details. Key format: platform:\n// HSET platform:plat_123 platform_id \"plat_123\" station_id \"station_xyz\" platform_number \"1A\" track_number \"T1\" status \"Operational\" length_meters 250.50 accessible 1\n\n// To link platforms to stations (optional):\n// SADD station:station_xyz:platforms platform:plat_123 platform:plat_456\n// Use Hashes for train details. Key format: train:\n// HSET train:train_789 train_id \"train_789\" train_number \"Acela 2151\" model \"Siemens Velaro\" ... status \"Active\" ...\n\n// To find train by train_number (optional index):\n// SET train_number:\"Acela 2151\" train:train_789\n// Use Hashes for car details. Key format: car:\n// HSET car:car_abc car_id \"car_abc\" train_id \"train_789\" car_number \"C3\" car_type \"Passenger\" class \"Business\" capacity 60 features \"WiFi,Power Outlet\"\n\n// To link cars to trains (optional):\n// SADD train:train_789:cars car:car_abc car:car_def\n// Use Hashes for details. Key format: route_station:\n// HSET route_station:rs_ne_1 route_station_id \"rs_ne_1\" route_id \"route_ne_corr\" station_id \"station_bos\" sequence_order 1 ...\n\n// To find stops for a route, use a Sorted Set (score by sequence_order):\n// ZADD route:route_ne_corr:stops 1 route_station:rs_ne_1\n// ZADD route:route_ne_corr:stops 2 route_station:rs_ne_2\n// Use Hashes for schedule details. Key format: schedule:\n// HSET schedule:sched_1122 schedule_id \"sched_1122\" train_id \"train_789\" route_id \"route_ne_corr\" departure_datetime \"2024-05-10T08:00:00-04:00\" ... status \"Scheduled\"\n// Use Hashes for details. Key format: schedule_stop:\n// HSET schedule_stop:stop_sched1122_1 stop_id \"stop_sched1122_1\" schedule_id \"sched_1122\" station_id \"station_bos\" ...\n\n// To find stops for a schedule, use a Sorted Set (score by sequence_order):\n// ZADD schedule:sched_1122:stops 1 schedule_stop:stop_sched1122_1\n// ZADD schedule:sched_1122:stops 2 schedule_stop:stop_sched1122_2\n// Use Hashes for passenger details. Key format: passenger:\n// HSET passenger:pass_pqr passenger_id \"pass_pqr\" first_name \"Alice\" last_name \"Smith\" email \"alice.smith@example.com\" ...\n\n// To find passenger by email (optional index):\n// SET passenger_email:\"alice.smith@example.com\" passenger:pass_pqr\n// Use Hashes for booking details. Key format: booking:\n// HSET booking:book_zyx booking_id \"book_zyx\" passenger_id \"pass_pqr\" schedule_id \"sched_1122\" ... status \"Confirmed\" ...\n\n// To link bookings to passengers/schedules (optional):\n// SADD passenger:pass_pqr:bookings booking:book_zyx\n// SADD schedule:sched_1122:bookings booking:book_zyx\n// Use Hashes for ticket details. Key format: ticket:\n// HSET ticket:tkt_1a2b ticket_id \"tkt_1a2b\" booking_id \"book_zyx\" car_id \"car_abc\" seat_number \"12A\" ... is_checked_in 0 ...\n\n// To link tickets to bookings (optional):\n// SADD booking:book_zyx:tickets ticket:tkt_1a2b\n// Use Hashes for staff details. Key format: staff:\n// HSET staff:staff_mno staff_id \"staff_mno\" first_name \"Bob\" ... employee_number \"E12345\" ... is_active 1\n\n// To find staff by employee number (optional index):\n// SET staff_employee_number:\"E12345\" staff:staff_mno\n// Use Hashes for maintenance record details. Key format: maintenance_record:\n// HSET maintenance_record:maint_rec_001 record_id \"maint_rec_001\" asset_id \"train_789\" asset_type \"Train\" ... status \"Completed\"\n\n// To link records to assets (optional):\n// SADD train:train_789:maintenance maintenance_record:maint_rec_001\n// SADD platform:plat_123:maintenance maintenance_record:maint_rec_002\n", "conversations": [{"role": "user", "content": "Can you help me retrieve the details of all schedules for a specific train with train_id 'train_789', including the route and stops information?"}, {"role": "assistant", "content": "HGETALL train:train_789\nSMEMBERS schedule:sched_*:train:train_789\nHGETALL schedule:sched_*\nHGETALL route:route_*\nZRANGE schedule:sched_*:stops 0 -1\nHGETALL schedule_stop:stop_*"}, {"role": "user", "content": "Can you filter the schedules to only include those with a status of 'Scheduled'?"}, {"role": "assistant", "content": "HGETALL train:train_789\nSMEMBERS schedule:sched_*:train:train_789\nHGETALL schedule:sched_*\nHGET schedule:sched_* status\nIF status == 'Scheduled' THEN\nHGETALL route:route_*\nZRANGE schedule:sched_*:stops 0 -1\nHGETALL schedule_stop:stop_*\nENDIF"}, {"role": "user", "content": "Can you also include the departure datetime for each schedule in the result?"}, {"role": "assistant", "content": "HGETALL train:train_789\nSMEMBERS schedule:sched_*:train:train_789\nHGETALL schedule:sched_*\nHGET schedule:sched_* status\nHGET schedule:sched_* departure_datetime\nIF status == 'Scheduled' THEN\nHGETALL route:route_*\nZRANGE schedule:sched_*:stops 0 -1\nHGETALL schedule_stop:stop_*\nENDIF"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.claims (\n claim_id character varying(64) NOT NULL, -- unique identifier for the claim\n policy_id character varying(64) NOT NULL, -- identifier of the policy under which the claim is made (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the claim (FK to customers)\n incident_date timestamp NOT NULL, -- date and time of the incident leading to the claim\n reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the claim was reported\n description text NOT NULL, -- detailed description of the incident and claim\n estimated_loss numeric(15, 2), -- initial estimated cost of the loss\n status character varying(30) NOT NULL, -- e.g., Filed, Processing, Under Review, Approved, Denied, Settled\n settlement_amount numeric(15, 2), -- final amount paid out\n settlement_date date,\n claim_handler_id character varying(64), -- identifier for the employee handling the claim (FK to employees/adjusters)\n police_report_number character varying(100),\n PRIMARY KEY (claim_id)\n)\nCREATE TABLE insurance.insurance_products (\n product_id character varying(64) NOT NULL, -- unique identifier for the insurance product\n product_name character varying(150) NOT NULL, -- name of the insurance product (e.g., 'Comprehensive Auto Insurance')\n product_type character varying(50) NOT NULL, -- category like 'Auto', 'Home', 'Life', 'Health', 'Travel'\n description text, -- detailed description of the product\n base_premium numeric(10, 2) NOT NULL, -- starting premium before adjustments\n coverage_details text, -- details about what is covered (could be JSON or structured text)\n underwriting_rules text, -- rules used for assessing risk and eligibility\n is_active boolean NOT NULL DEFAULT true, -- whether the product is currently offered\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at timestamp,\n PRIMARY KEY (product_id)\n)\nCREATE TABLE insurance.claim_documents ( document_id character varying(64) NOT NULL, claim_id character varying(64) NOT NULL, document_type character varying(50) NOT NULL, file_name character varying(255) NOT NULL, file_path character varying(512) NOT NULL, file_size_bytes integer, mime_type character varying(100), uploaded_by character varying(64), uploaded_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text, PRIMARY KEY (document_id) )\n", "conversations": [{"role": "user", "content": "I need a list of all documents associated with claims, showing the document ID, file name, document type, and the status of the claim it belongs to."}, {"role": "assistant", "content": "SELECT\n cd.document_id,\n cd.file_name,\n cd.document_type,\n c.status AS claim_status\nFROM insurance.claim_documents AS cd\nJOIN insurance.claims AS c\n ON cd.claim_id = c.claim_id;"}, {"role": "user", "content": "Okay, now filter those results to only include documents where the claim status is 'Processing'."}, {"role": "assistant", "content": "SELECT\n cd.document_id,\n cd.file_name,\n cd.document_type,\n c.status AS claim_status\nFROM insurance.claim_documents AS cd\nJOIN insurance.claims AS c\n ON cd.claim_id = c.claim_id\nWHERE\n c.status = 'Processing';"}, {"role": "user", "content": "Could you also add the estimated loss for these 'Processing' claims and order the results by file size descending?"}, {"role": "assistant", "content": "SELECT\n cd.document_id,\n cd.file_name,\n cd.document_type,\n c.status AS claim_status,\n c.estimated_loss,\n cd.file_size_bytes\nFROM insurance.claim_documents AS cd\nJOIN insurance.claims AS c\n ON cd.claim_id = c.claim_id\nWHERE\n c.status = 'Processing'\nORDER BY\n cd.file_size_bytes DESC;"}, {"role": "user", "content": "Actually, forget the estimated loss and file size. Just show the document ID, file name, document type, claim status, and the incident date of the claim for those 'Processing' claims, ordered by incident date descending."}, {"role": "assistant", "content": "SELECT\n cd.document_id,\n cd.file_name,\n cd.document_type,\n c.status AS claim_status,\n c.incident_date\nFROM insurance.claim_documents AS cd\nJOIN insurance.claims AS c\n ON cd.claim_id = c.claim_id\nWHERE\n c.status = 'Processing'\nORDER BY\n c.incident_date DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.player_inventory (\n inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry\n player_id uuid NOT NULL, -- FK linking to the player owning the item\n item_id uuid NOT NULL, -- FK linking to the item definition\n quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items)\n acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired\n instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability)\n PRIMARY KEY (inventory_id),\n -- Optional unique constraint if items are non-stackable or unique instances\n -- UNIQUE (player_id, item_id) -- Use if quantity is always 1\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id)\n)\n", "conversations": [{"role": "user", "content": "Show the latest time each player acquired any item."}, {"role": "assistant", "content": "SELECT player_id, MAX(acquired_at) AS last_acquired_at FROM gaming_technology.player_inventory GROUP BY player_id;"}, {"role": "user", "content": "Actually, can you also show the total number of items that each player acquired?"}, {"role": "assistant", "content": "SELECT player_id, MAX(acquired_at) AS last_acquired_at, SUM(quantity) AS total_items_acquired FROM gaming_technology.player_inventory GROUP BY player_id;"}, {"role": "user", "content": "I would also like this ordered by total_items_acquired descending."}, {"role": "assistant", "content": "SELECT player_id, MAX(acquired_at) AS last_acquired_at, SUM(quantity) AS total_items_acquired FROM gaming_technology.player_inventory GROUP BY player_id ORDER BY total_items_acquired DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.token_transfers (\n transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer\n token_id character varying(64) NOT NULL, -- identifier of the token being transferred\n from_address character varying(128) NOT NULL, -- address of the sender\n to_address character varying(128) NOT NULL, -- address of the receiver\n value numeric(38,14) NOT NULL, -- amount of tokens transferred\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer\n log_index integer NOT NULL, -- index of the transfer log in the transaction\n PRIMARY KEY (transfer_id)\n)\n", "conversations": [{"role": "user", "content": "Find pairs of distinct token transfers that occurred in the same transaction and were initiated by the same sender address. List the transaction ID, the common sender address, and both transfer IDs."}, {"role": "assistant", "content": "SELECT\n t1.transaction_id,\n t1.from_address,\n t1.transfer_id AS transfer_id_1,\n t2.transfer_id AS transfer_id_2\nFROM web3.token_transfers AS t1\nJOIN web3.token_transfers AS t2\n ON t1.transaction_id = t2.transaction_id\n AND t1.from_address = t2.from_address\nWHERE\n t1.transfer_id < t2.transfer_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id text PRIMARY KEY, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\n", "conversations": [{"role": "user", "content": "Find all pairs of drivers where one driver's license_expiry_date is earlier than another's. Return each pair's driver_ids, full names, and respective expiry dates."}, {"role": "assistant", "content": "SELECT d1.driver_id AS driver1_id, d1.first_name || ' ' || d1.last_name AS driver1_name, d1.license_expiry_date AS expiry1, d2.driver_id AS driver2_id, d2.first_name || ' ' || d2.last_name AS driver2_name, d2.license_expiry_date AS expiry2 FROM transportation.drivers d1 JOIN transportation.drivers d2 ON d1.license_expiry_date < d2.license_expiry_date;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid, player_id uuid, item_id uuid, quantity integer, acquired_at timestamp with time zone, instance_data jsonb )\n", "conversations": [{"role": "user", "content": "Find players who acquired two different items within the same minute. List the player ID, and the inventory IDs of the two acquisitions."}, {"role": "assistant", "content": "SELECT t1.player_id, t1.inventory_id AS inventory_id_1, t2.inventory_id AS inventory_id_2 FROM gaming_technology.player_inventory t1 JOIN gaming_technology.player_inventory t2 ON t1.player_id = t2.player_id AND t1.inventory_id <> t2.inventory_id AND t1.item_id <> t2.item_id WHERE ABS(EXTRACT(EPOCH FROM (t1.acquired_at - t2.acquired_at))) <= 60;"}, {"role": "user", "content": "Also include the exact difference in seconds between the acquisition times for each pair."}, {"role": "assistant", "content": "SELECT t1.player_id, t1.inventory_id AS inventory_id_1, t2.inventory_id AS inventory_id_2, ABS(EXTRACT(EPOCH FROM (t1.acquired_at - t2.acquired_at))) AS time_diff_seconds FROM gaming_technology.player_inventory t1 JOIN gaming_technology.player_inventory t2 ON t1.player_id = t2.player_id AND t1.inventory_id <> t2.inventory_id AND t1.item_id <> t2.item_id WHERE ABS(EXTRACT(EPOCH FROM (t1.acquired_at - t2.acquired_at))) <= 60;"}, {"role": "user", "content": "Ensure that for each pair, the first acquired item is listed before the second one (using inventory_id to break ties if acquired_at is identical)."}, {"role": "assistant", "content": "SELECT t1.player_id, t1.inventory_id AS inventory_id_1, t2.inventory_id AS inventory_id_2, EXTRACT(EPOCH FROM (t2.acquired_at - t1.acquired_at)) AS time_diff_seconds FROM gaming_technology.player_inventory t1 JOIN gaming_technology.player_inventory t2 ON t1.player_id = t2.player_id AND (t1.acquired_at < t2.acquired_at OR (t1.acquired_at = t2.acquired_at AND t1.inventory_id < t2.inventory_id)) AND t1.item_id <> t2.item_id WHERE EXTRACT(EPOCH FROM (t2.acquired_at - t1.acquired_at)) <= 60;"}, {"role": "user", "content": "Filter the results to only show pairs where the time difference is exactly 30 seconds or less, and order by the time difference."}, {"role": "assistant", "content": "SELECT t1.player_id, t1.inventory_id AS inventory_id_1, t2.inventory_id AS inventory_id_2, EXTRACT(EPOCH FROM (t2.acquired_at - t1.acquired_at)) AS time_diff_seconds FROM gaming_technology.player_inventory t1 JOIN gaming_technology.player_inventory t2 ON t1.player_id = t2.player_id AND (t1.acquired_at < t2.acquired_at OR (t1.acquired_at = t2.acquired_at AND t1.inventory_id < t2.inventory_id)) AND t1.item_id <> t2.item_id WHERE EXTRACT(EPOCH FROM (t2.acquired_at - t1.acquired_at)) <= 30 ORDER BY time_diff_seconds ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Retrieve the patient_id, email, and phone_number for all patients whose email ends with '@gmail.com'."}, {"role": "assistant", "content": "SELECT patient_id, email, phone_number FROM healthcare.patients WHERE email LIKE '%@gmail.com';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\n", "conversations": [{"role": "user", "content": "How many messages currently have a media file attached?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM social_media.messages WHERE media_url IS NOT NULL;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.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 )\n", "conversations": [{"role": "user", "content": "List all unique document types along with the count of documents for each type."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) AS document_count FROM legal_services.documents GROUP BY document_type;"}, {"role": "user", "content": "Can you exclude document types where the count is less than 3?"}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) AS document_count FROM legal_services.documents GROUP BY document_type HAVING COUNT(*) >= 3;"}, {"role": "user", "content": "Include only those document types which are not null."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) AS document_count FROM legal_services.documents WHERE document_type IS NOT NULL GROUP BY document_type HAVING COUNT(*) >= 3;"}, {"role": "user", "content": "Please order the results by document_count in descending order."}, {"role": "assistant", "content": "SELECT document_type, COUNT(*) AS document_count FROM legal_services.documents WHERE document_type IS NOT NULL GROUP BY document_type HAVING COUNT(*) >= 3 ORDER BY document_count DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\n", "conversations": [{"role": "user", "content": "I want to identify pairs of players who unlocked the same achievement within one hour of each other. List player1_id, player2_id, achievement_id, and the time difference in minutes."}, {"role": "assistant", "content": "SELECT pa1.player_id AS player1_id,\n pa2.player_id AS player2_id,\n pa1.achievement_id,\n ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) AS time_diff_minutes\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.achievement_id = pa2.achievement_id\n AND pa1.player_id <> pa2.player_id\nWHERE ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) <= 60;"}, {"role": "user", "content": "Actually, ensure we only list each pair once by showing only cases where player1_id < player2_id."}, {"role": "assistant", "content": "SELECT pa1.player_id AS player1_id,\n pa2.player_id AS player2_id,\n pa1.achievement_id,\n ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) AS time_diff_minutes\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.achievement_id = pa2.achievement_id\n AND pa1.player_id < pa2.player_id\nWHERE ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) <= 60;"}, {"role": "user", "content": "Also, only include cases where the time difference is less than 30 minutes."}, {"role": "assistant", "content": "SELECT pa1.player_id AS player1_id,\n pa2.player_id AS player2_id,\n pa1.achievement_id,\n ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) AS time_diff_minutes\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.achievement_id = pa2.achievement_id\n AND pa1.player_id < pa2.player_id\nWHERE ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) < 30;"}, {"role": "user", "content": "And only for achievements unlocked after '2023-01-01'."}, {"role": "assistant", "content": "SELECT pa1.player_id AS player1_id,\n pa2.player_id AS player2_id,\n pa1.achievement_id,\n ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) AS time_diff_minutes\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.achievement_id = pa2.achievement_id\n AND pa1.player_id < pa2.player_id\nWHERE pa1.unlocked_at >= '2023-01-01'\n AND pa2.unlocked_at >= '2023-01-01'\n AND ABS(EXTRACT(EPOCH FROM (pa1.unlocked_at - pa2.unlocked_at)) / 60) < 30;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id text PRIMARY KEY, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )\n", "conversations": [{"role": "user", "content": "Could you provide the booking ID, route number, and fare for all bookings?"}, {"role": "assistant", "content": "SELECT T1.booking_id, T2.route_number, T1.fare FROM transportation.bookings AS T1 JOIN transportation.routes AS T2 ON T1.trip_id = T2.route_id;"}, {"role": "user", "content": "Now, filter the results to only include bookings with a fare greater than 100 and sort them by fare in descending order."}, {"role": "assistant", "content": "SELECT T1.booking_id, T2.route_number, T1.fare FROM transportation.bookings AS T1 JOIN transportation.routes AS T2 ON T1.trip_id = T2.route_id WHERE T1.fare > 100 ORDER BY T1.fare DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id character varying(64) NOT NULL, license_plate character varying(32) NOT NULL UNIQUE, vin character varying(17) UNIQUE, make character varying(64) NOT NULL, model character varying(64) NOT NULL, year integer NOT NULL, type character varying(32) NOT NULL, capacity integer, fuel_type character varying(32) NOT NULL, status character varying(32) NOT NULL, depot_id character varying(64), acquisition_date date, PRIMARY KEY (vehicle_id) )\nCREATE TABLE transportation.drivers ( driver_id text PRIMARY KEY, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.trips ( trip_id.text, route_id.text, vehicle_id.text, driver_id.text, scheduled_departure.timestamp, actual_departure.timestamp, scheduled_arrival.timestamp, actual_arrival.timestamp, origin_location_id.text, destination_location_id.text, status.text, passenger_count.integer, cargo_manifest_id.text )\nCREATE TABLE transportation.locations ( location_id text PRIMARY KEY, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\nCREATE TABLE transportation.maintenance_logs ( log_id character varying(64) NOT NULL, vehicle_id character varying(64) NOT NULL, service_date date NOT NULL, odometer_reading integer, service_type character varying(128) NOT NULL, description text NOT NULL, cost numeric(10, 2), mechanic_name character varying(128), next_service_due_date date, PRIMARY KEY (log_id) )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\nCREATE TABLE transportation.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )\n", "conversations": [{"role": "user", "content": "Can you show the driver first name, last name, and the make and model of the vehicle for each trip, along with the scheduled departure time?"}, {"role": "assistant", "content": "SELECT d.first_name, d.last_name, v.make, v.model, t.scheduled_departure\nFROM transportation.trips t\nJOIN transportation.drivers d ON t.driver_id = d.driver_id\nJOIN transportation.vehicles v ON t.vehicle_id = v.vehicle_id;"}, {"role": "user", "content": "Only include trips that have not started yet, and make sure the vehicle status is 'Active'."}, {"role": "assistant", "content": "SELECT d.first_name, d.last_name, v.make, v.model, t.scheduled_departure\nFROM transportation.trips t\nJOIN transportation.drivers d ON t.driver_id = d.driver_id\nJOIN transportation.vehicles v ON t.vehicle_id = v.vehicle_id\nWHERE t.actual_departure IS NULL\n AND v.status = 'Active';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.achievements ( achievement_id uuid, game_id uuid, name text, description text, icon_url text, points integer, hidden boolean )\n", "conversations": [{"role": "user", "content": "I want to list each hidden achievement alongside the highest-point visible achievement in the same game, showing game_id, hidden_name, and visible_name."}, {"role": "assistant", "content": "WITH max_vis AS (\n SELECT game_id, MAX(points) AS max_points\n FROM gaming_technology.achievements\n WHERE hidden = FALSE\n GROUP BY game_id\n)\nSELECT h.game_id, h.name AS hidden_name, v.name AS visible_name\nFROM gaming_technology.achievements h\nJOIN max_vis m ON h.game_id = m.game_id\nJOIN gaming_technology.achievements v ON v.game_id = m.game_id AND v.hidden = FALSE AND v.points = m.max_points\nWHERE h.hidden = TRUE;"}, {"role": "user", "content": "Filter out games where the highest visible achievement point is not above 40."}, {"role": "assistant", "content": "WITH max_vis AS (\n SELECT game_id, MAX(points) AS max_points\n FROM gaming_technology.achievements\n WHERE hidden = FALSE AND points > 40\n GROUP BY game_id\n)\nSELECT h.game_id, h.name AS hidden_name, v.name AS visible_name\nFROM gaming_technology.achievements h\nJOIN max_vis m ON h.game_id = m.game_id\nJOIN gaming_technology.achievements v ON v.game_id = m.game_id AND v.hidden = FALSE AND v.points = m.max_points\nWHERE h.hidden = TRUE;"}, {"role": "user", "content": "Please order the output by game_id ascending and then by hidden_name ascending."}, {"role": "assistant", "content": "WITH max_vis AS (\n SELECT game_id, MAX(points) AS max_points\n FROM gaming_technology.achievements\n WHERE hidden = FALSE AND points > 40\n GROUP BY game_id\n)\nSELECT h.game_id, h.name AS hidden_name, v.name AS visible_name\nFROM gaming_technology.achievements h\nJOIN max_vis m ON h.game_id = m.game_id\nJOIN gaming_technology.achievements v ON v.game_id = m.game_id AND v.hidden = FALSE AND v.points = m.max_points\nWHERE h.hidden = TRUE\nORDER BY h.game_id ASC, hidden_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\n", "conversations": [{"role": "user", "content": "List the full names of employees whose direct manager themselves report to another manager. Also show the direct manager's full name."}, {"role": "assistant", "content": "SELECT E.first_name, E.last_name, M.first_name AS manager_first_name, M.last_name AS manager_last_name FROM government_services.employees AS E JOIN government_services.employees AS M ON E.manager_employee_id = M.employee_id WHERE M.manager_employee_id IS NOT NULL;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\n", "conversations": [{"role": "user", "content": "Show me the number of guests registered in each city. Order the results by city name."}, {"role": "assistant", "content": "SELECT city, COUNT(guest_id) AS guest_count FROM guests GROUP BY city ORDER BY city;"}]} -{"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE train_station_management.train_cars ( car_id text PRIMARY KEY, train_id text, car_number text, car_type text, class text, capacity int, features text )\n", "conversations": [{"role": "user", "content": "What is the current operational status of the train car with car_id 'CAR123'?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide information on the current operational status of the train car with car_id 'CAR123'. The data in the train_cars table does not include real-time status updates or operational conditions."}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\nCREATE TABLE legal_services.invoices ( invoice_id character varying(64) NOT NULL, invoice_number character varying(100) UNIQUE NOT NULL, client_id character varying(64) NOT NULL, case_id character varying(64), issue_date date NOT NULL, due_date date NOT NULL, total_amount numeric(12, 2) NOT NULL, amount_paid numeric(12, 2) DEFAULT 0.00, status character varying(50) NOT NULL, payment_date timestamp, notes text, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (invoice_id) )\n", "conversations": [{"role": "user", "content": "Calculate the total amount billed for each client, showing their first name, last name, and the total amount."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, SUM(i.total_amount) FROM legal_services.clients c JOIN legal_services.invoices i ON c.client_id = i.client_id GROUP BY c.client_id, c.first_name, c.last_name;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "Show all insurance plans where the plan name includes the word 'Care'."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, insurance_provider, plan_type\nFROM healthcare.insurance_plans\nWHERE plan_name ILIKE '%Care%';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE erc1155_approval_for_all (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction\n transaction_index integer NOT NULL, -- Index of the transaction within the block\n transaction_hash varchar(66) NOT NULL, -- Transaction hash\n log_index integer NOT NULL, -- Log index\n contract_address varchar(42) NOT NULL -- Event contract address\n)\nCREATE TABLE erc20_balances ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk varchar )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata (\n object_id varchar NOT NULL, -- object id of the coin metadata object\n coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN\n status varchar NOT NULL, -- coin status, eg. exists, deleted\n decimals bigint NOT NULL, -- decimals of the coin\n description varchar NOT NULL, -- description of the coin\n icon_url varchar NOT NULL, -- icon url of the coin\n symbol varchar NOT NULL, -- symbol of the coin\n name varchar NOT NULL -- name of the coin\n)\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_bitcoin (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply varchar NOT NULL, -- Max supply: Set max supply of the inscription\n amount varchar NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )\n", "conversations": [{"role": "user", "content": "Which wallets have sent more than 5 BTC in the past 7 days? Show wallet_address and total_sent_amount."}, {"role": "assistant", "content": "SELECT ta.from_address AS wallet_address, SUM(ta.amt) AS total_sent\nFROM token_activities ta\nWHERE ta.tick = 'BTC'\n AND ta.block_timestamp >= now() - INTERVAL '7 days'\nGROUP BY ta.from_address\nHAVING SUM(ta.amt) > 5;"}, {"role": "user", "content": "Also include their most recent BTC balance from token_balances_bitcoin."}, {"role": "assistant", "content": "SELECT t.wallet_address, t.total_sent,\n (SELECT tb2.amount\n FROM token_balances_bitcoin tb2\n WHERE tb2.wallet_address = t.wallet_address\n AND tb2.tick = 'BTC'\n ORDER BY tb2.block_number DESC\n LIMIT 1) AS current_balance\nFROM (\n SELECT ta.from_address AS wallet_address, SUM(ta.amt) AS total_sent\n FROM token_activities ta\n WHERE ta.tick = 'BTC'\n AND ta.block_timestamp >= now() - INTERVAL '7 days'\n GROUP BY ta.from_address\n HAVING SUM(ta.amt) > 5\n) t;"}, {"role": "user", "content": "Limit to top 5 wallets by total_sent in descending order."}, {"role": "assistant", "content": "SELECT t.wallet_address, t.total_sent,\n (SELECT tb2.amount\n FROM token_balances_bitcoin tb2\n WHERE tb2.wallet_address = t.wallet_address\n AND tb2.tick = 'BTC'\n ORDER BY tb2.block_number DESC\n LIMIT 1) AS current_balance\nFROM (\n SELECT ta.from_address AS wallet_address, SUM(ta.amt) AS total_sent\n FROM token_activities ta\n WHERE ta.tick = 'BTC'\n AND ta.block_timestamp >= now() - INTERVAL '7 days'\n GROUP BY ta.from_address\n HAVING SUM(ta.amt) > 5\n) t\nORDER BY t.total_sent DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "I need to find patients who received prescriptions within 7 days after their latest appointment. Show patient_id, first and last name, appointment_time, prescription_date, and medication_name."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Actually, restrict it to prescriptions where dosage contains 'mg'."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Also, sort the results by prescription_date descending and limit to 5."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id\nORDER BY pr.prescription_date DESC\nLIMIT 5"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List the patient ID, first name, last name, and phone number for all patients whose emergency contact name or phone number is missing."}, {"role": "assistant", "content": "SELECT patient_id, first_name, last_name, phone_number FROM healthcare.patients WHERE emergency_contact_name IS NULL OR emergency_contact_name = '' OR emergency_contact_phone IS NULL OR emergency_contact_phone = '';"}, {"role": "user", "content": "Refine this to also include patients who have a listed email address and sort the results by patient_id."}, {"role": "assistant", "content": "SELECT patient_id, first_name, last_name, phone_number FROM healthcare.patients WHERE (emergency_contact_name IS NULL OR emergency_contact_name = '' OR emergency_contact_phone IS NULL OR emergency_contact_phone = '') AND email IS NOT NULL AND email != '' ORDER BY patient_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Get the total number of appointments grouped by status."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS appointment_count\nFROM healthcare.appointments\nGROUP BY status;"}, {"role": "user", "content": "Now filter to include only statuses with more than 50 appointments."}, {"role": "assistant", "content": "SELECT status,\n COUNT(*) AS appointment_count\nFROM healthcare.appointments\nGROUP BY status\nHAVING COUNT(*) > 50;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean )\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.messages ( message_id.text, conversation_id.text, sender_user_id.text, content.text, media_url.text, media_type.text, sent_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Get the five most recent public posts that have media_type = 'video', showing post_id, created_at, and the author's username."}, {"role": "assistant", "content": "SELECT\n p.post_id,\n p.created_at,\n u.username\nFROM social_media.posts p\nJOIN social_media.users u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.media_type = 'video'\nORDER BY p.created_at DESC\nLIMIT 5;"}, {"role": "user", "content": "Actually, filter to only include posts made by verified users."}, {"role": "assistant", "content": "SELECT\n p.post_id,\n p.created_at,\n u.username\nFROM social_media.posts p\nJOIN social_media.users u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.media_type = 'video'\n AND u.is_verified = TRUE\nORDER BY p.created_at DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE blockchain.nodes ( node_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (node_id) )\n", "conversations": [{"role": "user", "content": "Find all pairs of node IDs that share the same IP address but operate on different ports."}, {"role": "assistant", "content": "SELECT a.node_id AS node1, b.node_id AS node2, a.ip_address, a.port AS port1, b.port AS port2 FROM blockchain.nodes a JOIN blockchain.nodes b ON a.ip_address = b.ip_address AND a.node_id < b.node_id AND a.port <> b.port;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc20_balances ( block_number bigint, contract_address text, wallet_address text, amount text, pk text )\nCREATE TABLE erc20_balances_historical (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract\n amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height\n pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))\n)\nCREATE TABLE nft_holder_historical (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract(with bloom filter)\n token_id varchar NOT NULL, -- NFT token id\n contract_type varchar NOT NULL, -- NFT contract type\n amount varchar NOT NULL, -- The quantity held in the wallet\n pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))\n)\nCREATE TABLE sui_coins ( object_id varchar, status varchar, coin_type varchar, balance varchar, owner varchar )\nCREATE TABLE sui_nfts ( object_id varchar NOT NULL, status varchar NOT NULL, collection_type varchar NOT NULL, package_id varchar NOT NULL, previous_transaction varchar NOT NULL, display varchar NOT NULL, owner varchar NOT NULL, name varchar NOT NULL )\nCREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_balances (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction\n tick varchar NOT NULL, -- Token tick\n wallet_address varchar(42) NOT NULL, -- Address of owner\n total_supply decimal(38,0) NOT NULL, -- Max supply\n amount decimal(38,0) NOT NULL -- The balance of wallet balance at the corresponding block height\n)\nCREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(255) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply varchar NOT NULL, amount varchar NOT NULL )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )\n", "conversations": [{"role": "user", "content": "List the top 5 Avalanche tokens by total transfer volume in token_activities_avalanche."}, {"role": "assistant", "content": "SELECT tick, SUM(amt) AS total_volume\nFROM token_activities_avalanche\nGROUP BY tick\nORDER BY total_volume DESC\nLIMIT 5;"}, {"role": "user", "content": "Also include the count of distinct senders and receivers for each token."}, {"role": "assistant", "content": "SELECT tick,\n SUM(amt) AS total_volume,\n COUNT(DISTINCT from_address) AS sender_count,\n COUNT(DISTINCT to_address) AS receiver_count\nFROM token_activities_avalanche\nGROUP BY tick\nORDER BY total_volume DESC\nLIMIT 5;"}, {"role": "user", "content": "Join with token_balances_avalanche to include the total_supply for each token and filter for transfers over 100 units in the last 7 days."}, {"role": "assistant", "content": "SELECT a.tick,\n SUM(a.amt) AS total_volume,\n COUNT(DISTINCT a.from_address) AS sender_count,\n COUNT(DISTINCT a.to_address) AS receiver_count,\n b.total_supply\nFROM token_activities_avalanche a\nJOIN token_balances_avalanche b\n ON a.tick = b.tick\n AND b.block_number = (\n SELECT MAX(block_number)\n FROM token_balances_avalanche\n WHERE tick = a.tick\n )\nWHERE a.amt > 100\n AND a.block_timestamp >= NOW() - INTERVAL '7 days'\nGROUP BY a.tick, b.total_supply\nORDER BY total_volume DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )\n", "conversations": [{"role": "user", "content": "Show me all staff members along with their positions and the names of the properties they work at."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name, s.position, p.property_name\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id;"}, {"role": "user", "content": "Only include staff who are not currently active."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name, s.position, p.property_name\nFROM hospitality_technology.staff s\nJOIN hospitality_technology.properties p ON s.property_id = p.property_id\nWHERE s.is_active = FALSE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.insurance_plans ( plan_id text PRIMARY KEY, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "Give me the website for the insurance plan named 'Family Advantage'."}, {"role": "assistant", "content": "SELECT website FROM healthcare.insurance_plans WHERE plan_name = 'Family Advantage';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "List patient_id, full name, policy_number, plan_type, and insurance_provider for all active primary insurance policies."}, {"role": "assistant", "content": "SELECT pi.patient_id,\n p.first_name,\n p.last_name,\n pi.policy_number,\n ip.plan_type,\n ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p\n ON p.patient_id = pi.patient_id\nJOIN healthcare.insurance_plans ip\n ON ip.plan_id = pi.plan_id\nWHERE pi.is_primary = TRUE\n AND pi.effective_date <= CURRENT_DATE\n AND pi.expiration_date >= CURRENT_DATE;"}, {"role": "user", "content": "Now also restrict to policies expiring within the next 30 days."}, {"role": "assistant", "content": "SELECT pi.patient_id,\n p.first_name,\n p.last_name,\n pi.policy_number,\n ip.plan_type,\n ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p\n ON p.patient_id = pi.patient_id\nJOIN healthcare.insurance_plans ip\n ON ip.plan_id = pi.plan_id\nWHERE pi.is_primary = TRUE\n AND pi.effective_date <= CURRENT_DATE\n AND pi.expiration_date BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL '30 days';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )\nCREATE TABLE trading_platform.notifications ( notification_id.text, user_id.text, message.text, sent_at.timestamp, read_at.timestamp )\n", "conversations": [{"role": "user", "content": "How many distinct IP addresses have ever connected as peers on the platform?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT ip_address) AS distinct_ip_count\nFROM trading_platform.peers;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )\nCREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )\nCREATE TABLE cex_token_balance ( snapshot_time.text, chain.text, address.text, exchange.text, token_address.text, token_symbol.text, balance.numeric, usd_value.numeric, price.numeric )\nCREATE TABLE smart_money_token_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, chain.text )\n", "conversations": [{"role": "user", "content": "Show me tokens with a 24-hour trading volume over $1,000,000 from DEX pools that also have a positive net flow from smart money addresses. Display the token symbol, chain, 24h volume, and net flow."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0;"}, {"role": "user", "content": "Okay, now refine the results to only include tokens where the smart money ROI is greater than 5 (500%) and the realized ratio is above 0.5."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0 AND smtp.roi > 5 AND smtp.realized_ratio > 0.5;"}, {"role": "user", "content": "Add the token's current price from the basic info table and its narrative category to the results."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow, tbi.price AS current_price, tbi.narrative FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain JOIN token_basic_info AS tbi ON tdi.token_symbol = tbi.token_symbol AND tdi.chain = tbi.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0 AND smtp.roi > 5 AND smtp.realized_ratio > 0.5;"}, {"role": "user", "content": "Order the final list by 24-hour trading volume descending and show the top 10."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.volume_24h, smtp.net_flow, tbi.price AS current_price, tbi.narrative FROM token_dexpool_info AS tdi JOIN smart_money_token_performance AS smtp ON tdi.token_symbol = smtp.token_symbol AND tdi.chain = smtp.chain JOIN token_basic_info AS tbi ON tdi.token_symbol = tbi.token_symbol AND tdi.chain = tbi.chain WHERE tdi.volume_24h > 1000000 AND smtp.net_flow > 0 AND smtp.roi > 5 AND smtp.realized_ratio > 0.5 ORDER BY tdi.volume_24h DESC LIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\n", "conversations": [{"role": "user", "content": "What are the top 5 most recently registered verified citizens? Return the citizen ID, full name, and registration date."}, {"role": "assistant", "content": "SELECT citizen_id,\n first_name || ' ' || last_name AS full_name,\n registration_date\nFROM government_services.citizens\nWHERE is_verified = TRUE\nORDER BY registration_date DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )\n", "conversations": [{"role": "user", "content": "List each payment's currency_code, total amount paid, and the number of service orders placed by the same guest for the same reservation."}, {"role": "assistant", "content": "SELECT p.payment_id,\n p.currency_code,\n p.amount AS payment_amount,\n COUNT(so.order_id) AS order_count\nFROM hospitality_technology.payments p\nLEFT JOIN hospitality_technology.service_orders so\n ON p.reservation_id = so.reservation_id\n AND p.guest_id = so.guest_id\nGROUP BY p.payment_id, p.currency_code, p.amount;"}, {"role": "user", "content": "Actually, I want the earliest service order date for each reservation and include it in the results."}, {"role": "assistant", "content": "SELECT p.payment_id,\n p.currency_code,\n p.amount AS payment_amount,\n COUNT(so.order_id) AS order_count,\n MIN(so.order_timestamp) AS first_order_timestamp\nFROM hospitality_technology.payments p\nLEFT JOIN hospitality_technology.service_orders so\n ON p.reservation_id = so.reservation_id\n AND p.guest_id = so.guest_id\nGROUP BY p.payment_id, p.currency_code, p.amount;"}, {"role": "user", "content": "Also, only include payments with status = 'Succeeded' and service orders with status = 'Delivered'."}, {"role": "assistant", "content": "SELECT p.payment_id,\n p.currency_code,\n p.amount AS payment_amount,\n COUNT(so.order_id) AS order_count,\n MIN(so.order_timestamp) AS first_order_timestamp\nFROM hospitality_technology.payments p\nLEFT JOIN hospitality_technology.service_orders so\n ON p.reservation_id = so.reservation_id\n AND p.guest_id = so.guest_id\n AND so.status = 'Delivered'\nWHERE p.status = 'Succeeded'\nGROUP BY p.payment_id, p.currency_code, p.amount;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles (\n vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle\n license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate\n vin character varying(17) UNIQUE, -- vehicle identification number\n make character varying(64) NOT NULL, -- manufacturer of the vehicle\n model character varying(64) NOT NULL, -- model of the vehicle\n year integer NOT NULL, -- manufacturing year\n type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)\n capacity integer, -- passenger or cargo capacity\n fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen\n status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned\n depot_id character varying(64), -- identifier of the home depot/base\n acquisition_date date, -- date the vehicle was acquired\n PRIMARY KEY (vehicle_id)\n)\nCREATE TABLE transportation.drivers ( driver_id.text, employee_id.text, first_name.text, last_name.text, license_number.text, license_expiry_date.date, contact_number.text, email.text, hire_date.date, status.text )\nCREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text )\nCREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\nCREATE TABLE transportation.fuel_logs (\n fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled\n trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred\n log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred\n fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type)\n quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh)\n unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh)\n cost_per_unit numeric(8, 4), -- price per unit of fuel\n total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase\n odometer_reading integer, -- vehicle mileage at time of fueling\n location_id character varying(64), -- identifier of the fueling station/location\n PRIMARY KEY (fuel_log_id)\n)\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\nCREATE TABLE transportation.bookings ( booking_id character varying(64) NOT NULL, passenger_id character varying(64) NOT NULL, trip_id character varying(64) NOT NULL, seat_number character varying(16), booking_time timestamp with time zone NOT NULL, status character varying(32) NOT NULL, fare numeric(10, 2) NOT NULL, payment_transaction_id character varying(128), special_requests text, PRIMARY KEY (booking_id) )\n", "conversations": [{"role": "user", "content": "Retrieve each completed booking's booking_id, passenger full name, trip_id, scheduled_departure, and fare for bookings where the trip's passenger_count is at least 10."}, {"role": "assistant", "content": "SELECT b.booking_id, p.first_name || ' ' || p.last_name AS passenger_name, b.trip_id, t.scheduled_departure, b.fare\nFROM transportation.bookings b\nJOIN transportation.passengers p ON b.passenger_id = p.passenger_id\nJOIN transportation.trips t ON b.trip_id = t.trip_id\nWHERE b.status = 'Completed'\n AND t.passenger_count >= 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (property_id)\n)\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types ( room_type_id text PRIMARY KEY, property_id text, type_name text, description text, base_rate numeric, max_occupancy int, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "Show me each room type with its property name and the number of rooms of that type which are currently 'Occupied'."}, {"role": "assistant", "content": "SELECT rt.type_name, p.property_name, COUNT(r.room_id) AS occupied_room_count\nFROM hospitality_technology.room_types rt\nJOIN hospitality_technology.properties p ON rt.property_id = p.property_id\nJOIN hospitality_technology.rooms r ON r.room_type_id = rt.room_type_id\nWHERE r.status = 'Occupied'\nGROUP BY rt.type_name, p.property_name;"}, {"role": "user", "content": "Only return room types where at least 2 rooms are 'Occupied'."}, {"role": "assistant", "content": "SELECT rt.type_name, p.property_name, COUNT(r.room_id) AS occupied_room_count\nFROM hospitality_technology.room_types rt\nJOIN hospitality_technology.properties p ON rt.property_id = p.property_id\nJOIN hospitality_technology.rooms r ON r.room_type_id = rt.room_type_id\nWHERE r.status = 'Occupied'\nGROUP BY rt.type_name, p.property_name\nHAVING COUNT(r.room_id) >= 2;"}, {"role": "user", "content": "Also, sort the results by occupied_room_count in descending order and only include room types at properties in the USA."}, {"role": "assistant", "content": "SELECT rt.type_name, p.property_name, COUNT(r.room_id) AS occupied_room_count\nFROM hospitality_technology.room_types rt\nJOIN hospitality_technology.properties p ON rt.property_id = p.property_id\nJOIN hospitality_technology.rooms r ON r.room_type_id = rt.room_type_id\nWHERE r.status = 'Occupied' AND p.country_code = 'USA'\nGROUP BY rt.type_name, p.property_name\nHAVING COUNT(r.room_id) >= 2\nORDER BY occupied_room_count DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.achievements (\n achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition\n game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to\n name character varying(150) NOT NULL, -- name of the achievement\n description text NOT NULL, -- how to unlock the achievement\n icon_url character varying(255), -- URL for the achievement's icon\n points integer DEFAULT 0, -- points awarded for unlocking (optional)\n hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked\n PRIMARY KEY (achievement_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\n", "conversations": [{"role": "user", "content": "Can you list the names of achievements and the length of their descriptions? Show the ones with the longest descriptions first."}, {"role": "assistant", "content": "SELECT name, LENGTH(description) AS description_length FROM achievements ORDER BY description_length DESC LIMIT 10;"}, {"role": "user", "content": "For these achievements, can you also show the title of the game they belong to?"}, {"role": "assistant", "content": "SELECT a.name, LENGTH(a.description) AS description_length, g.name AS game_title FROM achievements AS a JOIN games AS g ON a.game_id = g.game_id ORDER BY description_length DESC LIMIT 10;"}, {"role": "user", "content": "Also, please only include achievements that are not hidden."}, {"role": "assistant", "content": "SELECT a.name, LENGTH(a.description) AS description_length, g.name AS game_title FROM achievements AS a JOIN games AS g ON a.game_id = g.game_id WHERE a.hidden = FALSE ORDER BY description_length DESC LIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, submitted_at timestamp NOT NULL, status character varying(50) NOT NULL, last_updated_at timestamp NOT NULL, assigned_employee_id character varying(64), decision_date date, notes text, reference_number character varying(100) UNIQUE, PRIMARY KEY (application_id) )\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "Provide a count of documents grouped by their current verification status."}, {"role": "assistant", "content": "SELECT verification_status, COUNT(*) FROM government_services.documents GROUP BY verification_status"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.documents ( document_id text, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\n", "conversations": [{"role": "user", "content": "List all document IDs and document types for documents that have been verified by an employee, along with the verification timestamp and the ID of the verifying employee."}, {"role": "assistant", "content": "SELECT document_id, document_type, verification_timestamp, verified_by_employee_id FROM government_services.documents WHERE verified_by_employee_id IS NOT NULL;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\nCREATE TABLE trading_platform.wallets ( wallet_id text PRIMARY KEY, user_id text, address text, private_key text, created_at timestamp )\nCREATE TABLE trading_platform.orders ( order_id text PRIMARY KEY, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades (\n trade_id character varying(64) NOT NULL, -- unique identifier for the trade\n order_id character varying(64) NOT NULL, -- identifier of the order that led to the trade\n buyer_id character varying(64) NOT NULL, -- identifier of the buyer\n seller_id character varying(64) NOT NULL, -- identifier of the seller\n asset_id character varying(64) NOT NULL, -- identifier of the asset being traded\n quantity numeric(38,14) NOT NULL, -- quantity of the asset in the trade\n price numeric(38,14) NOT NULL, -- price per unit of the asset\n traded_at timestamp NOT NULL, -- time when the trade was executed\n PRIMARY KEY (trade_id)\n)\nCREATE TABLE trading_platform.assets ( asset_id 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) )\nCREATE TABLE trading_platform.dapps ( dapp_id character varying(64) NOT NULL, name character varying(128) NOT NULL, description text NOT NULL, url character varying(256) NOT NULL, PRIMARY KEY (dapp_id) )\nCREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id text PRIMARY KEY, asset_id text, key text, value text )\nCREATE TABLE trading_platform.kyc_audit (\n kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit\n user_id character varying(64) NOT NULL, -- identifier of the user being audited\n status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)\n reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed\n PRIMARY KEY (kyc_audit_id)\n)\nCREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )\n", "conversations": [{"role": "user", "content": "For each asset, list its ID and the total number of trades and the total traded value (quantity * price)."}, {"role": "assistant", "content": "SELECT a.asset_id,\n COALESCE(t.trade_count, 0) AS trade_count,\n COALESCE(t.total_value, 0) AS total_value\nFROM trading_platform.assets a\nLEFT JOIN (\n SELECT asset_id,\n COUNT(*) AS trade_count,\n SUM(quantity * price) AS total_value\n FROM trading_platform.trades\n GROUP BY asset_id\n) t ON a.asset_id = t.asset_id;"}, {"role": "user", "content": "Exclude assets that have zero trades."}, {"role": "assistant", "content": "SELECT a.asset_id,\n COALESCE(t.trade_count, 0) AS trade_count,\n COALESCE(t.total_value, 0) AS total_value\nFROM trading_platform.assets a\nLEFT JOIN (\n SELECT asset_id,\n COUNT(*) AS trade_count,\n SUM(quantity * price) AS total_value\n FROM trading_platform.trades\n GROUP BY asset_id\n) t ON a.asset_id = t.asset_id\nWHERE COALESCE(t.trade_count, 0) > 0;"}, {"role": "user", "content": "Include the asset name and symbol in the results as well."}, {"role": "assistant", "content": "SELECT a.asset_id,\n a.name,\n a.symbol,\n t.trade_count,\n t.total_value\nFROM trading_platform.assets a\nJOIN (\n SELECT asset_id,\n COUNT(*) AS trade_count,\n SUM(quantity * price) AS total_value\n FROM trading_platform.trades\n GROUP BY asset_id\n) t ON a.asset_id = t.asset_id;"}, {"role": "user", "content": "Limit the output to the top 3 assets by total_value in descending order."}, {"role": "assistant", "content": "SELECT a.asset_id,\n a.name,\n a.symbol,\n t.trade_count,\n t.total_value\nFROM trading_platform.assets a\nJOIN (\n SELECT asset_id,\n COUNT(*) AS trade_count,\n SUM(quantity * price) AS total_value\n FROM trading_platform.trades\n GROUP BY asset_id\n) t ON a.asset_id = t.asset_id\nORDER BY t.total_value DESC\nLIMIT 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.law_firms ( firm_id character varying(64) NOT NULL, firm_name character varying(200) NOT NULL, address text NOT NULL, phone character varying(32), website character varying(255), founded_date date, managing_partner_id character varying(64), PRIMARY KEY (firm_id) )\n", "conversations": [{"role": "user", "content": "List pairs of law firms that are located at the same address. Display the names of both firms and the shared address, ensuring the address is not null."}, {"role": "assistant", "content": "SELECT\n t1.firm_name AS firm1_name,\n t2.firm_name AS firm2_name,\n t1.address\nFROM legal_services.law_firms AS t1\nINNER JOIN legal_services.law_firms AS t2\n ON t1.address = t2.address\nWHERE\n t1.firm_id < t2.firm_id AND t1.address IS NOT NULL;"}, {"role": "user", "content": "Only show pairs where both firms were founded before 2020."}, {"role": "assistant", "content": "SELECT\n t1.firm_name AS firm1_name,\n t2.firm_name AS firm2_name,\n t1.address\nFROM legal_services.law_firms AS t1\nINNER JOIN legal_services.law_firms AS t2\n ON t1.address = t2.address\nWHERE\n t1.firm_id < t2.firm_id AND t1.address IS NOT NULL AND EXTRACT(YEAR FROM t1.founded_date) < 2020 AND EXTRACT(YEAR FROM t2.founded_date) < 2020;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.documents ( document_id text PRIMARY KEY, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version int, description text )\n", "conversations": [{"role": "user", "content": "Show all documents where the document description includes the word 'summary'. Please display their document name and type."}, {"role": "assistant", "content": "SELECT document_name, document_type FROM legal_services.documents WHERE description ILIKE '%summary%';"}, {"role": "user", "content": "Add the version number to the result, and only include documents uploaded after January 1st, 2024."}, {"role": "assistant", "content": "SELECT document_name, document_type, version FROM legal_services.documents WHERE description ILIKE '%summary%' AND upload_timestamp > '2024-01-01';"}, {"role": "user", "content": "Instead, can you show only documents where version is exactly 2?"}, {"role": "assistant", "content": "SELECT document_name, document_type, version FROM legal_services.documents WHERE description ILIKE '%summary%' AND upload_timestamp > '2024-01-01' AND version = 2;"}, {"role": "user", "content": "Please add the case_id to the output and order by document_name alphabetically."}, {"role": "assistant", "content": "SELECT document_name, document_type, version, case_id FROM legal_services.documents WHERE description ILIKE '%summary%' AND upload_timestamp > '2024-01-01' AND version = 2 ORDER BY document_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text )\nCREATE TABLE erc20_balances_historical (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract\n amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height\n pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))\n)\nCREATE TABLE nft_holders (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract(with bloom filter)\n token_id varchar NOT NULL, -- NFT token id\n contract_type varchar NOT NULL, -- NFT contract type\n amount varchar NOT NULL, -- Number of held NFTs\n pk varchar NOT NULL -- The last string partition of the contract.\n)\nCREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )\nCREATE TABLE sui_coins ( object_id text, status text, coin_type text, balance text, owner text )\nCREATE TABLE sui_coins_metadata ( object_id varchar, coin_type varchar, status varchar, decimals bigint, description varchar, icon_url varchar, symbol varchar, name varchar )\nCREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar )\nCREATE TABLE nft_collections (\n blockchain varchar NOT NULL, -- blockchain fields for the functionType in contract\n contract_address varchar NOT NULL, -- Contract address(with bloom filter)\n name varchar NOT NULL, -- name fields for the functionType in contract\n symbol varchar NOT NULL, -- symbol fields for the functionType in contract\n deploy_block_number bigint NOT NULL, -- deploy_block_number fields for the functionType in contract\n deploy_block_time bigint NOT NULL, -- deploy_block_time fields for the functionType in contract\n erc_type varchar NOT NULL, -- The type of token\n owner varchar NOT NULL, -- owner fields for the functionType in contract\n traits varchar NOT NULL, -- traits fields for the functionType in contract\n description varchar NOT NULL, -- description fields for the functionType in contract\n slug varchar NOT NULL, -- slug fields for the functionType in contract\n media_info varchar NOT NULL, -- media_info fields for the functionType in contract\n image_url varchar NOT NULL, -- image_url fields for the functionType in contract\n banner_image_url varchar NOT NULL, -- banner_image_url fields for the functionType in contract\n updated_at bigint NOT NULL, -- updated_at fields for the functionType in contract\n banner varchar NOT NULL, -- banner fields for the functionType in contract\n token_count bigint NOT NULL, -- token_count fields for the functionType in contract\n floor_price varchar NOT NULL, -- floor_price fields for the functionType in contract\n floor_price_symbol varchar NOT NULL, -- floor_price_symbol fields for the functionType in contract\n floor_price_contract varchar NOT NULL, -- floor_price_contract fields for the functionType in contract\n pk integer NOT NULL -- Partition key for the table(floor(deploy_block_time / 1000 / 86400 / 30))\n)\nCREATE TABLE token_prices ( uuid varchar, blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest (\n blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract\n address varchar(42) NOT NULL, -- address fields for the functionType in contract\n decimals bigint NOT NULL, -- decimals fields for the functionType in contract\n symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract\n price real NOT NULL, -- price fields for the functionType in contract\n timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract\n)\nCREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar NOT NULL, -- Token tick\n max_supply decimal(38,0) NOT NULL, -- Max supply\n lim decimal(38,0) NOT NULL, -- Limit of each mint\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table)\n)\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE mud_holesky_redstone ( address.text, table_id.text, key_bytes.text, key0.text, key1.text, static_data.text, encoded_lengths.text, dynamic_data.text, is_deleted.boolean, block_number.bigint, log_index.bigint )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )\n", "conversations": [{"role": "user", "content": "List all SUI coins that have the status 'inactive', including their owner address and coin_type."}, {"role": "assistant", "content": "SELECT coin_type, owner FROM sui_coins WHERE status = 'inactive';"}, {"role": "user", "content": "Add the name and symbol for each coin by joining with sui_coins_metadata."}, {"role": "assistant", "content": "SELECT sc.coin_type, sc.owner, scm.name, scm.symbol FROM sui_coins sc JOIN sui_coins_metadata scm ON sc.coin_type = scm.coin_type WHERE sc.status = 'inactive';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses (\n diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry\n record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)\n diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)\n code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used\n description text, -- textual description of the diagnosis\n diagnosis_date date NOT NULL, -- date the diagnosis was made\n status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out\n is_chronic boolean DEFAULT false, -- flag for chronic conditions\n PRIMARY KEY (diagnosis_id)\n)\n", "conversations": [{"role": "user", "content": "Which diagnosis codes have been used for more than 5 different patients? Show the diagnosis_code and the patient count."}, {"role": "assistant", "content": "SELECT diagnosis_code, COUNT(DISTINCT patient_id) AS patient_count FROM healthcare.diagnoses GROUP BY diagnosis_code HAVING COUNT(DISTINCT patient_id) > 5;"}, {"role": "user", "content": "Please also show the code_type for each diagnosis_code in the results."}, {"role": "assistant", "content": "SELECT diagnosis_code, code_type, COUNT(DISTINCT patient_id) AS patient_count FROM healthcare.diagnoses GROUP BY diagnosis_code, code_type HAVING COUNT(DISTINCT patient_id) > 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.reservations ( reservation_id.text, property_id.text, guest_id.text, room_id.text, room_type_id.text, check_in_date.date, check_out_date.date, actual_check_in_ts.timestamp, actual_check_out_ts.timestamp, num_adults.integer, num_children.integer, status.text, booking_source.text, rate_plan_id.text, total_amount.numeric, amount_paid.numeric, special_requests.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.services (\n service_id character varying(64) NOT NULL, -- unique identifier for a chargeable service\n property_id character varying(64) NOT NULL, -- FK to properties table\n service_name character varying(150) NOT NULL, -- e.g., Room Service - Burger, Spa - Massage 60min, Laundry - Shirt\n description text,\n category character varying(100), -- e.g., Food & Beverage, Wellness, Business Center, Activities\n price numeric(10, 2) NOT NULL, -- price per unit/instance\n unit character varying(30), -- e.g., Per Item, Per Hour, Per Day\n is_available boolean NOT NULL DEFAULT true, -- is the service currently offered?\n department character varying(100), -- department responsible (e.g., F&B, Spa, Housekeeping)\n PRIMARY KEY (service_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "Show me all service orders along with their status and the associated review comment for the same reservation, if there is one."}, {"role": "assistant", "content": "SELECT so.order_id, so.status, r.comment \nFROM hospitality_technology.service_orders so\nLEFT JOIN hospitality_technology.reviews r ON so.reservation_id = r.reservation_id;"}, {"role": "user", "content": "Filter to only include service orders where guests left a comment."}, {"role": "assistant", "content": "SELECT so.order_id, so.status, r.comment \nFROM hospitality_technology.service_orders so\nJOIN hospitality_technology.reviews r ON so.reservation_id = r.reservation_id\nWHERE r.comment IS NOT NULL AND r.comment <> '';"}, {"role": "user", "content": "Also, only show those service orders for services in the 'Activities' category."}, {"role": "assistant", "content": "SELECT so.order_id, so.status, r.comment \nFROM hospitality_technology.service_orders so\nJOIN hospitality_technology.reviews r ON so.reservation_id = r.reservation_id\nJOIN hospitality_technology.services s ON so.service_id = s.service_id\nWHERE r.comment IS NOT NULL AND r.comment <> ''\n AND s.category = 'Activities';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.locations ( location_id text, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text )\nCREATE TABLE transportation.passengers ( passenger_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Please show me the first name, last name, and date of birth for all passengers born between 1990 and 1999, inclusive."}, {"role": "assistant", "content": "SELECT first_name, last_name, date_of_birth FROM transportation.passengers WHERE date_of_birth BETWEEN '1990-01-01' AND '1999-12-31';"}, {"role": "user", "content": "Filter this list further to only include passengers whose records were created in the year 2023 and order the results by date of birth in ascending order."}, {"role": "assistant", "content": "SELECT first_name, last_name, date_of_birth FROM transportation.passengers WHERE date_of_birth BETWEEN '1990-01-01' AND '1999-12-31' AND EXTRACT(YEAR FROM created_at) = 2023 ORDER BY date_of_birth ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n \"CREATE TABLE cex_token_balance (\",\n \"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp\",\n \"chain character varying(128) NOT NULL, -- the chain that the token resides\",\n \"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX\",\n \"exchange character varying(512) NOT NULL, -- a centralized exchange name\",\n \"token_address character varying(128) NOT NULL, -- token contract address\",\n \"token_symbol character varying(512), --token symbol\",\n \"balance numeric(38,10), -- token balance\",\n \"usd_value numeric(38,14), -- value of the token held in USD\",\n \"price double precision, --price of the token in USD\",\n \",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));\"\n\n", "conversations": [{"role": "user", "content": "Which token symbol has the highest price among all tokens held by CEXes on the Polygon chain?"}, {"role": "assistant", "content": "SELECT token_symbol, MAX(price) AS max_price FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol ORDER BY max_price DESC LIMIT 1;"}, {"role": "user", "content": "Can you also show which exchange holds the largest balance of that token?"}, {"role": "assistant", "content": "SELECT exchange, address, balance, usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND token_symbol = (SELECT token_symbol FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol ORDER BY MAX(price) DESC LIMIT 1) ORDER BY usd_value DESC LIMIT 1;"}, {"role": "user", "content": "Please include the snapshot_time of the record as well."}, {"role": "assistant", "content": "SELECT snapshot_time, exchange, address, balance, usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND token_symbol = (SELECT token_symbol FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol ORDER BY MAX(price) DESC LIMIT 1) ORDER BY usd_value DESC LIMIT 1;"}, {"role": "user", "content": "Instead of only the largest balance, can you list the top 3 addresses by usd_value for that token?"}, {"role": "assistant", "content": "SELECT snapshot_time, exchange, address, balance, usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND token_symbol = (SELECT token_symbol FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol ORDER BY MAX(price) DESC LIMIT 1) ORDER BY usd_value DESC LIMIT 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "I need a list of patients along with their chronic diagnosis codes and diagnosis dates."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, d.diagnosis_code, d.diagnosis_date FROM healthcare.patients p JOIN healthcare.diagnoses d ON p.patient_id = d.patient_id WHERE d.is_chronic = true;"}, {"role": "user", "content": "Please only include diagnoses where status is 'Active' and order results by diagnosis_date ascending."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, d.diagnosis_code, d.diagnosis_date FROM healthcare.patients p JOIN healthcare.diagnoses d ON p.patient_id = d.patient_id WHERE d.is_chronic = true AND d.status = 'Active' ORDER BY d.diagnosis_date ASC;"}, {"role": "user", "content": "Also, calculate the patient's age at the time of each diagnosis as age_in_years."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, d.diagnosis_code, d.diagnosis_date, EXTRACT(YEAR FROM AGE(d.diagnosis_date, p.date_of_birth)) AS age_in_years FROM healthcare.patients p JOIN healthcare.diagnoses d ON p.patient_id = d.patient_id WHERE d.is_chronic = true AND d.status = 'Active' ORDER BY d.diagnosis_date ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )\n", "conversations": [{"role": "user", "content": "Show me all medications, their manufacturer, and NDC code for medications manufactured by 'Johnson & Johnson' or 'Roche'."}, {"role": "assistant", "content": "SELECT medication_name, manufacturer, ndc_code FROM healthcare.medications WHERE manufacturer IN ('Johnson & Johnson', 'Roche');"}, {"role": "user", "content": "Actually, only include medications where the NDC code ends with '99'."}, {"role": "assistant", "content": "SELECT medication_name, manufacturer, ndc_code FROM healthcare.medications WHERE manufacturer IN ('Johnson & Johnson', 'Roche') AND ndc_code LIKE '%99';"}, {"role": "user", "content": "Also return the description and sort the result by medication_name ascending."}, {"role": "assistant", "content": "SELECT medication_name, manufacturer, ndc_code, description FROM healthcare.medications WHERE manufacturer IN ('Johnson & Johnson', 'Roche') AND ndc_code LIKE '%99' ORDER BY medication_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.transactions (\n transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction\n account_id character varying(64) NOT NULL, -- account involved in the transaction\n related_account_id character varying(64), -- counterpart account for transfers\n transaction_type character varying(50) NOT NULL, -- e.g., Deposit, Withdrawal, Transfer, Payment, Fee, Interest\n amount numeric(19, 4) NOT NULL, -- transaction amount\n currency character varying(3) NOT NULL, -- transaction currency\n transaction_date timestamp NOT NULL, -- exact time of the transaction\n effective_date date NOT NULL, -- date the transaction affects the balance\n description text, -- description or memo of the transaction\n status character varying(32) NOT NULL, -- e.g., Pending, Completed, Failed, Reversed\n reference_number character varying(128), -- external reference if applicable (e.g., check number)\n PRIMARY KEY (transaction_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id),\n FOREIGN KEY (related_account_id) REFERENCES financial_services.accounts(account_id)\n)\n", "conversations": [{"role": "user", "content": "For each transaction, show the transaction_id, amount, and the number of other transactions that have the same related_account_id and happened on the same effective_date."}, {"role": "assistant", "content": "SELECT t1.transaction_id, t1.amount, (SELECT COUNT(*) FROM financial_services.transactions t2 WHERE t2.related_account_id = t1.related_account_id AND t2.effective_date = t1.effective_date AND t2.transaction_id <> t1.transaction_id) AS matching_transactions FROM financial_services.transactions t1;"}, {"role": "user", "content": "Now, only show transactions where there is at least one matching transaction found."}, {"role": "assistant", "content": "SELECT t1.transaction_id, t1.amount, (SELECT COUNT(*) FROM financial_services.transactions t2 WHERE t2.related_account_id = t1.related_account_id AND t2.effective_date = t1.effective_date AND t2.transaction_id <> t1.transaction_id) AS matching_transactions FROM financial_services.transactions t1 WHERE (SELECT COUNT(*) FROM financial_services.transactions t2 WHERE t2.related_account_id = t1.related_account_id AND t2.effective_date = t1.effective_date AND t2.transaction_id <> t1.transaction_id) > 0;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.hashtags ( hashtag_id text, tag_name text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me all hashtag IDs and their tag names that were created after June 10, 2024 and whose tag names contain the word 'dev'."}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name FROM social_media.hashtags WHERE created_at > '2024-06-10' AND tag_name ILIKE '%dev%';"}, {"role": "user", "content": "Can you also include the creation timestamp and order the results by created_at ascending?"}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name, created_at FROM social_media.hashtags WHERE created_at > '2024-06-10' AND tag_name ILIKE '%dev%' ORDER BY created_at ASC;"}, {"role": "user", "content": "Actually, only show hashtags where the tag name starts with the letter 'D'."}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name, created_at FROM social_media.hashtags WHERE created_at > '2024-06-10' AND tag_name ILIKE 'D%' ORDER BY created_at ASC;"}, {"role": "user", "content": "Limit the results to the top 8 hashtags."}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name, created_at FROM social_media.hashtags WHERE created_at > '2024-06-10' AND tag_name ILIKE 'D%' ORDER BY created_at ASC LIMIT 8;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.services (\n service_id character varying(64) NOT NULL, -- unique identifier for the service\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n service_name character varying(255) NOT NULL, -- name of the service (e.g., Driver's License Renewal)\n description text,\n category character varying(100), -- e.g., Licensing, Benefits, Taxation, Permits\n eligibility_criteria text, -- description of who is eligible\n standard_fee numeric(10, 2) DEFAULT 0.00, -- typical fee for the service\n average_processing_time_days integer, -- estimated processing time\n is_active boolean DEFAULT true, -- whether the service is currently offered\n online_application_url character varying(255),\n PRIMARY KEY (service_id)\n)\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\nCREATE TABLE government_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n employee_id character varying(64), -- FK to employees table (optional, if assigned)\n location_id character varying(64), -- FK to service_locations table (if physical)\n service_id character varying(64), -- FK to services table (optional, if related to specific service)\n scheduled_start_time timestamp NOT NULL,\n scheduled_end_time timestamp,\n purpose text NOT NULL, -- reason for the appointment\n status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show\n booking_method character varying(50), -- e.g., Online, Phone, In-Person\n created_at timestamp NOT NULL, -- when the appointment was booked\n notes text,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Find the names of services and the locations where appointments have been scheduled for them."}, {"role": "assistant", "content": "SELECT T1.service_name, T2.location_name FROM services AS T1 JOIN appointments AS T3 ON T1.service_id = T3.service_id JOIN service_locations AS T2 ON T3.location_id = T2.location_id GROUP BY T1.service_name, T2.location_name;"}, {"role": "user", "content": "Only include appointments where the location is in the state of 'California'."}, {"role": "assistant", "content": "SELECT T1.service_name, T2.location_name FROM services AS T1 JOIN appointments AS T3 ON T1.service_id = T3.service_id JOIN service_locations AS T2 ON T3.location_id = T2.location_id WHERE T2.state = 'California' GROUP BY T1.service_name, T2.location_name;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table\n appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment\n duration_minutes integer NOT NULL, -- expected duration in minutes\n reason text, -- reason for the visit\n status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show\n location_id character varying(64), -- FK to a potential locations/clinics table\n notes text, -- notes related to scheduling\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "List the appointment_id, patient_id, and reason for all appointments where the notes mention 'urgent'."}, {"role": "assistant", "content": "SELECT appointment_id, patient_id, reason\nFROM healthcare.appointments\nWHERE notes ILIKE '%urgent%';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.invoices (\n invoice_id character varying(64) NOT NULL, -- unique identifier for the invoice\n invoice_number character varying(100) UNIQUE NOT NULL, -- user-facing invoice number\n client_id character varying(64) NOT NULL, -- FK to clients table\n case_id character varying(64), -- FK to cases table (optional, could be general retainer)\n issue_date date NOT NULL, -- date the invoice was generated\n due_date date NOT NULL, -- date the payment is due\n total_amount numeric(12, 2) NOT NULL, -- total amount due on the invoice\n amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid\n status character varying(50) NOT NULL, -- e.g., Draft, Sent, Paid, Partially Paid, Overdue, Void\n payment_date timestamp, -- date the invoice was fully paid (nullable)\n notes text, -- additional notes or terms on the invoice\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (invoice_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all invoice numbers together with the client IDs and related case IDs for invoices issued after March 1st, 2024."}, {"role": "assistant", "content": "SELECT invoice_number, client_id, case_id FROM legal_services.invoices WHERE issue_date > '2024-03-01';"}, {"role": "user", "content": "I only want to include invoices that have a total_amount greater than 5000. Can you update the query?"}, {"role": "assistant", "content": "SELECT invoice_number, client_id, case_id FROM legal_services.invoices WHERE issue_date > '2024-03-01' AND total_amount > 5000;"}, {"role": "user", "content": "Add the invoice status to the result, and only show invoices where the status is either 'Overdue' or 'Partially Paid'."}, {"role": "assistant", "content": "SELECT invoice_number, client_id, case_id, status FROM legal_services.invoices WHERE issue_date > '2024-03-01' AND total_amount > 5000 AND status IN ('Overdue', 'Partially Paid');"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.payments ( payment_id text, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\nCREATE TABLE government_services.service_locations ( location_id text, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\n", "conversations": [{"role": "user", "content": "For each state, show the total number of service locations and the number of employees working at agencies within those states."}, {"role": "assistant", "content": "SELECT sl.state, COUNT(DISTINCT sl.location_id) AS location_count, COUNT(DISTINCT e.employee_id) AS employee_count\nFROM government_services.service_locations sl\nJOIN government_services.employees e ON sl.agency_id = e.agency_id\nGROUP BY sl.state;"}, {"role": "user", "content": "Only include states with more than 3 service locations."}, {"role": "assistant", "content": "SELECT sl.state, COUNT(DISTINCT sl.location_id) AS location_count, COUNT(DISTINCT e.employee_id) AS employee_count\nFROM government_services.service_locations sl\nJOIN government_services.employees e ON sl.agency_id = e.agency_id\nGROUP BY sl.state\nHAVING COUNT(DISTINCT sl.location_id) > 3;"}, {"role": "user", "content": "Now, order the results by employee_count in descending order."}, {"role": "assistant", "content": "SELECT sl.state, COUNT(DISTINCT sl.location_id) AS location_count, COUNT(DISTINCT e.employee_id) AS employee_count\nFROM government_services.service_locations sl\nJOIN government_services.employees e ON sl.agency_id = e.agency_id\nGROUP BY sl.state\nHAVING COUNT(DISTINCT sl.location_id) > 3\nORDER BY employee_count DESC;"}, {"role": "user", "content": "Show only the top 5 states."}, {"role": "assistant", "content": "SELECT sl.state, COUNT(DISTINCT sl.location_id) AS location_count, COUNT(DISTINCT e.employee_id) AS employee_count\nFROM government_services.service_locations sl\nJOIN government_services.employees e ON sl.agency_id = e.agency_id\nGROUP BY sl.state\nHAVING COUNT(DISTINCT sl.location_id) > 3\nORDER BY employee_count DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.developers (\n developer_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the developer studio\n name character varying(150) NOT NULL UNIQUE, -- name of the development studio\n country character varying(100), -- country where the studio is based\n founded_year integer, -- year the studio was founded\n website character varying(255), -- developer's official website\n created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (developer_id)\n)\n", "conversations": [{"role": "user", "content": "How many developers are there in each country?"}, {"role": "assistant", "content": "SELECT\n country,\n COUNT(developer_id) AS developer_count\nFROM\n gaming_technology.developers\nWHERE country IS NOT NULL\nGROUP BY\n country;"}, {"role": "user", "content": "Only include countries with more than 5 developers."}, {"role": "assistant", "content": "SELECT\n country,\n COUNT(developer_id) AS developer_count\nFROM\n gaming_technology.developers\nWHERE country IS NOT NULL\nGROUP BY\n country\nHAVING\n COUNT(developer_id) > 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table\n appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment\n duration_minutes integer NOT NULL, -- expected duration in minutes\n reason text, -- reason for the visit\n status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show\n location_id character varying(64), -- FK to a potential locations/clinics table\n notes text, -- notes related to scheduling\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the total number of appointments grouped by each unique duration in minutes. Include only durations with more than 5 appointments."}, {"role": "assistant", "content": "SELECT duration_minutes, COUNT(*) AS appointment_count\nFROM healthcare.appointments\nGROUP BY duration_minutes\nHAVING COUNT(*) > 5;"}, {"role": "user", "content": "Can you also show, for each of these durations, the earliest and latest appointment_time?"}, {"role": "assistant", "content": "SELECT duration_minutes, COUNT(*) AS appointment_count,\n MIN(appointment_time) AS earliest_appointment,\n MAX(appointment_time) AS latest_appointment\nFROM healthcare.appointments\nGROUP BY duration_minutes\nHAVING COUNT(*) > 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp.timestamp, block_number.bigint, transaction_hash.text, transaction_index.bigint, from_address.text, contract_address.text, symbol.text, total_supply.text, name.text, decimals.bigint, is_erc20.integer, is_erc721.integer, is_erc1155.integer, is_proxy.integer, extra_info.text, pk.integer )\nCREATE TABLE erc1155_approval_for_all (\n block_number bigint NOT NULL, -- Block number containing the transaction\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction\n transaction_index integer NOT NULL, -- Index of the transaction within the block\n transaction_hash varchar(66) NOT NULL, -- Transaction hash\n log_index integer NOT NULL, -- Log index\n contract_address varchar(42) NOT NULL -- Event contract address\n)\nCREATE TABLE nft_holders ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )\nCREATE TABLE sui_coins_metadata (\n object_id varchar NOT NULL, -- object id of the coin metadata object\n coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN\n status varchar NOT NULL, -- coin status, eg. exists, deleted\n decimals bigint NOT NULL, -- decimals of the coin\n description varchar NOT NULL, -- description of the coin\n icon_url varchar NOT NULL, -- icon url of the coin\n symbol varchar NOT NULL, -- symbol of the coin\n name varchar NOT NULL -- name of the coin\n)\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE token_info (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar NOT NULL, -- Token tick\n max_supply decimal(38,0) NOT NULL, -- Max supply\n lim decimal(38,0) NOT NULL, -- Limit of each mint\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table)\n)\nCREATE TABLE mud_holesky_redstone (\n address varchar NOT NULL, -- address fields for the functionType in contract\n table_id varchar NOT NULL, -- table_id fields for the functionType in contract\n key_bytes varchar NOT NULL, -- key_bytes fields for the functionType in contract\n key0 varchar NOT NULL, -- key0 fields for the functionType in contract\n key1 varchar NOT NULL, -- key1 fields for the functionType in contract\n static_data varchar NOT NULL, -- static_data fields for the functionType in contract\n encoded_lengths varchar NOT NULL, -- encoded_lengths fields for the functionType in contract\n dynamic_data varchar NOT NULL, -- dynamic_data fields for the functionType in contract\n is_deleted boolean NOT NULL, -- is_deleted fields for the functionType in contract\n block_number bigint NOT NULL, -- Block number uniquely identifying the block\n log_index bigint NOT NULL -- Index of the log within the transaction\n)\nCREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\n", "conversations": [{"role": "user", "content": "List all active SUI coins (status 'exists') with their `coin_type`, `symbol`, `name`, and the total balance across all owners."}, {"role": "assistant", "content": "SELECT sc.coin_type,\n sm.symbol,\n sm.name,\n SUM(CAST(sc.balance AS bigint)) AS total_balance\nFROM sui_coins sc\nJOIN sui_coins_metadata sm\n ON sc.coin_type = sm.coin_type\nWHERE sc.status = 'exists'\n AND sm.status = 'exists'\nGROUP BY sc.coin_type, sm.symbol, sm.name;"}, {"role": "user", "content": "Only include coins where the description contains 'staking'."}, {"role": "assistant", "content": "SELECT sc.coin_type,\n sm.symbol,\n sm.name,\n SUM(CAST(sc.balance AS bigint)) AS total_balance\nFROM sui_coins sc\nJOIN sui_coins_metadata sm\n ON sc.coin_type = sm.coin_type\nWHERE sc.status = 'exists'\n AND sm.status = 'exists'\n AND sm.description LIKE '%staking%'\nGROUP BY sc.coin_type, sm.symbol, sm.name;"}, {"role": "user", "content": "Also show the number of distinct owners per `coin_type`."}, {"role": "assistant", "content": "SELECT sc.coin_type,\n sm.symbol,\n sm.name,\n SUM(CAST(sc.balance AS bigint)) AS total_balance,\n COUNT(DISTINCT sc.owner) AS owner_count\nFROM sui_coins sc\nJOIN sui_coins_metadata sm\n ON sc.coin_type = sm.coin_type\nWHERE sc.status = 'exists'\n AND sm.status = 'exists'\n AND sm.description LIKE '%staking%'\nGROUP BY sc.coin_type, sm.symbol, sm.name;"}, {"role": "user", "content": "Finally, sort by `total_balance` descending and limit to the top 3 coins."}, {"role": "assistant", "content": "SELECT sc.coin_type,\n sm.symbol,\n sm.name,\n SUM(CAST(sc.balance AS bigint)) AS total_balance,\n COUNT(DISTINCT sc.owner) AS owner_count\nFROM sui_coins sc\nJOIN sui_coins_metadata sm\n ON sc.coin_type = sm.coin_type\nWHERE sc.status = 'exists'\n AND sm.status = 'exists'\n AND sm.description LIKE '%staking%'\nGROUP BY sc.coin_type, sm.symbol, sm.name\nORDER BY total_balance DESC\nLIMIT 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.posts ( post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, visibility character varying(20) NOT NULL DEFAULT 'public', location_lat numeric(9,6), location_lon numeric(9,6), PRIMARY KEY (post_id) )\nCREATE TABLE social_media.comments (\n comment_id character varying(64) NOT NULL, -- unique identifier for the comment\n post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)\n user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)\n parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)\n content text NOT NULL, -- textual content of the comment\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit\n PRIMARY KEY (comment_id)\n)\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.post_hashtags (\n post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link\n post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id)\n hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id)\n PRIMARY KEY (post_hashtag_id),\n CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post\n)\nCREATE TABLE social_media.messages ( message_id text PRIMARY KEY, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp )\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.user_settings ( setting_id text, user_id text, theme text, email_notifications_enabled boolean, push_notifications_enabled boolean, private_profile boolean, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Find posts that have been liked by users the author of the post is following. List the post_id and the user_id of the post author."}, {"role": "assistant", "content": "SELECT p.post_id, p.user_id AS post_author_user_id FROM social_media.posts AS p JOIN social_media.likes AS l ON p.post_id = l.post_id JOIN social_media.follows AS f ON f.follower_user_id = p.user_id AND f.following_user_id = l.user_id;"}, {"role": "user", "content": "Can you refine this to only include posts where the author started following the user *before* the post was created?"}, {"role": "assistant", "content": "SELECT p.post_id, p.user_id AS post_author_user_id FROM social_media.posts AS p JOIN social_media.likes AS l ON p.post_id = l.post_id JOIN social_media.follows AS f ON f.follower_user_id = p.user_id AND f.following_user_id = l.user_id WHERE f.created_at < p.created_at;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers (\n customer_id character varying(64) NOT NULL, -- unique identifier for the customer\n first_name character varying(100) NOT NULL, -- customer's first name\n last_name character varying(100) NOT NULL, -- customer's last name\n date_of_birth date NOT NULL, -- customer's date of birth\n ssn_hash character varying(128), -- Hashed social security number (or national ID)\n address_line1 character varying(255) NOT NULL,\n address_line2 character varying(255),\n city character varying(100) NOT NULL,\n state character varying(50) NOT NULL,\n zip_code character varying(20) NOT NULL,\n country character varying(50) NOT NULL DEFAULT 'USA',\n phone_number character varying(30),\n email character varying(128) UNIQUE, -- unique email address\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the customer record was created\n updated_at timestamp, -- when the customer record was last updated\n status character varying(20) NOT NULL DEFAULT 'Active', -- e.g., Active, Inactive, Prospect\n PRIMARY KEY (customer_id)\n)\n", "conversations": [{"role": "user", "content": "List all inactive customers from Texas who were created in the last 2 years, showing their full names and creation dates."}, {"role": "assistant", "content": "SELECT first_name, last_name, created_at FROM insurance.customers WHERE state = 'Texas' AND status = 'Inactive' AND created_at >= CURRENT_DATE - INTERVAL '2 years';"}, {"role": "user", "content": "Now sort these results by creation date in descending order."}, {"role": "assistant", "content": "SELECT first_name, last_name, created_at FROM insurance.customers WHERE state = 'Texas' AND status = 'Inactive' AND created_at >= CURRENT_DATE - INTERVAL '2 years' ORDER BY created_at DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.securities (\n security_id character varying(64) NOT NULL, -- unique identifier for the security\n ticker_symbol character varying(20) NOT NULL UNIQUE, -- stock ticker or fund symbol\n isin_code character varying(12) UNIQUE, -- International Securities Identification Number\n cusip_code character varying(9) UNIQUE, -- CUSIP number\n security_name text NOT NULL, -- full name of the security\n security_type character varying(50) NOT NULL, -- e.g., Stock, Bond, ETF, Mutual Fund, Option, Future\n exchange character varying(50), -- primary exchange where traded (e.g., NYSE, NASDAQ)\n currency character varying(3) NOT NULL, -- currency the security is denominated in\n issuer_name character varying(255), -- name of the issuing entity\n sector character varying(100), -- industry sector\n last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (security_id)\n)\n", "conversations": [{"role": "user", "content": "List pairs of securities that trade on different exchanges but belong to the same sector, showing ticker_symbol of both as symbol_a and symbol_b, their exchanges, and the sector."}, {"role": "assistant", "content": "SELECT a.ticker_symbol AS symbol_a, a.exchange AS exchange_a, b.ticker_symbol AS symbol_b, b.exchange AS exchange_b, a.sector\nFROM financial_services.securities a\nJOIN financial_services.securities b\n ON a.sector = b.sector\n AND a.exchange <> b.exchange\nWHERE a.ticker_symbol < b.ticker_symbol;"}, {"role": "user", "content": "Actually, exclude any pairs where the sector is NULL and ensure uniqueness by requiring symbol_a < symbol_b."}, {"role": "assistant", "content": "SELECT a.ticker_symbol AS symbol_a, a.exchange AS exchange_a, b.ticker_symbol AS symbol_b, b.exchange AS exchange_b, a.sector\nFROM financial_services.securities a\nJOIN financial_services.securities b\n ON a.sector = b.sector\n AND a.exchange <> b.exchange\nWHERE a.sector IS NOT NULL\n AND a.ticker_symbol < b.ticker_symbol;"}, {"role": "user", "content": "Now also order the results by sector ascending and symbol_a ascending."}, {"role": "assistant", "content": "SELECT a.ticker_symbol AS symbol_a, a.exchange AS exchange_a, b.ticker_symbol AS symbol_b, b.exchange AS exchange_b, a.sector\nFROM financial_services.securities a\nJOIN financial_services.securities b\n ON a.sector = b.sector\n AND a.exchange <> b.exchange\nWHERE a.sector IS NOT NULL\n AND a.ticker_symbol < b.ticker_symbol\nORDER BY a.sector ASC, a.ticker_symbol ASC;"}, {"role": "user", "content": "Finally, only include pairs where both securities are denominated in USD."}, {"role": "assistant", "content": "SELECT a.ticker_symbol AS symbol_a, a.exchange AS exchange_a, b.ticker_symbol AS symbol_b, b.exchange AS exchange_b, a.sector\nFROM financial_services.securities a\nJOIN financial_services.securities b\n ON a.sector = b.sector\n AND a.exchange <> b.exchange\nWHERE a.sector IS NOT NULL\n AND a.currency = 'USD'\n AND b.currency = 'USD'\n AND a.ticker_symbol < b.ticker_symbol\nORDER BY a.sector ASC, a.ticker_symbol ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles (\n vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle\n license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate\n vin character varying(17) UNIQUE, -- vehicle identification number\n make character varying(64) NOT NULL, -- manufacturer of the vehicle\n model character varying(64) NOT NULL, -- model of the vehicle\n year integer NOT NULL, -- manufacturing year\n type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)\n capacity integer, -- passenger or cargo capacity\n fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen\n status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned\n depot_id character varying(64), -- identifier of the home depot/base\n acquisition_date date, -- date the vehicle was acquired\n PRIMARY KEY (vehicle_id)\n)\nCREATE TABLE transportation.locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the location\n name character varying(255) NOT NULL, -- name of the location (e.g., Central Station, Depot Alpha, Pier 7)\n type character varying(64) NOT NULL, -- e.g., Station, Stop, Depot, Port, Airport, Customer Address\n address_line1 character varying(255), -- street address\n city character varying(128), -- city name\n state_province character varying(128), -- state or province\n postal_code character varying(32), -- postal code\n country character varying(64) NOT NULL, -- country name\n latitude numeric(9, 6), -- geographic latitude\n longitude numeric(9, 6), -- geographic longitude\n timezone character varying(64), -- IANA timezone name (e.g., America/New_York)\n PRIMARY KEY (location_id)\n)\nCREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\nCREATE TABLE transportation.passengers ( passenger_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve each vehicle's latest maintenance service date and mechanic alongside its make and model."}, {"role": "assistant", "content": "SELECT v.vehicle_id, v.make, v.model, ml.service_date, ml.mechanic_name\nFROM transportation.vehicles v\nJOIN transportation.maintenance_logs ml ON v.vehicle_id = ml.vehicle_id\nWHERE ml.service_date = (\n SELECT MAX(service_date)\n FROM transportation.maintenance_logs\n WHERE vehicle_id = v.vehicle_id\n);"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (property_id)\n)\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, bill_id character varying(64), amount numeric(12,2) NOT NULL, currency_code character varying(3) NOT NULL, payment_method character varying(50) NOT NULL, card_type character varying(50), card_last_four character varying(4), transaction_ref character varying(128), payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, status character varying(50) NOT NULL, staff_id_processed character varying(64), notes text, PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "For each reservation, can you show the guest's full name, the property name, and the room number?"}, {"role": "assistant", "content": "SELECT r.reservation_id, g.first_name || ' ' || g.last_name AS guest_full_name, p.property_name, rm.room_number\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.guests g ON r.guest_id = g.guest_id\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nJOIN hospitality_technology.rooms rm ON r.room_id = rm.room_id;"}, {"role": "user", "content": "Also include the check-in and check-out dates for each reservation, and sort the results by check-in date."}, {"role": "assistant", "content": "SELECT r.reservation_id, g.first_name || ' ' || g.last_name AS guest_full_name, p.property_name, rm.room_number, r.check_in_date, r.check_out_date\nFROM hospitality_technology.reservations r\nJOIN hospitality_technology.guests g ON r.guest_id = g.guest_id\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nJOIN hospitality_technology.rooms rm ON r.room_id = rm.room_id\nORDER BY r.check_in_date;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Show me the property ID, name, and creation date for all properties created after January 1, 2022."}, {"role": "assistant", "content": "SELECT property_id, property_name, created_at FROM hospitality_technology.properties WHERE created_at >= '2022-01-01';"}, {"role": "user", "content": "Filter this list to only include properties in 'Texas' or 'Florida' and sort by creation date ascending."}, {"role": "assistant", "content": "SELECT property_id, property_name, created_at FROM hospitality_technology.properties WHERE created_at >= '2022-01-01' AND state_province IN ('TX', 'FL') ORDER BY created_at ASC;"}, {"role": "user", "content": "Actually, only show properties of type 'Resort' and limit the output to the top 10."}, {"role": "assistant", "content": "SELECT property_id, property_name, created_at FROM hospitality_technology.properties WHERE created_at >= '2022-01-01' AND state_province IN ('TX', 'FL') AND property_type = 'Resort' ORDER BY created_at ASC LIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id character varying(64) NOT NULL, license_plate character varying(32) NOT NULL UNIQUE, vin character varying(17) UNIQUE, make character varying(64) NOT NULL, model character varying(64) NOT NULL, year integer NOT NULL, type character varying(32) NOT NULL, capacity integer, fuel_type character varying(32) NOT NULL, status character varying(32) NOT NULL, depot_id character varying(64), acquisition_date date, PRIMARY KEY (vehicle_id) )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Give me a list of all passengers with an email address on file, showing their first name, last name, and the date their record was created."}, {"role": "assistant", "content": "SELECT first_name, last_name, created_at\nFROM transportation.passengers\nWHERE email IS NOT NULL;"}, {"role": "user", "content": "Narrow the results to only include passengers who joined in 2022."}, {"role": "assistant", "content": "SELECT first_name, last_name, created_at\nFROM transportation.passengers\nWHERE email IS NOT NULL AND EXTRACT(YEAR FROM created_at) = 2022;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.agencies ( agency_id text PRIMARY KEY, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )\nCREATE TABLE government_services.services ( service_id text 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 )\nCREATE TABLE government_services.documents ( document_id text PRIMARY KEY, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees ( employee_id text PRIMARY KEY, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\nCREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "How many service locations are marked as accessible?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM government_services.service_locations WHERE is_accessible = TRUE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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) )\n", "conversations": [{"role": "user", "content": "How many documents of each type currently have a verification_status of 'Pending'?"}, {"role": "assistant", "content": "SELECT\n document_type,\n COUNT(*) AS pending_count\nFROM government_services.documents\nWHERE verification_status = 'Pending'\nGROUP BY document_type;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.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 )\n", "conversations": [{"role": "user", "content": "Calculate the total price for all service orders, grouped by their status."}, {"role": "assistant", "content": "SELECT status, SUM(total_price) AS total_revenue FROM hospitality_technology.service_orders GROUP BY status;"}, {"role": "user", "content": "Now, only include the statuses 'Delivered' and 'Completed'."}, {"role": "assistant", "content": "SELECT status, SUM(total_price) AS total_revenue FROM hospitality_technology.service_orders WHERE status IN ('Delivered', 'Completed') GROUP BY status;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all invoice numbers and their total amount for invoices that are overdue. Show the client ID and the due date as well."}, {"role": "assistant", "content": "SELECT invoice_number, total_amount, client_id, due_date FROM legal_services.invoices WHERE due_date < CURRENT_DATE AND amount_paid < total_amount;"}, {"role": "user", "content": "Please also include the number of days each invoice is overdue."}, {"role": "assistant", "content": "SELECT invoice_number, total_amount, client_id, due_date, (CURRENT_DATE - due_date) AS days_overdue FROM legal_services.invoices WHERE due_date < CURRENT_DATE AND amount_paid < total_amount;"}, {"role": "user", "content": "Now, show only those invoices that are overdue by more than 15 days."}, {"role": "assistant", "content": "SELECT invoice_number, total_amount, client_id, due_date, (CURRENT_DATE - due_date) AS days_overdue FROM legal_services.invoices WHERE due_date < CURRENT_DATE AND amount_paid < total_amount AND (CURRENT_DATE - due_date) > 15;"}, {"role": "user", "content": "Add the invoice status to the output and order by days_overdue descending."}, {"role": "assistant", "content": "SELECT invoice_number, total_amount, client_id, due_date, status, (CURRENT_DATE - due_date) AS days_overdue FROM legal_services.invoices WHERE due_date < CURRENT_DATE AND amount_paid < total_amount AND (CURRENT_DATE - due_date) > 15 ORDER BY days_overdue DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "What are the top 5 product types by average base premium, showing the product_type and average base_premium, ordered by average base_premium descending?"}, {"role": "assistant", "content": "SELECT product_type, AVG(base_premium) AS avg_premium FROM insurance.insurance_products GROUP BY product_type ORDER BY avg_premium DESC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.events (\n event_id character varying(64) NOT NULL, -- unique identifier for the event\n contract_id character varying(64) NOT NULL, -- identifier of the contract emitting the event\n event_name character varying(128) NOT NULL, -- name of the event\n data text NOT NULL, -- data payload of the event\n emitted_at timestamp NOT NULL, -- time when the event was emitted\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction that triggered the event\n log_index integer NOT NULL, -- index of the event log in the transaction\n PRIMARY KEY (event_id)\n)\nCREATE TABLE web3.tokens (\n token_id character varying(64) NOT NULL, -- unique identifier for the token\n contract_address character varying(128) NOT NULL, -- address of the token contract\n token_name character varying(128) NOT NULL, -- name of the token\n token_symbol character varying(32) NOT NULL, -- symbol of the token\n decimals integer NOT NULL, -- number of decimals for the token\n total_supply numeric(38,14) NOT NULL, -- total supply of the token\n PRIMARY KEY (token_id)\n)\nCREATE TABLE web3.wallets (\n wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet\n user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet\n address character varying(128) NOT NULL, -- address of the wallet\n private_key text NOT NULL, -- private key of the wallet\n created_at timestamp NOT NULL, -- time when the wallet was created\n PRIMARY KEY (wallet_id)\n)\nCREATE TABLE web3.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(128) NOT NULL, -- username of the user\n email character varying(128) NOT NULL, -- email address of the user\n password_hash text NOT NULL, -- hashed password of the user\n created_at timestamp NOT NULL, -- time when the user account was created\n PRIMARY KEY (user_id)\n)\n", "conversations": [{"role": "user", "content": "List the username and email of users whose first wallet creation date is the same day as their user registration date."}, {"role": "assistant", "content": "SELECT u.username, u.email FROM web3.users u JOIN (SELECT user_id, MIN(created_at) as first_wallet_created_at FROM web3.wallets GROUP BY user_id) w ON u.user_id = w.user_id WHERE DATE(u.created_at) = DATE(w.first_wallet_created_at);"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.tokens (\n token_id character varying(64) NOT NULL, -- unique identifier for the token\n contract_address character varying(128) NOT NULL, -- address of the token contract\n token_name character varying(128) NOT NULL, -- name of the token\n token_symbol character varying(32) NOT NULL, -- symbol of the token\n decimals integer NOT NULL, -- number of decimals for the token\n total_supply numeric(38,14) NOT NULL, -- total supply of the token\n PRIMARY KEY (token_id)\n)\n", "conversations": [{"role": "user", "content": "Count how many tokens exist for each contract_address."}, {"role": "assistant", "content": "SELECT contract_address,\n COUNT(*) AS token_count\nFROM web3.tokens\nGROUP BY contract_address;"}, {"role": "user", "content": "Now only include contract_address values that have more than 2 tokens."}, {"role": "assistant", "content": "SELECT contract_address,\n COUNT(*) AS token_count\nFROM web3.tokens\nGROUP BY contract_address\nHAVING COUNT(*) > 2;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.passengers (\n passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger\n first_name character varying(128) NOT NULL, -- passenger's first name\n last_name character varying(128) NOT NULL, -- passenger's last name\n email character varying(128) UNIQUE, -- email address\n phone_number character varying(32) UNIQUE, -- phone number\n date_of_birth date, -- passenger's date of birth\n loyalty_program_id character varying(64), -- identifier for loyalty program membership\n created_at timestamp with time zone NOT NULL, -- time when the passenger record was created\n PRIMARY KEY (passenger_id)\n)\n", "conversations": [{"role": "user", "content": "List all passengers born before 1990 with their first and last names and email addresses."}, {"role": "assistant", "content": "SELECT first_name, last_name, email FROM transportation.passengers WHERE date_of_birth < '1990-01-01';"}, {"role": "user", "content": "Can you also include their phone numbers in the result?"}, {"role": "assistant", "content": "SELECT first_name, last_name, email, phone_number FROM transportation.passengers WHERE date_of_birth < '1990-01-01';"}, {"role": "user", "content": "Now, filter it further to only passengers who have an email address registered."}, {"role": "assistant", "content": "SELECT first_name, last_name, email, phone_number FROM transportation.passengers WHERE date_of_birth < '1990-01-01' AND email IS NOT NULL;"}, {"role": "user", "content": "Sort the final result by last name in ascending order."}, {"role": "assistant", "content": "SELECT first_name, last_name, email, phone_number FROM transportation.passengers WHERE date_of_birth < '1990-01-01' AND email IS NOT NULL ORDER BY last_name ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.events ( event_id character varying(64) NOT NULL, contract_id character varying(64) NOT NULL, event_name character varying(128) NOT NULL, data text NOT NULL, emitted_at timestamp NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (event_id) )\n", "conversations": [{"role": "user", "content": "Count the number of events for each hour of the day based on the emitted_at timestamp."}, {"role": "assistant", "content": "SELECT EXTRACT(HOUR FROM emitted_at) AS event_hour, COUNT(*) AS event_count FROM web3.events GROUP BY event_hour ORDER BY event_hour;"}, {"role": "user", "content": "Actually, only show hours with more than 100 events."}, {"role": "assistant", "content": "SELECT EXTRACT(HOUR FROM emitted_at) AS event_hour, COUNT(*) AS event_count FROM web3.events GROUP BY event_hour HAVING COUNT(*) > 100 ORDER BY event_hour;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.cases (\n case_id character varying(64) NOT NULL, -- unique identifier for the case/matter\n case_number character varying(100) UNIQUE, -- official case number (court or internal)\n case_name text NOT NULL, -- descriptive name or title for the case\n client_id character varying(64) NOT NULL, -- FK to clients table\n lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)\n case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP\n status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed\n date_opened timestamp NOT NULL, -- date the case was formally opened\n date_closed timestamp, -- date the case was closed (nullable)\n description text, -- detailed description of the case\n court_jurisdiction character varying(128), -- court or jurisdiction if applicable\n PRIMARY KEY (case_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all cases where the description contains the word 'agreement'. Display the case ID, case name, and description."}, {"role": "assistant", "content": "SELECT case_id, case_name, description FROM legal_services.cases WHERE description ILIKE '%agreement%';"}, {"role": "user", "content": "Also include cases where the description contains 'contract', and make sure the status is 'Pending'."}, {"role": "assistant", "content": "SELECT case_id, case_name, description FROM legal_services.cases WHERE (description ILIKE '%agreement%' OR description ILIKE '%contract%') AND status = 'Pending';"}, {"role": "user", "content": "Now, show only those cases from the previous list that were opened in the last 90 days."}, {"role": "assistant", "content": "SELECT case_id, case_name, description FROM legal_services.cases WHERE (description ILIKE '%agreement%' OR description ILIKE '%contract%') AND status = 'Pending' AND date_opened >= CURRENT_DATE - INTERVAL '90 days';"}, {"role": "user", "content": "Finally, order the results by date opened descending and only show the case name and description."}, {"role": "assistant", "content": "SELECT case_name, description FROM legal_services.cases WHERE (description ILIKE '%agreement%' OR description ILIKE '%contract%') AND status = 'Pending' AND date_opened >= CURRENT_DATE - INTERVAL '90 days' ORDER BY date_opened DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE manufacturing.materials (\n material_id character varying(64) NOT NULL, -- unique identifier for the material\n material_name character varying(128) NOT NULL, -- common name (e.g., Titanium Alloy Grade 5, Carbon Fiber Prepreg)\n specification character varying(255), -- specification standard (e.g., AMS 4928)\n description text, -- detailed description of properties\n density_kg_m3 numeric(10, 4), -- density in kg per cubic meter\n tensile_strength_mpa integer, -- tensile strength in Megapascals\n PRIMARY KEY (material_id)\n)\nCREATE TABLE manufacturing.assembly_steps (\n step_id character varying(64) NOT NULL, -- unique identifier for an assembly step/task\n line_id character varying(64) NOT NULL, -- FK to the assembly line where this step occurs\n step_number integer NOT NULL, -- sequence number of the step on the line\n step_name character varying(255) NOT NULL, -- name of the task (e.g., Install Wing Root Fairing)\n description text, -- detailed instructions or description\n standard_duration_hours numeric(8,2), -- estimated time to complete the step\n required_skill_level character varying(50), -- skill level needed (e.g., 'Mechanic II', 'Electrician I')\n workstation character varying(100), -- specific workstation or area for the step\n PRIMARY KEY (step_id)\n)\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u6750\u6599\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u7d44\u307f\u7acb\u3066\u624b\u9806\u3092\u78ba\u8a8d\u3057\u305f\u3044\u3067\u3059\u3002\u6750\u6599ID\u3068\u6750\u6599\u540d\u3001\u7d44\u307f\u7acb\u3066\u624b\u9806\u306e\u30b9\u30c6\u30c3\u30d7\u540d\u3068\u8aac\u660e\u3092\u542b\u3081\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SELECT m.material_id, m.material_name, s.step_name, s.description\nFROM manufacturing.materials m\nJOIN manufacturing.assembly_steps s ON m.material_id = s.step_id\nWHERE m.material_id = 'specific_material_id';"}, {"role": "user", "content": "\u3055\u3089\u306b\u3001\u7279\u5b9a\u306e\u30b9\u30ad\u30eb\u30ec\u30d9\u30eb\u304c\u5fc5\u8981\u306a\u624b\u9806\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3067\u304d\u307e\u3059\u304b\uff1f\u4f8b\u3048\u3070\u300cMechanic II\u300d\u306e\u307f\u3002"}, {"role": "assistant", "content": "SELECT m.material_id, m.material_name, s.step_name, s.description\nFROM manufacturing.materials m\nJOIN manufacturing.assembly_steps s ON m.material_id = s.step_id\nWHERE m.material_id = 'specific_material_id'\nAND s.required_skill_level = 'Mechanic II';"}, {"role": "user", "content": "\u3082\u3057\u6a19\u6e96\u4f5c\u696d\u6642\u9593\u304c2\u6642\u9593\u4ee5\u4e0a\u306e\u624b\u9806\u3060\u3051\u3092\u7d5e\u308a\u8fbc\u307f\u305f\u3044\u5834\u5408\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u3067\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SELECT m.material_id, m.material_name, s.step_name, s.description\nFROM manufacturing.materials m\nJOIN manufacturing.assembly_steps s ON m.material_id = s.step_id\nWHERE m.material_id = 'specific_material_id'\nAND s.required_skill_level = 'Mechanic II'\nAND s.standard_duration_hours >= 2;"}, {"role": "user", "content": "\u6700\u5f8c\u306b\u3001\u30b9\u30c6\u30c3\u30d7\u756a\u53f7\u9806\u306b\u4e26\u3079\u66ff\u3048\u3066\u7d50\u679c\u3092\u8868\u793a\u3057\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SELECT m.material_id, m.material_name, s.step_name, s.description\nFROM manufacturing.materials m\nJOIN manufacturing.assembly_steps s ON m.material_id = s.step_id\nWHERE m.material_id = 'specific_material_id'\nAND s.required_skill_level = 'Mechanic II'\nAND s.standard_duration_hours >= 2\nORDER BY s.step_number;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "I need to find users who have liked both a post and a comment on the same day. For each such user and date, list user_id, date, post_id, and comment_id."}, {"role": "assistant", "content": "SELECT p.user_id, DATE(p.created_at) AS like_date, p.post_id, c.comment_id\nFROM social_media.likes p\nJOIN social_media.likes c\n ON p.user_id = c.user_id\n AND DATE(p.created_at) = DATE(c.created_at)\nWHERE p.post_id IS NOT NULL\n AND c.comment_id IS NOT NULL;"}, {"role": "user", "content": "Actually, I only want cases where the post and comment were liked within two hours of each other."}, {"role": "assistant", "content": "SELECT p.user_id, DATE(p.created_at) AS like_date, p.post_id, c.comment_id\nFROM social_media.likes p\nJOIN social_media.likes c\n ON p.user_id = c.user_id\n AND DATE(p.created_at) = DATE(c.created_at)\nWHERE p.post_id IS NOT NULL\n AND c.comment_id IS NOT NULL\n AND ABS(EXTRACT(EPOCH FROM (p.created_at - c.created_at))) <= 7200;"}, {"role": "user", "content": "Please order the results by like_date descending."}, {"role": "assistant", "content": "SELECT p.user_id, DATE(p.created_at) AS like_date, p.post_id, c.comment_id\nFROM social_media.likes p\nJOIN social_media.likes c\n ON p.user_id = c.user_id\n AND DATE(p.created_at) = DATE(c.created_at)\nWHERE p.post_id IS NOT NULL\n AND c.comment_id IS NOT NULL\n AND ABS(EXTRACT(EPOCH FROM (p.created_at - c.created_at))) <= 7200\nORDER BY like_date DESC;"}, {"role": "user", "content": "Also, limit the output to the top 10 records."}, {"role": "assistant", "content": "SELECT p.user_id, DATE(p.created_at) AS like_date, p.post_id, c.comment_id\nFROM social_media.likes p\nJOIN social_media.likes c\n ON p.user_id = c.user_id\n AND DATE(p.created_at) = DATE(c.created_at)\nWHERE p.post_id IS NOT NULL\n AND c.comment_id IS NOT NULL\n AND ABS(EXTRACT(EPOCH FROM (p.created_at - c.created_at))) <= 7200\nORDER BY like_date DESC\nLIMIT 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances_historical (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract\n amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height\n pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200))\n)\nCREATE TABLE nft_holders (\n block_number bigint NOT NULL, -- Block number containing the transaction\n contract_address varchar NOT NULL, -- Event contract address\n wallet_address varchar NOT NULL, -- The wallet address for the contract(with bloom filter)\n token_id varchar NOT NULL, -- NFT token id\n contract_type varchar NOT NULL, -- NFT contract type\n amount varchar NOT NULL, -- Number of held NFTs\n pk varchar NOT NULL -- The last string partition of the contract.\n)\nCREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar )\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )\n", "conversations": [{"role": "user", "content": "List all Sui NFTs with 'exists' status from the 'Gaming' collection type. Show the object_id, name, and owner."}, {"role": "assistant", "content": "SELECT object_id, name, owner FROM sui_nfts WHERE status = 'exists' AND collection_type = 'Gaming'"}, {"role": "user", "content": "Can you also include the package_id and the display metadata field?"}, {"role": "assistant", "content": "SELECT object_id, name, owner, package_id, display FROM sui_nfts WHERE status = 'exists' AND collection_type = 'Gaming'"}, {"role": "user", "content": "Filter the results to only include NFTs where the owner address starts with '0xabc'."}, {"role": "assistant", "content": "SELECT object_id, name, owner, package_id, display FROM sui_nfts WHERE status = 'exists' AND collection_type = 'Gaming' AND owner LIKE '0xabc%'"}, {"role": "user", "content": "Order the results by name ascending and limit to 5."}, {"role": "assistant", "content": "SELECT object_id, name, owner, package_id, display FROM sui_nfts WHERE status = 'exists' AND collection_type = 'Gaming' AND owner LIKE '0xabc%' ORDER BY name ASC LIMIT 5"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, hashtag_id character varying(64) NOT NULL, PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) )\n", "conversations": [{"role": "user", "content": "How many unique hashtags are linked to each post? Return post_id and hashtag_count."}, {"role": "assistant", "content": "SELECT post_id, COUNT(DISTINCT hashtag_id) AS hashtag_count\nFROM social_media.post_hashtags\nGROUP BY post_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id character varying(64) NOT NULL, license_plate character varying(32) NOT NULL UNIQUE, vin character varying(17) UNIQUE, make character varying(64) NOT NULL, model character varying(64) NOT NULL, year integer NOT NULL, type character varying(32) NOT NULL, capacity integer, fuel_type character varying(32) NOT NULL, status character varying(32) NOT NULL, depot_id character varying(64), acquisition_date date, PRIMARY KEY (vehicle_id) )\nCREATE TABLE transportation.trips ( trip_id character varying(64) NOT NULL, route_id character varying(64), vehicle_id character varying(64) NOT NULL, driver_id character varying(64) NOT NULL, scheduled_departure timestamp with time zone NOT NULL, actual_departure timestamp with time zone, scheduled_arrival timestamp with time zone NOT NULL, actual_arrival timestamp with time zone, origin_location_id character varying(64) NOT NULL, destination_location_id character varying(64) NOT NULL, status character varying(32) NOT NULL, passenger_count integer, cargo_manifest_id character varying(64), PRIMARY KEY (trip_id) )\nCREATE 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) )\nCREATE TABLE transportation.maintenance_logs ( log_id character varying(64) NOT NULL, vehicle_id character varying(64) NOT NULL, service_date date NOT NULL, odometer_reading integer, service_type character varying(128) NOT NULL, description text NOT NULL, cost numeric(10, 2), mechanic_name character varying(128), next_service_due_date date, PRIMARY KEY (log_id) )\nCREATE 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) )\nCREATE 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) )\n", "conversations": [{"role": "user", "content": "Which vehicles have a total maintenance cost exceeding 10000 across all their maintenance logs?"}, {"role": "assistant", "content": "SELECT vehicle_id, SUM(cost) AS total_maintenance_cost FROM transportation.maintenance_logs GROUP BY vehicle_id HAVING SUM(cost) > 10000;"}, {"role": "user", "content": "For these vehicles, also show the count of maintenance logs and the average cost per log."}, {"role": "assistant", "content": "SELECT vehicle_id, COUNT(log_id) AS maintenance_log_count, AVG(cost) AS average_maintenance_cost FROM transportation.maintenance_logs GROUP BY vehicle_id HAVING SUM(cost) > 10000;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.reviews ( review_id.text, property_id.text, reservation_id.text, guest_id.text, rating_overall.integer, rating_cleanliness.integer, rating_service.integer, rating_location.integer, rating_value.integer, comment.text, review_source.text, review_date.timestamp, is_public.boolean, staff_response.text, response_staff_id.text, response_date.timestamp )\n", "conversations": [{"role": "user", "content": "Show me reviews from 'Expedia' that have an overall rating of 1 or 2."}, {"role": "assistant", "content": "SELECT review_id, property_id, guest_id, rating_overall, review_date, comment FROM hospitality_technology.reviews WHERE review_source = 'Expedia' AND rating_overall <= 2;"}, {"role": "user", "content": "Actually, only include those submitted in the second half of 2023."}, {"role": "assistant", "content": "SELECT review_id, property_id, guest_id, rating_overall, review_date, comment FROM hospitality_technology.reviews WHERE review_source = 'Expedia' AND rating_overall <= 2 AND review_date >= '2023-07-01' AND review_date < '2024-01-01';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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) )\nCREATE TABLE transportation.routes ( route_id character varying(64) NOT NULL, route_number character varying(32) NOT NULL UNIQUE, description text, origin_location_id character varying(64) NOT NULL, destination_location_id character varying(64) NOT NULL, distance_km numeric(10, 2), estimated_duration_minutes integer, type character varying(32) NOT NULL, PRIMARY KEY (route_id) )\nCREATE 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) )\nCREATE 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) )\n", "conversations": [{"role": "user", "content": "Could you provide the route number, the name of the origin location, and the name of the destination location for all routes?"}, {"role": "assistant", "content": "SELECT T1.route_number , T2.name , T3.name FROM transportation.routes AS T1 JOIN transportation.locations AS T2 ON T1.origin_location_id = T2.location_id JOIN transportation.locations AS T3 ON T1.destination_location_id = T3.location_id"}, {"role": "user", "content": "Now, only show routes where the origin location is in the United States and the destination location is in Canada."}, {"role": "assistant", "content": "SELECT T1.route_number , T2.name , T3.name FROM transportation.routes AS T1 JOIN transportation.locations AS T2 ON T1.origin_location_id = T2.location_id JOIN transportation.locations AS T3 ON T1.destination_location_id = T3.location_id WHERE T2.country = 'USA' AND T3.country = 'Canada'"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date )\n", "conversations": [{"role": "user", "content": "Find all pairs of vehicles that have the same make and model but different fuel types. For each pair, display the first vehicle_id, the second vehicle_id, make, model, fuel_type of the first as fuel_type1 and of the second as fuel_type2."}, {"role": "assistant", "content": "SELECT v1.vehicle_id AS vehicle1_id, v2.vehicle_id AS vehicle2_id, v1.make, v1.model, v1.fuel_type AS fuel_type1, v2.fuel_type AS fuel_type2 FROM transportation.vehicles v1 JOIN transportation.vehicles v2 ON v1.make = v2.make AND v1.model = v2.model AND v1.vehicle_id < v2.vehicle_id AND v1.fuel_type <> v2.fuel_type;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.services ( service_id.text, agency_id.text, service_name.text, description.text, category.text, eligibility_criteria.text, standard_fee.numeric, average_processing_time_days.integer, is_active.boolean, online_application_url.text )\n", "conversations": [{"role": "user", "content": "Show me all services, their names, and their online application URLs for services that are both active and have an online application available."}, {"role": "assistant", "content": "SELECT service_name, online_application_url FROM government_services.services WHERE is_active = TRUE AND online_application_url IS NOT NULL AND online_application_url <> '';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.insurance_products ( product_id text, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.agents ( agent_id text, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "List customers who have active 'Auto' policies, showing their first name, last name, the policy number, and the product name."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number, T3.product_name FROM insurance.customers AS T1 JOIN insurance.policies AS T2 ON T1.customer_id = T2.customer_id JOIN insurance.insurance_products AS T3 ON T2.product_id = T3.product_id WHERE T2.status = 'Active' AND T3.product_type = 'Auto';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.messages ( message_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, sender_user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (message_id) )\nCREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "How many followers does each user have? Show user_id and follower_count."}, {"role": "assistant", "content": "SELECT following_user_id AS user_id, COUNT(*) AS follower_count\nFROM social_media.follows\nGROUP BY following_user_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, token_name character varying(100) NOT NULL, token_symbol character varying(100) NOT NULL, token_address character varying(100) NOT NULL, chain text, price double precision, price_change_percentage_1h double precision, price_change_percentage_24h double precision, price_change_percentage_7d double precision, highest_price_24h double precision, lowest_price_24h double precision, market_cap double precision, market_cap_rank bigint, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank bigint )\n", "conversations": [{"role": "user", "content": "List all tokens with a price below $1 and a 24-hour trading volume over $5 million."}, {"role": "assistant", "content": "SELECT token_name, token_symbol, price, total_volume FROM token_basic_info WHERE price < 1 AND total_volume::numeric > 5000000;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types ( room_type_id.text, property_id.text, type_name.text, description.text, base_rate.numeric, max_occupancy.integer, bed_type.text, area_sqft.numeric, amenities.text )\n", "conversations": [{"role": "user", "content": "Show all room types that offer 'WiFi' in their amenities."}, {"role": "assistant", "content": "SELECT room_type_id, property_id, type_name, amenities FROM hospitality_technology.room_types WHERE amenities LIKE '%WiFi%';"}, {"role": "user", "content": "Only include those with a base rate below 100 and return the results sorted by base_rate ascending."}, {"role": "assistant", "content": "SELECT room_type_id, property_id, type_name, amenities, base_rate FROM hospitality_technology.room_types WHERE amenities LIKE '%WiFi%' AND base_rate < 100 ORDER BY base_rate ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players ( player_id uuid PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb )\nCREATE TABLE gaming_technology.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 )\nCREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid PRIMARY KEY, player_id uuid, game_id uuid, server_id uuid, start_time timestamptz, end_time timestamptz, duration_seconds int, score int, session_data jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id.uuid, player_id.uuid, achievement_id.uuid, unlocked_at.timestamptz )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\nCREATE TABLE gaming_technology.player_inventory (\n inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry\n player_id uuid NOT NULL, -- FK linking to the player owning the item\n item_id uuid NOT NULL, -- FK linking to the item definition\n quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items)\n acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired\n instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability)\n PRIMARY KEY (inventory_id),\n -- Optional unique constraint if items are non-stackable or unique instances\n -- UNIQUE (player_id, item_id) -- Use if quantity is always 1\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id)\n)\n", "conversations": [{"role": "user", "content": "List each game and the number of unique in-game items available for it."}, {"role": "assistant", "content": "SELECT T1.title, count(T2.item_id) FROM gaming_technology.games AS T1 LEFT JOIN gaming_technology.in_game_items AS T2 ON T1.game_id = T2.game_id GROUP BY T1.title;"}, {"role": "user", "content": "Only show games with more than 10 unique items."}, {"role": "assistant", "content": "SELECT T1.title, count(T2.item_id) FROM gaming_technology.games AS T1 JOIN gaming_technology.in_game_items AS T2 ON T1.game_id = T2.game_id GROUP BY T1.title HAVING count(T2.item_id) > 10;"}, {"role": "user", "content": "Also include the average cost amount of items for these games."}, {"role": "assistant", "content": "SELECT T1.title, count(T2.item_id), avg(T2.cost_amount) FROM gaming_technology.games AS T1 JOIN gaming_technology.in_game_items AS T2 ON T1.game_id = T2.game_id GROUP BY T1.title HAVING count(T2.item_id) > 10;"}, {"role": "user", "content": "Order the results by average item cost amount in descending order."}, {"role": "assistant", "content": "SELECT T1.title, count(T2.item_id), avg(T2.cost_amount) FROM gaming_technology.games AS T1 JOIN gaming_technology.in_game_items AS T2 ON T1.game_id = T2.game_id GROUP BY T1.title HAVING count(T2.item_id) > 10 ORDER BY avg(T2.cost_amount) DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\n", "conversations": [{"role": "user", "content": "Show me the first name, last name, and position of all staff members, along with the name of the property they work at."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.position, T2.property_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id;"}, {"role": "user", "content": "Only include staff who are currently active."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.position, T2.property_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id WHERE T1.is_active = true;"}, {"role": "user", "content": "Sort the results by property name and then by staff last name."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.position, T2.property_name FROM hospitality_technology.staff AS T1 JOIN hospitality_technology.properties AS T2 ON T1.property_id = T2.property_id WHERE T1.is_active = true ORDER BY T2.property_name, T1.last_name;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.locations ( location_id text PRIMARY KEY, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\n", "conversations": [{"role": "user", "content": "Can you show me the name, city, and type for all locations that are in the same city but have different types?"}, {"role": "assistant", "content": "SELECT l1.name, l1.city, l1.type FROM transportation.locations l1 JOIN transportation.locations l2 ON l1.city = l2.city AND l1.location_id <> l2.location_id AND l1.type <> l2.type;"}, {"role": "user", "content": "Please only include locations where the city is 'Chicago'."}, {"role": "assistant", "content": "SELECT l1.name, l1.city, l1.type FROM transportation.locations l1 JOIN transportation.locations l2 ON l1.city = l2.city AND l1.location_id <> l2.location_id AND l1.type <> l2.type WHERE l1.city = 'Chicago';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers ( lawyer_id text, first_name text, last_name text, bar_number text, firm_id text, email text, phone text, specialization text, hire_date timestamp, is_partner boolean )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents ( document_id text, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version integer, description text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all appointments along with their subject and start time for lawyers specializing in 'Criminal Law'."}, {"role": "assistant", "content": "SELECT T1.subject, T1.start_time FROM legal_services.appointments AS T1 JOIN legal_services.lawyers AS T2 ON T1.lawyer_id = T2.lawyer_id WHERE T2.specialization = 'Criminal Law';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE cex_token_balance ( snapshot_time character varying(32) NOT NULL, chain character varying(128) NOT NULL, address character varying(128) NOT NULL, exchange character varying(512) NOT NULL, token_address character varying(128) NOT NULL, token_symbol character varying(512), balance numeric(38,10), usd_value numeric(38,14), price double precision )\n", "conversations": [{"role": "user", "content": "Show me the top 5 tokens by USD value held on the Binance Smart Chain, along with their average price and total balance."}, {"role": "assistant", "content": "SELECT token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Binance Smart Chain' GROUP BY token_symbol ORDER BY total_usd_value DESC LIMIT 5;"}, {"role": "user", "content": "Actually, I want to see this for the Polygon chain instead, and only include tokens with a total balance over 1000."}, {"role": "assistant", "content": "SELECT token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol HAVING SUM(balance) > 1000 ORDER BY total_usd_value DESC LIMIT 5;"}, {"role": "user", "content": "Can you add the exchange name to these results and filter to only show Binance holdings?"}, {"role": "assistant", "content": "SELECT exchange, token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND exchange = 'Binance' GROUP BY exchange, token_symbol HAVING SUM(balance) > 1000 ORDER BY total_usd_value DESC LIMIT 5;"}, {"role": "user", "content": "Now order these results by total balance instead of USD value."}, {"role": "assistant", "content": "SELECT exchange, token_symbol, AVG(price) as average_price, SUM(balance) as total_balance, SUM(usd_value) as total_usd_value FROM cex_token_balance WHERE chain = 'Polygon' AND exchange = 'Binance' GROUP BY exchange, token_symbol HAVING SUM(balance) > 1000 ORDER BY total_balance DESC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id.text, property_name.text, address_line1.text, address_line2.text, city.text, state_province.text, postal_code.text, country_code.text, phone_number.text, email_address.text, property_type.text, star_rating.numeric, timezone.text, manager_staff_id.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id.text, property_id.text, room_number.text, room_type_id.text, floor.integer, status.text, is_smoking.boolean, features.text, current_condition.text, last_cleaned_at.timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id.text, property_id.text, first_name.text, last_name.text, position.text, work_email.text, work_phone.text, hire_date.date, termination_date.date, is_active.boolean, access_level.integer, manager_id.text, created_at.timestamp )\nCREATE TABLE hospitality_technology.services ( service_id.text, property_id.text, service_name.text, description.text, category.text, price.numeric, unit.text, is_available.boolean, department.text )\nCREATE TABLE hospitality_technology.service_orders ( order_id.text, reservation_id.text, guest_id.text, service_id.text, staff_id_ordered.text, staff_id_delivered.text, order_timestamp.timestamp, delivery_timestamp.timestamp, quantity.integer, unit_price.numeric, total_price.numeric, status.text, notes.text, bill_id.text )\nCREATE TABLE hospitality_technology.reviews ( review_id.text, property_id.text, reservation_id.text, guest_id.text, rating_overall.integer, rating_cleanliness.integer, rating_service.integer, rating_location.integer, rating_value.integer, comment.text, review_source.text, review_date.timestamp, is_public.boolean, staff_response.text, response_staff_id.text, response_date.timestamp )\n", "conversations": [{"role": "user", "content": "Show each property's name, the number of available rooms, and the number of available services it currently offers."}, {"role": "assistant", "content": "SELECT p.property_name,\n COUNT(DISTINCT r.room_id) AS available_rooms,\n COUNT(DISTINCT s.service_id) AS available_services\nFROM hospitality_technology.properties p\nLEFT JOIN hospitality_technology.rooms r ON r.property_id = p.property_id AND r.status = 'Available'\nLEFT JOIN hospitality_technology.services s ON s.property_id = p.property_id AND s.is_available = TRUE\nGROUP BY p.property_id, p.property_name;"}, {"role": "user", "content": "Show only the properties where both available rooms and available services are at least 10, and sort the results by number of available rooms descending."}, {"role": "assistant", "content": "SELECT p.property_name,\n COUNT(DISTINCT r.room_id) AS available_rooms,\n COUNT(DISTINCT s.service_id) AS available_services\nFROM hospitality_technology.properties p\nLEFT JOIN hospitality_technology.rooms r ON r.property_id = p.property_id AND r.status = 'Available'\nLEFT JOIN hospitality_technology.services s ON s.property_id = p.property_id AND s.is_available = TRUE\nGROUP BY p.property_id, p.property_name\nHAVING COUNT(DISTINCT r.room_id) >= 10 AND COUNT(DISTINCT s.service_id) >= 10\nORDER BY available_rooms DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.passengers (\n passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger\n first_name character varying(128) NOT NULL, -- passenger's first name\n last_name character varying(128) NOT NULL, -- passenger's last name\n email character varying(128) UNIQUE, -- email address\n phone_number character varying(32) UNIQUE, -- phone number\n date_of_birth date, -- passenger's date of birth\n loyalty_program_id character varying(64), -- identifier for loyalty program membership\n created_at timestamp with time zone NOT NULL, -- time when the passenger record was created\n PRIMARY KEY (passenger_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the email and full name of passengers who are enrolled in a loyalty program, along with the date they joined, ordered by most recent sign-up."}, {"role": "assistant", "content": "SELECT email, CONCAT(first_name, ' ', last_name) AS full_name, created_at FROM transportation.passengers WHERE loyalty_program_id IS NOT NULL ORDER BY created_at DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medical_records (\n record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)\n record_date timestamp with time zone NOT NULL, -- date the record/observation was made\n chief_complaint text, -- patient's primary reason for visit\n present_illness_history text, -- detailed history of the current issue\n past_medical_history text, -- relevant past conditions/surgeries\n physical_examination_notes text, -- findings from the physical exam\n assessment text, -- doctor's assessment/diagnosis summary\n treatment_plan text, -- planned course of action\n vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (record_id)\n)\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "Can you provide a list of all medical records created by doctors for patients who are associated with 'PPO' type insurance plans? I need the record ID, patient ID, doctor ID, record date, and insurance plan name."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.doctor_id, mr.record_date, ip.plan_name\nFROM healthcare.medical_records mr\nJOIN healthcare.insurance_plans ip ON mr.patient_id IS NOT NULL -- placeholder JOIN, fix below if you have a patient-insurance mapping table\nWHERE ip.plan_type = 'PPO';"}, {"role": "user", "content": "The SQL seems off because there's no direct mapping between patients and insurance_plans in the schema. Can you adjust the query so that it only lists medical records with the plan details if the doctor creating the record has a contact phone number that matches the plan's contact_phone? Still need the same output columns."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.doctor_id, mr.record_date, ip.plan_name\nFROM healthcare.medical_records mr\nJOIN healthcare.insurance_plans ip ON mr.doctor_id IS NOT NULL -- placeholder JOIN, fix below if you have a doctors table with contact_phone\nWHERE ip.plan_type = 'PPO' AND ip.contact_phone IS NOT NULL;"}, {"role": "user", "content": "Actually, please sort the results by record_date in descending order and return only the latest 20 records."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.doctor_id, mr.record_date, ip.plan_name\nFROM healthcare.medical_records mr\nJOIN healthcare.insurance_plans ip ON mr.doctor_id IS NOT NULL -- placeholder JOIN, fix below if you have a doctors table with contact_phone\nWHERE ip.plan_type = 'PPO' AND ip.contact_phone IS NOT NULL\nORDER BY mr.record_date DESC\nLIMIT 20;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE blockchain.nodes ( node_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )\n", "conversations": [{"role": "user", "content": "Show me pairs of node_id and node_id for nodes that share the same ip_address but have different port numbers."}, {"role": "assistant", "content": "SELECT n1.node_id AS node_id1, n2.node_id AS node_id2, n1.ip_address, n1.port AS port1, n2.port AS port2 FROM blockchain.nodes n1 JOIN blockchain.nodes n2 ON n1.ip_address = n2.ip_address WHERE n1.node_id < n2.node_id AND n1.port <> n2.port;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address.text, city.text, state.text, zip_code.text, country.text, email.text, phone_number.text, created_at.timestamp, status.text, risk_profile.text )\n", "conversations": [{"role": "user", "content": "Calculate the average age of customers grouped by risk_profile."}, {"role": "assistant", "content": "SELECT risk_profile, AVG(EXTRACT(YEAR FROM AGE(current_date, date_of_birth)))::numeric(5,2) AS average_age, COUNT(*) AS customer_count\nFROM financial_services.customers\nGROUP BY risk_profile;"}, {"role": "user", "content": "Exclude risk profiles that have fewer than 50 customers."}, {"role": "assistant", "content": "SELECT risk_profile, AVG(EXTRACT(YEAR FROM AGE(current_date, date_of_birth)))::numeric(5,2) AS average_age, COUNT(*) AS customer_count\nFROM financial_services.customers\nGROUP BY risk_profile\nHAVING COUNT(*) >= 50;"}, {"role": "user", "content": "Sort the result by average_age ascending."}, {"role": "assistant", "content": "SELECT risk_profile, AVG(EXTRACT(YEAR FROM AGE(current_date, date_of_birth)))::numeric(5,2) AS average_age, COUNT(*) AS customer_count\nFROM financial_services.customers\nGROUP BY risk_profile\nHAVING COUNT(*) >= 50\nORDER BY average_age ASC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients (\n patient_id character varying(64) NOT NULL, -- unique identifier for the patient\n first_name character varying(100) NOT NULL, -- patient's first name\n last_name character varying(100) NOT NULL, -- patient's last name\n date_of_birth date NOT NULL, -- patient's date of birth\n gender character varying(10), -- patient's gender (e.g., Male, Female, Other)\n address text, -- patient's home address\n phone_number character varying(20), -- patient's phone number\n email character varying(128) UNIQUE, -- patient's email address\n emergency_contact_name character varying(200), -- name of emergency contact\n emergency_contact_phone character varying(20), -- phone number of emergency contact\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (patient_id)\n)\nCREATE TABLE healthcare.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table\n appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment\n duration_minutes integer NOT NULL, -- expected duration in minutes\n reason text, -- reason for the visit\n status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show\n location_id character varying(64), -- FK to a potential locations/clinics table\n notes text, -- notes related to scheduling\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE healthcare.medical_records (\n record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)\n record_date timestamp with time zone NOT NULL, -- date the record/observation was made\n chief_complaint text, -- patient's primary reason for visit\n present_illness_history text, -- detailed history of the current issue\n past_medical_history text, -- relevant past conditions/surgeries\n physical_examination_notes text, -- findings from the physical exam\n assessment text, -- doctor's assessment/diagnosis summary\n treatment_plan text, -- planned course of action\n vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (record_id)\n)\n", "conversations": [{"role": "user", "content": "List each patient's first and last name along with their total number of appointments in 2024."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nLEFT JOIN healthcare.appointments a\n ON p.patient_id = a.patient_id\n AND a.appointment_time BETWEEN '2024-01-01' AND '2024-12-31'\nGROUP BY p.first_name, p.last_name;"}, {"role": "user", "content": "Now exclude all 'Cancelled' appointments from the count."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nLEFT JOIN healthcare.appointments a\n ON p.patient_id = a.patient_id\n AND a.appointment_time BETWEEN '2024-01-01' AND '2024-12-31'\n AND a.status <> 'Cancelled'\nGROUP BY p.first_name, p.last_name;"}, {"role": "user", "content": "Also, only show patients who have more than 2 appointments and sort the result by appointment_count in descending order."}, {"role": "assistant", "content": "SELECT p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nLEFT JOIN healthcare.appointments a\n ON p.patient_id = a.patient_id\n AND a.appointment_time BETWEEN '2024-01-01' AND '2024-12-31'\n AND a.status <> 'Cancelled'\nGROUP BY p.first_name, p.last_name\nHAVING COUNT(a.appointment_id) > 2\nORDER BY appointment_count DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Find all pairs of lawyers who work for the same firm, showing each lawyer's first_name, last_name, email, and firm_id."}, {"role": "assistant", "content": "SELECT l1.first_name AS lawyer1_first_name,\n l1.last_name AS lawyer1_last_name,\n l1.email AS lawyer1_email,\n l2.first_name AS lawyer2_first_name,\n l2.last_name AS lawyer2_last_name,\n l2.email AS lawyer2_email,\n l1.firm_id\nFROM legal_services.lawyers l1\nJOIN legal_services.lawyers l2\n ON l1.firm_id = l2.firm_id\n AND l1.lawyer_id < l2.lawyer_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text )\n", "conversations": [{"role": "user", "content": "List the message subjects for all notifications sent via the 'Push' channel that have a 'Sent' status."}, {"role": "assistant", "content": "SELECT message_subject FROM government_services.notifications WHERE channel = 'Push' AND status = 'Sent';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.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 )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the policy number, start date, end date, product name, and product type for all policies."}, {"role": "assistant", "content": "SELECT T1.policy_number, T1.start_date, T1.end_date, T2.product_name, T2.product_type FROM insurance.policies AS T1 JOIN insurance.insurance_products AS T2 ON T1.product_id = T2.product_id"}, {"role": "user", "content": "Okay, now only show policies that started after '2023-01-01'."}, {"role": "assistant", "content": "SELECT T1.policy_number, T1.start_date, T1.end_date, T2.product_name, T2.product_type FROM insurance.policies AS T1 JOIN insurance.insurance_products AS T2 ON T1.product_id = T2.product_id WHERE T1.start_date > '2023-01-01'"}, {"role": "user", "content": "Also include the customer's first and last name in the results."}, {"role": "assistant", "content": "SELECT T3.first_name, T3.last_name, T1.policy_number, T1.start_date, T1.end_date, T2.product_name, T2.product_type FROM insurance.policies AS T1 JOIN insurance.insurance_products AS T2 ON T1.product_id = T2.product_id JOIN insurance.customers AS T3 ON T1.customer_id = T3.customer_id WHERE T1.start_date > '2023-01-01'"}, {"role": "user", "content": "Sort the results by policy start date descending and limit to the top 10."}, {"role": "assistant", "content": "SELECT T3.first_name, T3.last_name, T1.policy_number, T1.start_date, T1.end_date, T2.product_name, T2.product_type FROM insurance.policies AS T1 JOIN insurance.insurance_products AS T2 ON T1.product_id = T2.product_id JOIN insurance.customers AS T3 ON T1.customer_id = T3.customer_id WHERE T1.start_date > '2023-01-01' ORDER BY T1.start_date DESC LIMIT 10"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )\nCREATE TABLE trading_platform.wallets ( wallet_id text PRIMARY KEY, user_id text, address text, private_key text, created_at timestamp )\nCREATE TABLE trading_platform.orders ( order_id text PRIMARY KEY, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades ( trade_id text PRIMARY KEY, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp )\nCREATE TABLE trading_platform.utxos ( utxo_id text PRIMARY KEY, transaction_id text, output_index int, address text, amount numeric, spent boolean )\nCREATE TABLE trading_platform.dapps ( dapp_id text PRIMARY KEY, name text, description text, url text )\nCREATE TABLE trading_platform.peers ( peer_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id text PRIMARY KEY, asset_id text, key text, value text )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id text PRIMARY KEY, user_id text, status text, reviewed_at timestamp )\nCREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )\nCREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me each completed order with order_id, the username of the user who placed it, asset_id, quantity, and price."}, {"role": "assistant", "content": "SELECT\n o.order_id,\n u.username,\n o.asset_id,\n o.quantity,\n o.price\nFROM trading_platform.orders o\nJOIN trading_platform.users u ON o.user_id = u.user_id\nWHERE o.status = 'completed';"}, {"role": "user", "content": "Also include the total executed quantity from trades for each order."}, {"role": "assistant", "content": "SELECT\n o.order_id,\n u.username,\n o.asset_id,\n o.quantity,\n o.price,\n COALESCE(t.total_executed, 0) AS executed_quantity\nFROM trading_platform.orders o\nJOIN trading_platform.users u ON o.user_id = u.user_id\nLEFT JOIN (\n SELECT order_id, SUM(quantity) AS total_executed\n FROM trading_platform.trades\n GROUP BY order_id\n) t ON o.order_id = t.order_id\nWHERE o.status = 'completed';"}, {"role": "user", "content": "Only include orders where some trades have occurred and calculate remaining_unfilled as order.quantity minus executed_quantity."}, {"role": "assistant", "content": "SELECT\n o.order_id,\n u.username,\n o.asset_id,\n o.quantity,\n t.total_executed AS executed_quantity,\n (o.quantity - t.total_executed) AS remaining_unfilled\nFROM trading_platform.orders o\nJOIN trading_platform.users u ON o.user_id = u.user_id\nJOIN (\n SELECT order_id, SUM(quantity) AS total_executed\n FROM trading_platform.trades\n GROUP BY order_id\n) t ON o.order_id = t.order_id\nWHERE o.status = 'completed'\n AND t.total_executed > 0;"}, {"role": "user", "content": "Limit to the top 5 orders by highest remaining_unfilled quantity."}, {"role": "assistant", "content": "SELECT\n o.order_id,\n u.username,\n o.asset_id,\n o.quantity,\n t.total_executed AS executed_quantity,\n (o.quantity - t.total_executed) AS remaining_unfilled\nFROM trading_platform.orders o\nJOIN trading_platform.users u ON o.user_id = u.user_id\nJOIN (\n SELECT order_id, SUM(quantity) AS total_executed\n FROM trading_platform.trades\n GROUP BY order_id\n) t ON o.order_id = t.order_id\nWHERE o.status = 'completed'\nORDER BY (o.quantity - t.total_executed) DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "Please list the contact phone number and website for each insurance plan."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, contact_phone, website FROM healthcare.insurance_plans;"}, {"role": "user", "content": "Show only the plans where the website contains '.gov'."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, contact_phone, website FROM healthcare.insurance_plans WHERE website LIKE '%.gov%';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.comments (\n comment_id character varying(64) NOT NULL, -- unique identifier for the comment\n post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)\n user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)\n parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)\n content text NOT NULL, -- textual content of the comment\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit\n PRIMARY KEY (comment_id)\n)\nCREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, hashtag_id character varying(64) NOT NULL, PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) )\nCREATE TABLE social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\nCREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )\nCREATE TABLE social_media.conversation_participants (\n participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry\n conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)\n user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)\n joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation\n last_read_at timestamp, -- timestamp indicating up to when the user has read messages\n PRIMARY KEY (participant_id),\n CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times\n)\nCREATE TABLE social_media.notifications ( notification_id.text, recipient_user_id.text, sender_user_id.text, notification_type.text, target_entity_id.text, target_entity_type.text, created_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Which users have sent messages in private conversations? Please show their usernames and the conversation IDs."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, m.conversation_id\nFROM social_media.messages m\nJOIN social_media.users u ON m.sender_user_id = u.user_id\nJOIN social_media.conversations c ON m.conversation_id = c.conversation_id\nWHERE c.is_group_chat = false;"}, {"role": "user", "content": "Include the time of the first message they sent in each conversation."}, {"role": "assistant", "content": "SELECT u.username, m.conversation_id, MIN(m.sent_at) AS first_message_time\nFROM social_media.messages m\nJOIN social_media.users u ON m.sender_user_id = u.user_id\nJOIN social_media.conversations c ON m.conversation_id = c.conversation_id\nWHERE c.is_group_chat = false\nGROUP BY u.username, m.conversation_id;"}, {"role": "user", "content": "Can you also show the total number of messages each user has sent in each private conversation?"}, {"role": "assistant", "content": "SELECT u.username, m.conversation_id, COUNT(*) AS message_count, MIN(m.sent_at) AS first_message_time\nFROM social_media.messages m\nJOIN social_media.users u ON m.sender_user_id = u.user_id\nJOIN social_media.conversations c ON m.conversation_id = c.conversation_id\nWHERE c.is_group_chat = false\nGROUP BY u.username, m.conversation_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.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 )\n", "conversations": [{"role": "user", "content": "List all payments processed in USD, showing payment_id, guest_id, amount, and payment_timestamp."}, {"role": "assistant", "content": "SELECT payment_id,\n guest_id,\n amount,\n payment_timestamp\nFROM hospitality_technology.payments\nWHERE currency_code = 'USD';"}, {"role": "user", "content": "Actually, only include those with amount greater than 1000."}, {"role": "assistant", "content": "SELECT payment_id,\n guest_id,\n amount,\n payment_timestamp\nFROM hospitality_technology.payments\nWHERE currency_code = 'USD'\n AND amount > 1000;"}, {"role": "user", "content": "Also, order the results by amount descending and limit to the top 5."}, {"role": "assistant", "content": "SELECT payment_id,\n guest_id,\n amount,\n payment_timestamp\nFROM hospitality_technology.payments\nWHERE currency_code = 'USD'\n AND amount > 1000\nORDER BY amount DESC\nLIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )\nCREATE TABLE trading_platform.metadata (\n metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata\n asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with\n key character varying(128) NOT NULL, -- key of the metadata\n value text NOT NULL, -- value of the metadata\n PRIMARY KEY (metadata_id)\n)\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )\nCREATE TABLE trading_platform.logs (\n log_id character varying(64) NOT NULL, -- unique identifier for the log entry\n user_id character varying(64), -- identifier of the user associated with the log entry\n action character varying(128) NOT NULL, -- action performed\n details text NOT NULL, -- details of the action\n logged_at timestamp NOT NULL, -- time when the log entry was created\n PRIMARY KEY (log_id)\n)\nCREATE TABLE trading_platform.notifications ( notification_id.text, user_id.text, message.text, sent_at.timestamp, read_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the username and the total number of log entries for each user who has logged any action."}, {"role": "assistant", "content": "SELECT T1.username, COUNT(T2.log_id) FROM users AS T1 JOIN logs AS T2 ON T1.user_id = T2.user_id GROUP BY T1.username;"}, {"role": "user", "content": "Refine this to only include users whose log entries contain the word 'error' and who have more than 5 such log entries."}, {"role": "assistant", "content": "SELECT T1.username, COUNT(T2.log_id) FROM users AS T1 JOIN logs AS T2 ON T1.user_id = T2.user_id WHERE T2.details LIKE '%error%' GROUP BY T1.username HAVING COUNT(T2.log_id) > 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\n", "conversations": [{"role": "user", "content": "List all customers who have two policies with overlapping coverage periods and show both policy numbers along with the overlap start and end dates."}, {"role": "assistant", "content": "SELECT p1.customer_id, p1.policy_number AS policy_number1, p2.policy_number AS policy_number2, GREATEST(p1.start_date, p2.start_date) AS overlap_start, LEAST(p1.end_date, p2.end_date) AS overlap_end FROM insurance.policies p1 JOIN insurance.policies p2 ON p1.customer_id = p2.customer_id AND p1.policy_id < p2.policy_id WHERE p1.start_date <= p2.end_date AND p2.start_date <= p1.end_date;"}, {"role": "user", "content": "Actually, I only want overlapping policies where both policies are currently active."}, {"role": "assistant", "content": "SELECT p1.customer_id, p1.policy_number AS policy_number1, p2.policy_number AS policy_number2, GREATEST(p1.start_date, p2.start_date) AS overlap_start, LEAST(p1.end_date, p2.end_date) AS overlap_end FROM insurance.policies p1 JOIN insurance.policies p2 ON p1.customer_id = p2.customer_id AND p1.policy_id < p2.policy_id WHERE p1.status = 'active' AND p2.status = 'active' AND p1.start_date <= p2.end_date AND p2.start_date <= p1.end_date;"}, {"role": "user", "content": "Also include the number of days of overlap as overlap_days."}, {"role": "assistant", "content": "SELECT p1.customer_id, p1.policy_number AS policy_number1, p2.policy_number AS policy_number2, GREATEST(p1.start_date, p2.start_date) AS overlap_start, LEAST(p1.end_date, p2.end_date) AS overlap_end, (LEAST(p1.end_date, p2.end_date) - GREATEST(p1.start_date, p2.start_date)) AS overlap_days FROM insurance.policies p1 JOIN insurance.policies p2 ON p1.customer_id = p2.customer_id AND p1.policy_id < p2.policy_id WHERE p1.status = 'active' AND p2.status = 'active' AND p1.start_date <= p2.end_date AND p2.start_date <= p1.end_date;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\nCREATE TABLE legal_services.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.text, created_at.timestamp )\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all clients who have appointments with lawyers from law firms located at the same address as their own company. I want to see the client's first and last name, company name, the lawyer's name, the law firm's name, and the shared address."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, c.company_name, l.first_name AS lawyer_first_name, l.last_name AS lawyer_last_name, f.firm_name, f.address\nFROM legal_services.clients c\nJOIN legal_services.appointments a ON c.client_id = a.client_id\nJOIN legal_services.lawyers l ON a.lawyer_id = l.lawyer_id\nJOIN legal_services.law_firms f ON l.firm_id = f.firm_id\nWHERE c.address = f.address;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar )\nCREATE TABLE nft_holders ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk varchar )\nCREATE TABLE nft_holder_historical ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk integer )\nCREATE TABLE sui_coins_metadata ( object_id varchar, coin_type varchar, status varchar, decimals bigint, description varchar, icon_url varchar, symbol varchar, name varchar )\nCREATE TABLE nft_metadata ( blockchain varchar, contract_address varchar, token_id varchar, contract_name varchar, erc_type varchar, amount bigint, minter varchar, owner varchar, mint_block_number bigint, mint_time bigint, mint_transaction_hash varchar, mint_price varchar, token_uri varchar, metadata varchar, name varchar, image_uri varchar, traits varchar, updated_at bigint, status varchar, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar, pk integer )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\nCREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\nCREATE TABLE mud_holesky_redstone ( address varchar, table_id varchar, key_bytes varchar, key0 varchar, key1 varchar, static_data varchar, encoded_lengths varchar, dynamic_data varchar, is_deleted boolean, block_number bigint, log_index bigint )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )\n", "conversations": [{"role": "user", "content": "Show all ERC20 token approvals that happened between block numbers 18000000 and 18500000, including the contract address and number of approvals per contract."}, {"role": "assistant", "content": "SELECT contract_address, COUNT(*) AS approval_count FROM erc20_approval WHERE block_number BETWEEN 18000000 AND 18500000 GROUP BY contract_address;"}, {"role": "user", "content": "Include the symbol and name for each ERC20 token by joining with token_metas."}, {"role": "assistant", "content": "SELECT ea.contract_address, COUNT(*) AS approval_count, tm.symbol, tm.name FROM erc20_approval ea LEFT JOIN token_metas tm ON ea.contract_address = tm.contract_address WHERE ea.block_number BETWEEN 18000000 AND 18500000 GROUP BY ea.contract_address, tm.symbol, tm.name;"}, {"role": "user", "content": "Now only show tokens which have more than 100 approvals in this block range."}, {"role": "assistant", "content": "SELECT ea.contract_address, COUNT(*) AS approval_count, tm.symbol, tm.name FROM erc20_approval ea LEFT JOIN token_metas tm ON ea.contract_address = tm.contract_address WHERE ea.block_number BETWEEN 18000000 AND 18500000 GROUP BY ea.contract_address, tm.symbol, tm.name HAVING COUNT(*) > 100;"}, {"role": "user", "content": "Order the results by approval_count descending and limit to the top 5."}, {"role": "assistant", "content": "SELECT ea.contract_address, COUNT(*) AS approval_count, tm.symbol, tm.name FROM erc20_approval ea LEFT JOIN token_metas tm ON ea.contract_address = tm.contract_address WHERE ea.block_number BETWEEN 18000000 AND 18500000 GROUP BY ea.contract_address, tm.symbol, tm.name HAVING COUNT(*) > 100 ORDER BY approval_count DESC LIMIT 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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) )\n", "conversations": [{"role": "user", "content": "Which token symbols have the highest number of addresses buying them on the Ethereum chain? Show the top 3 symbols, their total address_amount, and narrative."}, {"role": "assistant", "content": "SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses\nFROM smart_money_token_inflow\nWHERE type = 1 AND chain = 'Ethereum'\nGROUP BY token_symbol, narrative\nORDER BY total_buying_addresses DESC\nLIMIT 3;"}, {"role": "user", "content": "I got incorrect results. I only want results where the summed address_amount is at least 10."}, {"role": "assistant", "content": "SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses\nFROM smart_money_token_inflow\nWHERE type = 1 AND chain = 'Ethereum'\nGROUP BY token_symbol, narrative\nHAVING SUM(address_amount) >= 10\nORDER BY total_buying_addresses DESC\nLIMIT 3;"}, {"role": "user", "content": "Please add the total usd_value spent on buying each of these tokens."}, {"role": "assistant", "content": "SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses, SUM(usd_value) AS total_buy_usd_value\nFROM smart_money_token_inflow\nWHERE type = 1 AND chain = 'Ethereum'\nGROUP BY token_symbol, narrative\nHAVING SUM(address_amount) >= 10\nORDER BY total_buying_addresses DESC\nLIMIT 3;"}, {"role": "user", "content": "Also include the average price (avg_price) for each token."}, {"role": "assistant", "content": "SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses, SUM(usd_value) AS total_buy_usd_value, AVG(avg_price) AS average_price\nFROM smart_money_token_inflow\nWHERE type = 1 AND chain = 'Ethereum'\nGROUP BY token_symbol, narrative\nHAVING SUM(address_amount) >= 10\nORDER BY total_buying_addresses DESC\nLIMIT 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.lawyers ( lawyer_id.text, first_name.text, last_name.text, bar_number.text, firm_id.text, email.text, phone.text, specialization.text, hire_date.timestamp, is_partner.boolean )\nCREATE TABLE legal_services.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all invoices that were paid within 7 days of their issue date. Show invoice number, issue date, payment date, and total amount."}, {"role": "assistant", "content": "SELECT invoice_number, issue_date, payment_date, total_amount FROM legal_services.invoices WHERE status = 'Paid' AND payment_date IS NOT NULL AND (payment_date::DATE - issue_date) <= 7;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\nCREATE TABLE legal_services.invoices ( invoice_id.text, invoice_number.text, client_id.text, case_id.text, issue_date.date, due_date.date, total_amount.numeric, amount_paid.numeric, status.text, payment_date.timestamp, notes.text, created_at.timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me case numbers, names, and related invoice numbers."}, {"role": "assistant", "content": "SELECT T1.case_number, T1.case_name, T2.invoice_number FROM legal_services.cases AS T1 JOIN legal_services.invoices AS T2 ON T1.case_id = T2.case_id;"}, {"role": "user", "content": "Only include cases that are currently 'Open'."}, {"role": "assistant", "content": "SELECT T1.case_number, T1.case_name, T2.invoice_number FROM legal_services.cases AS T1 JOIN legal_services.invoices AS T2 ON T1.case_id = T2.case_id WHERE T1.status = 'Open';"}, {"role": "user", "content": "Also, only show invoices that have a 'Paid' status."}, {"role": "assistant", "content": "SELECT T1.case_number, T1.case_name, T2.invoice_number FROM legal_services.cases AS T1 JOIN legal_services.invoices AS T2 ON T1.case_id = T2.case_id WHERE T1.status = 'Open' AND T2.status = 'Paid';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_token_performance ( token_address character varying(100) NOT NULL, token_symbol character varying(100), pnl numeric(38,2), net_flow numeric(38,2), avg_cost numeric(38,16), price double precision, realized_ratio numeric(10,2), roi numeric(10,2), chain character varying(100) )\n", "conversations": [{"role": "user", "content": "Which token on the Ethereum chain had the highest realized ratio last quarter? Show the symbol, realized ratio, and ROI."}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 1;"}, {"role": "user", "content": "Can you show the top 3 tokens by realized ratio instead of just the top one?"}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 3;"}, {"role": "user", "content": "Include their average cost in the result."}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi, avg_cost FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 3;"}, {"role": "user", "content": "Also show their current price."}, {"role": "assistant", "content": "SELECT token_symbol, realized_ratio, roi, avg_cost, price FROM smart_money_token_performance WHERE chain = 'Ethereum' AND date_trunc('quarter', CURRENT_DATE) - interval '1 quarter' = date_trunc('quarter', now()) ORDER BY realized_ratio DESC LIMIT 3;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.claims ( claim_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, incident_date timestamp NOT NULL, reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text NOT NULL, estimated_loss numeric(15, 2), status character varying(30) NOT NULL, settlement_amount numeric(15, 2), settlement_date date, claim_handler_id character varying(64), police_report_number character varying(100), PRIMARY KEY (claim_id) )\nCREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\n", "conversations": [{"role": "user", "content": "Show all policies that started before January 1, 2022, including policy_id, policy_number, start_date, and status."}, {"role": "assistant", "content": "SELECT policy_id, policy_number, start_date, status\nFROM insurance.policies\nWHERE start_date < '2022-01-01';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )\n", "conversations": [{"role": "user", "content": "List addresses on the 'Ethereum' chain that have an ROI greater than 5 and a profit greater than $1000. Show their address, profit, ROI, and realized ratio."}, {"role": "assistant", "content": "SELECT address, profit, roi, realized_ratio FROM smart_money_profit WHERE chain = 'Ethereum' AND roi > 5 AND profit > 1000"}, {"role": "user", "content": "Can you order these addresses by their profit in descending order?"}, {"role": "assistant", "content": "SELECT address, profit, roi, realized_ratio FROM smart_money_profit WHERE chain = 'Ethereum' AND roi > 5 AND profit > 1000 ORDER BY profit DESC"}, {"role": "user", "content": "Only show addresses whose last trade time is in 2024."}, {"role": "assistant", "content": "SELECT address, profit, roi, realized_ratio FROM smart_money_profit WHERE chain = 'Ethereum' AND roi > 5 AND profit > 1000 AND last_trade_time LIKE '2024%' ORDER BY profit DESC"}, {"role": "user", "content": "Include the rank of these addresses in the output and show only the top 5 results."}, {"role": "assistant", "content": "SELECT address, profit, roi, realized_ratio, rank FROM smart_money_profit WHERE chain = 'Ethereum' AND roi > 5 AND profit > 1000 AND last_trade_time LIKE '2024%' ORDER BY profit DESC LIMIT 5"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts (\n contract_id character varying(64) NOT NULL, -- unique identifier for the contract\n address character varying(128) NOT NULL, -- address of the deployed contract\n abi text NOT NULL, -- application binary interface of the contract\n bytecode text NOT NULL, -- bytecode of the contract\n deployer_address character varying(128) NOT NULL, -- address of the deployer\n deployed_at timestamp NOT NULL, -- time when the contract was deployed\n network_id character varying(64) NOT NULL, -- identifier of the network where the contract is deployed\n status character varying(32) NOT NULL, -- status of the contract (e.g., active, deprecated)\n PRIMARY KEY (contract_id)\n)\nCREATE TABLE web3.transactions (\n transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction\n from_address character varying(128) NOT NULL, -- address of the sender\n to_address character varying(128), -- address of the receiver (can be null for contract deployment)\n value numeric(38,14) NOT NULL, -- value transferred\n gas_used integer NOT NULL, -- amount of gas used by the transaction\n gas_price numeric(38,14) NOT NULL, -- price of gas at the time of the transaction\n block_number integer NOT NULL, -- block number containing the transaction\n timestamp timestamp NOT NULL, -- time when the transaction was mined\n input_data text, -- input data of the transaction (can be null)\n status character varying(32) NOT NULL, -- status of the transaction (e.g., success, failed)\n nonce integer NOT NULL, -- nonce of the sender at the time of the transaction\n PRIMARY KEY (transaction_id)\n)\nCREATE TABLE web3.wallets (\n wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet\n user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet\n address character varying(128) NOT NULL, -- address of the wallet\n private_key text NOT NULL, -- private key of the wallet\n created_at timestamp NOT NULL, -- time when the wallet was created\n PRIMARY KEY (wallet_id)\n)\n", "conversations": [{"role": "user", "content": "For each user with at least two wallets, calculate the average time difference in hours between consecutive wallet creations. Return user_id and avg_diff_hours."}, {"role": "assistant", "content": "SELECT user_id, AVG(EXTRACT(EPOCH FROM (created_at - prev_created)) / 3600) AS avg_diff_hours FROM (SELECT user_id, created_at, LAG(created_at) OVER (PARTITION BY user_id ORDER BY created_at) AS prev_created FROM web3.wallets) t WHERE prev_created IS NOT NULL GROUP BY user_id;"}, {"role": "user", "content": "Actually, restrict the results to users whose avg_diff_hours is less than 24 hours and sort by avg_diff_hours ascending."}, {"role": "assistant", "content": "WITH diffs AS (SELECT user_id, EXTRACT(EPOCH FROM (created_at - prev_created)) / 3600 AS diff_hours FROM (SELECT user_id, created_at, LAG(created_at) OVER (PARTITION BY user_id ORDER BY created_at) AS prev_created FROM web3.wallets) sub WHERE prev_created IS NOT NULL) SELECT user_id, AVG(diff_hours) AS avg_diff_hours FROM diffs GROUP BY user_id HAVING AVG(diff_hours) < 24 ORDER BY avg_diff_hours;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\n", "conversations": [{"role": "user", "content": "Count the total number of chronic diagnoses for each code_type."}, {"role": "assistant", "content": "SELECT\n code_type,\n COUNT(*) AS chronic_diagnosis_count\nFROM healthcare.diagnoses\nWHERE is_chronic = TRUE\nGROUP BY code_type;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all active clients with their client_id, first_name, last_name, and the website of their law firm, matching on company_name = firm_name."}, {"role": "assistant", "content": "SELECT cl.client_id,\n cl.first_name,\n cl.last_name,\n lf.website\nFROM legal_services.clients cl\nJOIN legal_services.law_firms lf ON cl.company_name = lf.firm_name\nWHERE cl.status = 'active';"}, {"role": "user", "content": "Include only those law firms founded after 2010-01-01 and exclude any with no website."}, {"role": "assistant", "content": "SELECT cl.client_id,\n cl.first_name,\n cl.last_name,\n lf.website\nFROM legal_services.clients cl\nJOIN legal_services.law_firms lf ON cl.company_name = lf.firm_name\nWHERE cl.status = 'active'\n AND lf.founded_date > '2010-01-01'\n AND lf.website IS NOT NULL;"}, {"role": "user", "content": "Also show the number of cases each client has opened."}, {"role": "assistant", "content": "SELECT cl.client_id,\n cl.first_name,\n cl.last_name,\n lf.website,\n COUNT(c.case_id) AS case_count\nFROM legal_services.clients cl\nJOIN legal_services.law_firms lf ON cl.company_name = lf.firm_name\nLEFT JOIN legal_services.cases c ON cl.client_id = c.client_id\nWHERE cl.status = 'active'\n AND lf.founded_date > '2010-01-01'\n AND lf.website IS NOT NULL\nGROUP BY cl.client_id, cl.first_name, cl.last_name, lf.website;"}, {"role": "user", "content": "Finally, sort the results by case count descending and limit to the top 20."}, {"role": "assistant", "content": "SELECT cl.client_id,\n cl.first_name,\n cl.last_name,\n lf.website,\n COUNT(c.case_id) AS case_count\nFROM legal_services.clients cl\nJOIN legal_services.law_firms lf ON cl.company_name = lf.firm_name\nLEFT JOIN legal_services.cases c ON cl.client_id = c.client_id\nWHERE cl.status = 'active'\n AND lf.founded_date > '2010-01-01'\n AND lf.website IS NOT NULL\nGROUP BY cl.client_id, cl.first_name, cl.last_name, lf.website\nORDER BY case_count DESC\nLIMIT 20;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\n", "conversations": [{"role": "user", "content": "Show the names, symbols, and types of all assets whose symbol starts with the letter 'B'."}, {"role": "assistant", "content": "SELECT name, symbol, type\nFROM trading_platform.assets\nWHERE symbol LIKE 'B%';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.insurance_products ( product_id text, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\nCREATE TABLE insurance.claim_documents ( document_id text, claim_id text, document_type text, file_name text, file_path text, file_size_bytes integer, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "What is the total amount paid across all premium payments for payments marked as 'Failed'?"}, {"role": "assistant", "content": "SELECT sum(amount_paid) FROM insurance.premium_payments WHERE status = 'Failed';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id character varying(64) NOT NULL, reservation_id character varying(64), guest_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, staff_id_ordered character varying(64), staff_id_delivered character varying(64), order_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, delivery_timestamp timestamp with time zone, quantity integer NOT NULL DEFAULT 1, unit_price numeric(10, 2) NOT NULL, total_price numeric(12, 2) NOT NULL, status character varying(50) NOT NULL, notes text, bill_id character varying(64), PRIMARY KEY (order_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (service_id) REFERENCES hospitality_technology.services(service_id), FOREIGN KEY (staff_id_ordered) REFERENCES hospitality_technology.staff(staff_id), FOREIGN KEY (staff_id_delivered) REFERENCES hospitality_technology.staff(staff_id) )\nCREATE TABLE hospitality_technology.payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Which room types have a base rate above 250 USD, and what are their maximum occupancies?"}, {"role": "assistant", "content": "SELECT room_type_id, type_name, base_rate, max_occupancy\nFROM hospitality_technology.room_types\nWHERE base_rate > 250;"}, {"role": "user", "content": "For these room types, can you also add the property_id?"}, {"role": "assistant", "content": "SELECT room_type_id, property_id, type_name, base_rate, max_occupancy\nFROM hospitality_technology.room_types\nWHERE base_rate > 250;"}, {"role": "user", "content": "Now join this with the payments table to show the total payment amount for each property where such a room type exists."}, {"role": "assistant", "content": "SELECT r.property_id, SUM(p.amount) AS total_payment_amount\nFROM hospitality_technology.room_types r\nJOIN hospitality_technology.payments p ON r.property_id = p.reservation_id\nWHERE r.base_rate > 250\nGROUP BY r.property_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean )\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.notifications ( notification_id.text, recipient_user_id.text, sender_user_id.text, notification_type.text, target_entity_id.text, target_entity_type.text, created_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "List usernames of users who participate in any group chat and also have a private profile. Include the name of the group chat."}, {"role": "assistant", "content": "SELECT DISTINCT\n U.username,\n C.group_name\nFROM\n social_media.users AS U\nJOIN\n social_media.conversation_participants AS CP ON U.user_id = CP.user_id\nJOIN\n social_media.conversations AS C ON CP.conversation_id = C.conversation_id\nJOIN\n social_media.user_settings AS US ON U.user_id = US.user_id\nWHERE\n C.is_group_chat = TRUE AND US.private_profile = TRUE;"}, {"role": "user", "content": "Filter the results to only show users whose private profile setting was updated in the last 180 days."}, {"role": "assistant", "content": "SELECT DISTINCT\n U.username,\n C.group_name\nFROM\n social_media.users AS U\nJOIN\n social_media.conversation_participants AS CP ON U.user_id = CP.user_id\nJOIN\n\tsocial_media.conversations AS C ON CP.conversation_id = C.conversation_id\nJOIN\n social_media.user_settings AS US ON U.user_id = US.user_id\nWHERE\n C.is_group_chat = TRUE\n AND US.private_profile = TRUE\n AND US.updated_at >= NOW() - INTERVAL '180 days';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.time_entries ( entry_id text PRIMARY KEY, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable bool, is_billed bool, invoice_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the total hours spent by each lawyer on a specific case, say with case_id = 'CASE001'."}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours FROM legal_services.time_entries WHERE case_id = 'CASE001' GROUP BY lawyer_id;"}, {"role": "user", "content": "Can you also include only the entries that are billable?"}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours FROM legal_services.time_entries WHERE case_id = 'CASE001' AND is_billable = TRUE GROUP BY lawyer_id;"}, {"role": "user", "content": "Now, show only those lawyers who have logged more than 5 billable hours on this case."}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours FROM legal_services.time_entries WHERE case_id = 'CASE001' AND is_billable = TRUE GROUP BY lawyer_id HAVING SUM(hours_spent) > 5;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\nCREATE TABLE healthcare.diagnoses (\n diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry\n record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)\n diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)\n code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used\n description text, -- textual description of the diagnosis\n diagnosis_date date NOT NULL, -- date the diagnosis was made\n status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out\n is_chronic boolean DEFAULT false, -- flag for chronic conditions\n PRIMARY KEY (diagnosis_id)\n)\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )\n", "conversations": [{"role": "user", "content": "Show me all patients who have had prescriptions for a medication named 'Metformin', including their full name, prescription date, and prescribing doctor's ID."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pr.prescription_date, pr.doctor_id FROM healthcare.patients p INNER JOIN healthcare.prescriptions pr ON p.patient_id = pr.patient_id INNER JOIN healthcare.medications m ON pr.medication_id = m.medication_id WHERE m.medication_name = 'Metformin';"}, {"role": "user", "content": "Only show those prescriptions that were issued in 2024."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pr.prescription_date, pr.doctor_id FROM healthcare.patients p INNER JOIN healthcare.prescriptions pr ON p.patient_id = pr.patient_id INNER JOIN healthcare.medications m ON pr.medication_id = m.medication_id WHERE m.medication_name = 'Metformin' AND EXTRACT(YEAR FROM pr.prescription_date) = 2024;"}, {"role": "user", "content": "Include the prescription ID and dosage in the results."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pr.prescription_id, pr.dosage, pr.prescription_date, pr.doctor_id FROM healthcare.patients p INNER JOIN healthcare.prescriptions pr ON p.patient_id = pr.patient_id INNER JOIN healthcare.medications m ON pr.medication_id = m.medication_id WHERE m.medication_name = 'Metformin' AND EXTRACT(YEAR FROM pr.prescription_date) = 2024;"}, {"role": "user", "content": "I encountered an error: relation \"healthcare.medications\" does not exist. Can you fix it?"}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pr.prescription_id, pr.dosage, pr.prescription_date, pr.doctor_id FROM healthcare.patients p INNER JOIN healthcare.prescriptions pr ON p.patient_id = pr.patient_id WHERE pr.medication_id = 'Metformin' AND EXTRACT(YEAR FROM pr.prescription_date) = 2024;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\n", "conversations": [{"role": "user", "content": "Retrieve route_number, description, and distance_km for routes that have a distance greater than the average distance of all routes."}, {"role": "assistant", "content": "SELECT route_number, description, distance_km\nFROM transportation.routes\nWHERE distance_km > (\n SELECT AVG(distance_km)\n FROM transportation.routes\n);"}, {"role": "user", "content": "Actually, I only want those routes where estimated_duration_minutes is less than 120, and sort by distance_km in descending order."}, {"role": "assistant", "content": "SELECT route_number, description, distance_km\nFROM transportation.routes\nWHERE distance_km > (\n SELECT AVG(distance_km)\n FROM transportation.routes\n)\n AND estimated_duration_minutes < 120\nORDER BY distance_km DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.payments ( payment_id text, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\nCREATE TABLE government_services.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\nCREATE TABLE government_services.notifications ( notification_id text, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "Show me the first name and last name of citizens who have scheduled appointments for services offered by agencies whose agency_id starts with 'AG'. Also include the service name."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, s.service_name\nFROM government_services.appointments a\nJOIN government_services.services s ON a.service_id = s.service_id\nJOIN government_services.applications app ON a.citizen_id = app.citizen_id AND a.service_id = app.service_id\nJOIN government_services.citizens c ON a.citizen_id = c.citizen_id\nWHERE s.agency_id LIKE 'AG%';"}, {"role": "user", "content": "Only include appointments that are booked via 'Kiosk' and scheduled after July 1, 2024."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, s.service_name\nFROM government_services.appointments a\nJOIN government_services.services s ON a.service_id = s.service_id\nJOIN government_services.applications app ON a.citizen_id = app.citizen_id AND a.service_id = app.service_id\nJOIN government_services.citizens c ON a.citizen_id = c.citizen_id\nWHERE s.agency_id LIKE 'AG%'\n AND a.booking_method = 'Kiosk'\n AND a.scheduled_start_time > '2024-07-01';"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types ( room_type_id.text, property_id.text, type_name.text, description.text, base_rate.numeric, max_occupancy.integer, bed_type.text, area_sqft.numeric, amenities.text )\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id 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) )\nCREATE TABLE hospitality_technology.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\n", "conversations": [{"role": "user", "content": "Show me the list of all guests who have reservations along with the room number, room type name, and property name for each reservation."}, {"role": "assistant", "content": "SELECT g.first_name, g.last_name, r.room_number, rt.type_name AS room_type_name, p.property_name\nFROM hospitality_technology.reservations res\nJOIN hospitality_technology.guests g ON res.guest_id = g.guest_id\nLEFT JOIN hospitality_technology.rooms r ON res.room_id = r.room_id\nLEFT JOIN hospitality_technology.room_types rt ON res.room_type_id = rt.room_type_id\nJOIN hospitality_technology.properties p ON res.property_id = p.property_id;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products ( product_id text, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Find the total count of insurance products for each product type, but only include product types with more than 10 products."}, {"role": "assistant", "content": "SELECT product_type, COUNT(*) FROM insurance.insurance_products GROUP BY product_type HAVING COUNT(*) > 10;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\nCREATE TABLE government_services.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text )\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\nCREATE TABLE government_services.service_locations ( location_id text, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n application_id character varying(64), -- FK to applications table (optional)\n message_subject character varying(255),\n message_body text NOT NULL,\n channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail\n sent_at timestamp NOT NULL,\n status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read\n related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request\n related_entity_id character varying(64), -- ID of the related entity\n PRIMARY KEY (notification_id)\n)\n", "conversations": [{"role": "user", "content": "Which agencies have at least one service with a standard fee equal to zero? Show the agency name and the service name."}, {"role": "assistant", "content": "SELECT a.agency_name, s.service_name\nFROM government_services.agencies a\nJOIN government_services.services s ON a.agency_id = s.agency_id\nWHERE s.standard_fee = 0;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\n", "conversations": [{"role": "user", "content": "List the diagnosis_id, patient_id, and doctor_id for all diagnoses with status 'Pending' and is_chronic set to TRUE."}, {"role": "assistant", "content": "SELECT diagnosis_id, patient_id, doctor_id FROM healthcare.diagnoses WHERE status = 'Pending' AND is_chronic = TRUE;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products (\n product_id character varying(64) NOT NULL, -- unique identifier for the insurance product\n product_name character varying(150) NOT NULL, -- name of the insurance product (e.g., 'Comprehensive Auto Insurance')\n product_type character varying(50) NOT NULL, -- category like 'Auto', 'Home', 'Life', 'Health', 'Travel'\n description text, -- detailed description of the product\n base_premium numeric(10, 2) NOT NULL, -- starting premium before adjustments\n coverage_details text, -- details about what is covered (could be JSON or structured text)\n underwriting_rules text, -- rules used for assessing risk and eligibility\n is_active boolean NOT NULL DEFAULT true, -- whether the product is currently offered\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at timestamp,\n PRIMARY KEY (product_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve the product_id, product_name, base_premium, and created_at for all active insurance products with a base_premium greater than 1000, ordered by base_premium descending."}, {"role": "assistant", "content": "SELECT\n product_id,\n product_name,\n base_premium,\n created_at\nFROM insurance.insurance_products\nWHERE is_active = true\n AND base_premium > 1000\nORDER BY base_premium DESC;"}]} -{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.agencies (\n agency_id character varying(64) NOT NULL, -- unique identifier for the agency\n agency_name character varying(255) NOT NULL, -- full name of the government agency\n jurisdiction_level character varying(50) NOT NULL, -- e.g., Federal, State, County, City\n primary_contact_email character varying(128),\n main_phone_number character varying(32),\n website_url character varying(255),\n established_date date,\n parent_agency_id character varying(64), -- FK to self for hierarchical structure\n PRIMARY KEY (agency_id)\n)\nCREATE TABLE government_services.applications (\n application_id character varying(64) NOT NULL, -- unique identifier for the application\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n service_id character varying(64) NOT NULL, -- FK to services table\n submitted_at timestamp NOT NULL, -- time the application was submitted\n status character varying(50) NOT NULL, -- e.g., Submitted, Processing, Approved, Rejected, Pending Info\n last_updated_at timestamp NOT NULL, -- time the status or details last changed\n assigned_employee_id character varying(64), -- FK to employees table (optional)\n decision_date date, -- date when a final decision was made\n notes text, -- internal notes or citizen-provided comments\n reference_number character varying(100) UNIQUE, -- publicly visible reference number\n PRIMARY KEY (application_id)\n)\nCREATE TABLE government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\n", "conversations": [{"role": "user", "content": "List the agency names and addresses for all service locations in the state of 'Florida'."}, {"role": "assistant", "content": "SELECT a.agency_name, l.address\nFROM government_services.service_locations l\nJOIN government_services.agencies a ON l.agency_id = a.agency_id\nWHERE l.state = 'Florida';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )\n", "conversations": [{"role": "user", "content": "List the top 5 tokens by price_change_percentage_7d, showing token_symbol, narrative, and price_change_percentage_7d."}, {"role": "assistant", "content": "SELECT token_symbol, narrative, price_change_percentage_7d\nFROM token_basic_info\nORDER BY price_change_percentage_7d DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "List all patients who have insurance plans with group numbers, showing their patient IDs and the count of such plans per patient."}, {"role": "assistant", "content": "SELECT patient_id, COUNT(*) AS plan_count FROM healthcare.patient_insurance WHERE group_number IS NOT NULL GROUP BY patient_id;"}, {"role": "user", "content": "Actually, I only need patients who have more than 2 such plans."}, {"role": "assistant", "content": "SELECT patient_id, COUNT(*) AS plan_count FROM healthcare.patient_insurance WHERE group_number IS NOT NULL GROUP BY patient_id HAVING COUNT(*) > 2;"}, {"role": "user", "content": "Can you also include the earliest effective date among these plans for each patient?"}, {"role": "assistant", "content": "SELECT patient_id, COUNT(*) AS plan_count, MIN(effective_date) AS earliest_effective_date FROM healthcare.patient_insurance WHERE group_number IS NOT NULL GROUP BY patient_id HAVING COUNT(*) > 2;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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) )\n", "conversations": [{"role": "user", "content": "Which agents, along with their managers' full names, are licensed in 'TX' and are currently active?"}, {"role": "assistant", "content": "SELECT a.agent_id, a.first_name AS agent_first_name, a.last_name AS agent_last_name, m.first_name AS manager_first_name, m.last_name AS manager_last_name\nFROM insurance.agents a\nLEFT JOIN insurance.agents m ON a.manager_id = m.agent_id\nWHERE a.license_state = 'TX' AND a.status = 'Active';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.loans (\n loan_id character varying(64) NOT NULL, -- unique identifier for the loan, could be same as account_id\n account_id character varying(64) NOT NULL UNIQUE, -- link to the general account record\n loan_type character varying(50) NOT NULL, -- e.g., Mortgage, Personal, Auto, Student\n principal_amount numeric(19, 4) NOT NULL, -- original loan amount\n current_principal_balance numeric(19, 4) NOT NULL, -- remaining principal\n interest_rate numeric(6, 4) NOT NULL, -- annual interest rate\n term_months integer NOT NULL, -- loan term in months\n origination_date date NOT NULL, -- date the loan was disbursed\n maturity_date date NOT NULL, -- date the loan is due to be fully repaid\n monthly_payment numeric(12, 4), -- scheduled monthly payment amount\n collateral_description text, -- description of collateral, if secured loan\n status character varying(32) NOT NULL, -- e.g., Active, Paid Off, Defaulted\n PRIMARY KEY (loan_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve all pairs of loans for the same account where both loans are active and have different loan types. Show account_id, loan_id as loan_a, loan_type as type_a, loan_id as loan_b, and loan_type as type_b."}, {"role": "assistant", "content": "SELECT a.account_id,\n a.loan_id AS loan_a,\n a.loan_type AS type_a,\n b.loan_id AS loan_b,\n b.loan_type AS type_b\nFROM financial_services.loans a\nJOIN financial_services.loans b\n ON a.account_id = b.account_id\n AND a.loan_id < b.loan_id\nWHERE a.status = 'Active'\n AND b.status = 'Active'\n AND a.loan_type <> b.loan_type;"}, {"role": "user", "content": "Actually, only include pairs where loan_a has a higher principal_amount than loan_b."}, {"role": "assistant", "content": "SELECT a.account_id,\n a.loan_id AS loan_a,\n a.loan_type AS type_a,\n b.loan_id AS loan_b,\n b.loan_type AS type_b\nFROM financial_services.loans a\nJOIN financial_services.loans b\n ON a.account_id = b.account_id\n AND a.loan_id < b.loan_id\nWHERE a.status = 'Active'\n AND b.status = 'Active'\n AND a.loan_type <> b.loan_type\n AND a.principal_amount > b.principal_amount;"}, {"role": "user", "content": "Now restrict to accounts where the total number of active loans is at least 3."}, {"role": "assistant", "content": "SELECT a.account_id,\n a.loan_id AS loan_a,\n a.loan_type AS type_a,\n b.loan_id AS loan_b,\n b.loan_type AS type_b\nFROM financial_services.loans a\nJOIN financial_services.loans b\n ON a.account_id = b.account_id\n AND a.loan_id < b.loan_id\nWHERE a.status = 'Active'\n AND b.status = 'Active'\n AND a.loan_type <> b.loan_type\n AND a.principal_amount > b.principal_amount\n AND a.account_id IN (\n SELECT account_id\n FROM financial_services.loans\n WHERE status = 'Active'\n GROUP BY account_id\n HAVING COUNT(*) >= 3\n );"}, {"role": "user", "content": "Finally, also include the number of active loans for each account as loan_count."}, {"role": "assistant", "content": "WITH active_counts AS (\n SELECT account_id,\n COUNT(*) AS loan_count\n FROM financial_services.loans\n WHERE status = 'Active'\n GROUP BY account_id\n)\nSELECT a.account_id,\n ac.loan_count,\n a.loan_id AS loan_a,\n a.loan_type AS type_a,\n b.loan_id AS loan_b,\n b.loan_type AS type_b\nFROM financial_services.loans a\nJOIN financial_services.loans b\n ON a.account_id = b.account_id\n AND a.loan_id < b.loan_id\nJOIN active_counts ac\n ON a.account_id = ac.account_id\nWHERE a.status = 'Active'\n AND b.status = 'Active'\n AND a.loan_type <> b.loan_type\n AND a.principal_amount > b.principal_amount\n AND ac.loan_count >= 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "List each patient and the number of different insurance plans they have had. Include patient_id and plan_count."}, {"role": "assistant", "content": "SELECT patient_id, COUNT(DISTINCT plan_id) AS plan_count\nFROM healthcare.patient_insurance\nGROUP BY patient_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.fuel_logs ( fuel_log_id text, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading integer, location_id text )\n", "conversations": [{"role": "user", "content": "List all fuel log IDs along with their vehicle IDs and odometer readings for logs where the quantity is below 10."}, {"role": "assistant", "content": "SELECT fuel_log_id, vehicle_id, odometer_reading\nFROM transportation.fuel_logs\nWHERE quantity < 10;"}, {"role": "user", "content": "I received a lot of results. Please show only those logs where the unit is 'gallon'."}, {"role": "assistant", "content": "SELECT fuel_log_id, vehicle_id, odometer_reading\nFROM transportation.fuel_logs\nWHERE quantity < 10 AND unit = 'gallon';"}, {"role": "user", "content": "Now, could you also display the cost_per_unit for each of these logs and sort the output by cost_per_unit in ascending order?"}, {"role": "assistant", "content": "SELECT fuel_log_id, vehicle_id, odometer_reading, cost_per_unit\nFROM transportation.fuel_logs\nWHERE quantity < 10 AND unit = 'gallon'\nORDER BY cost_per_unit ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts ( contract_id text, address text, abi text, bytecode text, deployer_address text, deployed_at timestamp, network_id text, status text )\nCREATE TABLE web3.transactions ( transaction_id text, from_address text, to_address text, value numeric, gas_used integer, gas_price numeric, block_number integer, timestamp timestamp, input_data text, status text, nonce integer )\nCREATE TABLE web3.tokens ( token_id text, contract_address text, token_name text, token_symbol text, decimals integer, total_supply numeric )\nCREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )\nCREATE TABLE web3.users ( user_id text, username text, email text, password_hash text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all contracts and the number of different tokens associated with each contract address. Show contract_id, contract address, and token_count."}, {"role": "assistant", "content": "SELECT c.contract_id, c.address, COUNT(DISTINCT t.token_id) AS token_count\nFROM web3.contracts c\nLEFT JOIN web3.tokens t ON c.address = t.contract_address\nGROUP BY c.contract_id, c.address;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, ssn_hash character varying(128), address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state character varying(50) NOT NULL, zip_code character varying(20) NOT NULL, country character varying(50) NOT NULL DEFAULT 'USA', phone_number character varying(30), email character varying(128) UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, status character varying(20) NOT NULL DEFAULT 'Active', PRIMARY KEY (customer_id) )\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.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) )\nCREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, amount_paid numeric(12, 2) NOT NULL, payment_method character varying(50), transaction_reference character varying(128) UNIQUE, due_date date, payment_period_start date, payment_period_end date, status character varying(30) NOT NULL DEFAULT 'Completed', PRIMARY KEY (payment_id) )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, relationship character varying(50) NOT NULL, percentage_share numeric(5, 2) NOT NULL CHECK (percentage_share > 0 AND percentage_share <= 100), contact_info text, added_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (beneficiary_id), UNIQUE (policy_id, customer_id) )\n", "conversations": [{"role": "user", "content": "Show me the first and last names of all customers and the agency name of the agent who sold their policy."}, {"role": "assistant", "content": "SELECT c.first_name, c.last_name, a.agency_name\nFROM insurance.policies p\nJOIN insurance.customers c ON p.customer_id = c.customer_id\nLEFT JOIN insurance.agents a ON p.agent_id = a.agent_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.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 )\n", "conversations": [{"role": "user", "content": "Show me all documents along with the document name and type, together with both the upload_timestamp and the lawyer ID who uploaded them."}, {"role": "assistant", "content": "SELECT document_id, document_name, document_type, upload_timestamp, uploaded_by_lawyer_id FROM legal_services.documents;"}, {"role": "user", "content": "Can you filter the list to only include documents uploaded after March 1st, 2024?"}, {"role": "assistant", "content": "SELECT document_id, document_name, document_type, upload_timestamp, uploaded_by_lawyer_id FROM legal_services.documents WHERE upload_timestamp > '2024-03-01';"}, {"role": "user", "content": "Additionally, show only those documents where the document_type contains the word 'Report'."}, {"role": "assistant", "content": "SELECT document_id, document_name, document_type, upload_timestamp, uploaded_by_lawyer_id FROM legal_services.documents WHERE upload_timestamp > '2024-03-01' AND document_type ILIKE '%Report%';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\n", "conversations": [{"role": "user", "content": "Retrieve the first and last names and email addresses of all customers who registered after '2024-01-01'."}, {"role": "assistant", "content": "SELECT first_name, last_name, email FROM insurance.customers WHERE created_at > '2024-01-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "List the names and contact phone numbers of all insurance plans whose website is not null."}, {"role": "assistant", "content": "SELECT plan_name, contact_phone\nFROM healthcare.insurance_plans\nWHERE website IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\n", "conversations": [{"role": "user", "content": "Show all policies that started in 2024, including the policy_id, customer_id, and start_date. Order the results by start_date ascending."}, {"role": "assistant", "content": "SELECT policy_id, customer_id, start_date\nFROM insurance.policies\nWHERE start_date >= '2024-01-01' AND start_date < '2025-01-01'\nORDER BY start_date ASC;"}, {"role": "user", "content": "Also, include the status of each policy and only show those with premium_amount over 3000."}, {"role": "assistant", "content": "SELECT policy_id, customer_id, start_date, status\nFROM insurance.policies\nWHERE start_date >= '2024-01-01' AND start_date < '2025-01-01'\n AND premium_amount > 3000\nORDER BY start_date ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text PRIMARY KEY, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "List the first name and last name of all policy beneficiaries, along with the name of the insurance product associated with their policy."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.product_name FROM insurance.policy_beneficiaries AS T1 JOIN insurance.insurance_products AS T2 ON T1.policy_id = T2.product_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.posts (\n post_id character varying(64) NOT NULL, -- unique identifier for the post\n user_id character varying(64) NOT NULL, -- identifier of the user who created the post (FK to users.user_id)\n content text, -- textual content of the post\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of post creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last post edit\n visibility character varying(20) NOT NULL DEFAULT 'public', -- visibility ('public', 'friends', 'private')\n location_lat numeric(9,6), -- latitude of post location\n location_lon numeric(9,6), -- longitude of post location\n PRIMARY KEY (post_id)\n)\nCREATE TABLE social_media.likes (\n like_id character varying(64) NOT NULL, -- unique identifier for the like\n user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id)\n post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable)\n comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred\n PRIMARY KEY (like_id),\n CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes\n CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something\n)\nCREATE TABLE social_media.post_hashtags (\n post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link\n post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id)\n hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id)\n PRIMARY KEY (post_hashtag_id),\n CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post\n)\nCREATE TABLE social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\nCREATE TABLE social_media.conversation_participants (\n participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry\n conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)\n user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)\n joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation\n last_read_at timestamp, -- timestamp indicating up to when the user has read messages\n PRIMARY KEY (participant_id),\n CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times\n)\nCREATE TABLE social_media.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)\n sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)\n notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')\n target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)\n target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created\n read_at timestamp, -- timestamp notification was marked as read\n PRIMARY KEY (notification_id)\n)\nCREATE TABLE social_media.user_settings (\n setting_id character varying(64) NOT NULL, -- unique identifier for the setting entry\n user_id character varying(64) NOT NULL UNIQUE, -- user the settings belong to (FK to users.user_id)\n theme character varying(20) DEFAULT 'light', -- UI theme ('light', 'dark')\n email_notifications_enabled boolean DEFAULT true, -- enable/disable email notifications\n push_notifications_enabled boolean DEFAULT true, -- enable/disable push notifications\n private_profile boolean DEFAULT false, -- is the user profile private\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last setting change\n PRIMARY KEY (setting_id)\n)\n", "conversations": [{"role": "user", "content": "How many users have email_notifications_enabled set to false and private_profile set to true? Return the count."}, {"role": "assistant", "content": "SELECT COUNT(*) AS user_count\nFROM social_media.user_settings\nWHERE email_notifications_enabled = false\n AND private_profile = true;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE narrative_info ( narrative.text, top_3_coins.text, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, market_cap.numeric, volume_24h.numeric, trend_rank.numeric, token_num.numeric )\n", "conversations": [{"role": "user", "content": "List the top 10 narratives based on their market cap. Display the narrative name, market_cap, and token_num."}, {"role": "assistant", "content": "SELECT narrative, market_cap, token_num FROM narrative_info ORDER BY market_cap DESC LIMIT 10"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.in_game_items ( item_id.uuid, game_id.uuid, item_name.text, item_type.text, description.text, rarity.text, cost_currency.text, cost_amount.numeric, attributes.jsonb )\n", "conversations": [{"role": "user", "content": "List all items with rarity = 'Legendary', showing item_id, item_name, and cost_amount."}, {"role": "assistant", "content": "SELECT item_id,\n item_name,\n cost_amount\nFROM gaming_technology.in_game_items\nWHERE rarity = 'Legendary';"}, {"role": "user", "content": "Now find games where the average cost_amount of those legendary items exceeds 1000. Return game_id and the average cost."}, {"role": "assistant", "content": "SELECT game_id,\n AVG(cost_amount) AS avg_legendary_cost\nFROM gaming_technology.in_game_items\nWHERE rarity = 'Legendary'\nGROUP BY game_id\nHAVING AVG(cost_amount) > 1000;"}, {"role": "user", "content": "Show all the legendary items in those games alongside the computed average cost."}, {"role": "assistant", "content": "WITH high_avg AS (\n SELECT game_id,\n AVG(cost_amount) AS avg_cost\n FROM gaming_technology.in_game_items\n WHERE rarity = 'Legendary'\n GROUP BY game_id\n HAVING AVG(cost_amount) > 1000\n)\nSELECT i.game_id,\n i.item_id,\n i.item_name,\n i.cost_amount,\n h.avg_cost\nFROM gaming_technology.in_game_items i\nJOIN high_avg h\n ON i.game_id = h.game_id\nWHERE i.rarity = 'Legendary';"}, {"role": "user", "content": "Order the results by avg_cost descending and then by cost_amount ascending."}, {"role": "assistant", "content": "WITH high_avg AS (\n SELECT game_id,\n AVG(cost_amount) AS avg_cost\n FROM gaming_technology.in_game_items\n WHERE rarity = 'Legendary'\n GROUP BY game_id\n HAVING AVG(cost_amount) > 1000\n)\nSELECT i.game_id,\n i.item_id,\n i.item_name,\n i.cost_amount,\n h.avg_cost\nFROM gaming_technology.in_game_items i\nJOIN high_avg h\n ON i.game_id = h.game_id\nWHERE i.rarity = 'Legendary'\nORDER BY h.avg_cost DESC,\n i.cost_amount ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles (\n vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle\n license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate\n vin character varying(17) UNIQUE, -- vehicle identification number\n make character varying(64) NOT NULL, -- manufacturer of the vehicle\n model character varying(64) NOT NULL, -- model of the vehicle\n year integer NOT NULL, -- manufacturing year\n type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)\n capacity integer, -- passenger or cargo capacity\n fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen\n status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned\n depot_id character varying(64), -- identifier of the home depot/base\n acquisition_date date, -- date the vehicle was acquired\n PRIMARY KEY (vehicle_id)\n)\nCREATE TABLE transportation.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) )\nCREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text )\nCREATE TABLE transportation.bookings ( booking_id character varying(64) NOT NULL, passenger_id character varying(64) NOT NULL, trip_id character varying(64) NOT NULL, seat_number character varying(16), booking_time timestamp with time zone NOT NULL, status character varying(32) NOT NULL, fare numeric(10, 2) NOT NULL, payment_transaction_id character varying(128), special_requests text, PRIMARY KEY (booking_id) )\n", "conversations": [{"role": "user", "content": "I need a list of all routes and the number of trips made on each route."}, {"role": "assistant", "content": "SELECT route_id, COUNT(*) AS trip_count\nFROM transportation.trips\nGROUP BY route_id;"}, {"role": "user", "content": "Actually, show the route_number and description instead of route_id."}, {"role": "assistant", "content": "SELECT r.route_number,\n r.description,\n COUNT(t.trip_id) AS trip_count\nFROM transportation.trips t\nJOIN transportation.routes r ON t.route_id = r.route_id\nGROUP BY r.route_number, r.description;"}, {"role": "user", "content": "Also, only include routes with more than 20 trips and sort by trip_count descending."}, {"role": "assistant", "content": "SELECT r.route_number,\n r.description,\n COUNT(t.trip_id) AS trip_count\nFROM transportation.trips t\nJOIN transportation.routes r ON t.route_id = r.route_id\nGROUP BY r.route_number, r.description\nHAVING COUNT(t.trip_id) > 20\nORDER BY trip_count DESC;"}, {"role": "user", "content": "Finally, display the average passenger count per trip for each of these routes."}, {"role": "assistant", "content": "SELECT r.route_number,\n r.description,\n COUNT(t.trip_id) AS trip_count,\n AVG(t.passenger_count) AS avg_passengers\nFROM transportation.trips t\nJOIN transportation.routes r ON t.route_id = r.route_id\nGROUP BY r.route_number, r.description\nHAVING COUNT(t.trip_id) > 20\nORDER BY trip_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) )\n", "conversations": [{"role": "user", "content": "I need to retrieve asset IDs along with their category and website metadata values for assets that have both entries."}, {"role": "assistant", "content": "SELECT m_cat.asset_id,\n m_cat.value AS category,\n m_web.value AS website_url\nFROM trading_platform.metadata m_cat\nJOIN trading_platform.metadata m_web\n ON m_cat.asset_id = m_web.asset_id\nWHERE m_cat.key = 'category'\n AND m_web.key = 'website';"}, {"role": "user", "content": "Actually, filter to include only those assets where the category value is 'defi'."}, {"role": "assistant", "content": "SELECT m_cat.asset_id,\n m_cat.value AS category,\n m_web.value AS website_url\nFROM trading_platform.metadata m_cat\nJOIN trading_platform.metadata m_web\n ON m_cat.asset_id = m_web.asset_id\nWHERE m_cat.key = 'category'\n AND m_web.key = 'website'\n AND m_cat.value = 'defi';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.accounts ( account_id text, customer_id text, account_number text, account_type text, balance numeric, currency text, opened_date date, status text, interest_rate numeric, last_updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Could you list all pairs of active accounts for the same customer, showing customer_id, account_a, and account_b?"}, {"role": "assistant", "content": "SELECT a.customer_id, a.account_number AS account_a, b.account_number AS account_b FROM financial_services.accounts a JOIN financial_services.accounts b ON a.customer_id = b.customer_id AND a.account_id < b.account_id WHERE a.status = 'Active' AND b.status = 'Active';"}, {"role": "user", "content": "Please only include account pairs where both balances exceed 1000."}, {"role": "assistant", "content": "SELECT a.customer_id, a.account_number AS account_a, b.account_number AS account_b FROM financial_services.accounts a JOIN financial_services.accounts b ON a.customer_id = b.customer_id AND a.account_id < b.account_id WHERE a.status = 'Active' AND b.status = 'Active' AND a.balance > 1000 AND b.balance > 1000;"}, {"role": "user", "content": "Also, filter to accounts opened after 2022-01-01."}, {"role": "assistant", "content": "SELECT a.customer_id, a.account_number AS account_a, b.account_number AS account_b FROM financial_services.accounts a JOIN financial_services.accounts b ON a.customer_id = b.customer_id AND a.account_id < b.account_id WHERE a.status = 'Active' AND b.status = 'Active' AND a.balance > 1000 AND b.balance > 1000 AND a.opened_date > '2022-01-01' AND b.opened_date > '2022-01-01';"}, {"role": "user", "content": "Finally, order the output by customer_id and account_a."}, {"role": "assistant", "content": "SELECT a.customer_id, a.account_number AS account_a, b.account_number AS account_b FROM financial_services.accounts a JOIN financial_services.accounts b ON a.customer_id = b.customer_id AND a.account_id < b.account_id WHERE a.status = 'Active' AND b.status = 'Active' AND a.balance > 1000 AND b.balance > 1000 AND a.opened_date > '2022-01-01' AND b.opened_date > '2022-01-01' ORDER BY a.customer_id, a.account_number;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE narrative_info ( narrative.text, top_3_coins.text, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, market_cap.numeric, volume_24h.numeric, trend_rank.numeric, token_num.numeric )\n", "conversations": [{"role": "user", "content": "List all narratives with a trend rank better than 50, showing the narrative name and their listed 'Top 3 Coins'."}, {"role": "assistant", "content": "SELECT narrative, top_3_coins FROM narrative_info WHERE trend_rank < 50"}, {"role": "user", "content": "Could you also include the 24-hour trading volume for these narratives and only show those where the volume is greater than 10,000,000 USD?"}, {"role": "assistant", "content": "SELECT narrative, top_3_coins, volume_24h FROM narrative_info WHERE trend_rank < 50 AND volume_24h > 10000000"}, {"role": "user", "content": "Please order the results by 24-hour trading volume in descending order."}, {"role": "assistant", "content": "SELECT narrative, top_3_coins, volume_24h FROM narrative_info WHERE trend_rank < 50 AND volume_24h > 10000000 ORDER BY volume_24h DESC"}, {"role": "user", "content": "Finally, limit the output to the top 10 and add the total number of tokens for each narrative."}, {"role": "assistant", "content": "SELECT narrative, top_3_coins, volume_24h, token_num FROM narrative_info WHERE trend_rank < 50 AND volume_24h > 10000000 ORDER BY volume_24h DESC LIMIT 10"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\n", "conversations": [{"role": "user", "content": "List pairs of distinct routes that originate from the same location but go to different destinations. Show the route ID and route number for both routes and the common origin location ID."}, {"role": "assistant", "content": "SELECT\n r1.route_id AS route1_id,\n r1.route_number AS route1_number,\n r2.route_id AS route2_id,\n r2.route_number AS route2_number,\n r1.origin_location_id AS shared_origin_location_id\nFROM transportation.routes AS r1\nJOIN transportation.routes AS r2\n ON r1.origin_location_id = r2.origin_location_id\n AND r1.route_id < r2.route_id\nWHERE\n r1.destination_location_id != r2.destination_location_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\n", "conversations": [{"role": "user", "content": "Find pairs of guests living in the same city, returning each pair\u2019s full names and the city."}, {"role": "assistant", "content": "SELECT g1.first_name || ' ' || g1.last_name AS guest1,\n g2.first_name || ' ' || g2.last_name AS guest2,\n g1.city\nFROM hospitality_technology.guests g1\nJOIN hospitality_technology.guests g2\n ON g1.city = g2.city\n AND g1.guest_id < g2.guest_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.events ( event_id text, contract_id text, event_name text, data text, emitted_at timestamp, transaction_id text, log_index integer )\nCREATE TABLE web3.transactions ( transaction_id text, from_address text, to_address text, value numeric, gas_used integer, gas_price numeric, block_number integer, timestamp timestamp, input_data text, status text, nonce integer )\nCREATE TABLE web3.tokens ( token_id text, contract_address text, token_name text, token_symbol text, decimals integer, total_supply numeric )\nCREATE TABLE web3.token_transfers ( transfer_id text, token_id text, from_address text, to_address text, value numeric, transaction_id text, log_index integer )\nCREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all token transfers showing the transfer id, the symbol of the transferred token, and the contract address where the token was created."}, {"role": "assistant", "content": "SELECT tt.transfer_id, t.token_symbol, t.contract_address\nFROM web3.token_transfers tt\nJOIN web3.tokens t ON tt.token_id = t.token_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\n", "conversations": [{"role": "user", "content": "Can you show me all routes where the origin_location_id is the same as the destination_location_id? List their route_id, route_number, and type."}, {"role": "assistant", "content": "SELECT route_id, route_number, type\nFROM transportation.routes\nWHERE origin_location_id = destination_location_id;"}, {"role": "user", "content": "I'd also like to know the distance_km and estimated_duration_minutes for these routes."}, {"role": "assistant", "content": "SELECT route_id, route_number, type, distance_km, estimated_duration_minutes\nFROM transportation.routes\nWHERE origin_location_id = destination_location_id;"}, {"role": "user", "content": "Finally, only include those routes where estimated_duration_minutes is less than 30 and sort by distance_km descending."}, {"role": "assistant", "content": "SELECT route_id, route_number, type, distance_km, estimated_duration_minutes\nFROM transportation.routes\nWHERE origin_location_id = destination_location_id\n AND estimated_duration_minutes < 30\nORDER BY distance_km DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.lawyers ( lawyer_id text PRIMARY KEY, first_name text, last_name text, bar_number text UNIQUE, firm_id text, email text UNIQUE, phone text, specialization text, hire_date timestamp, is_partner bool )\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id text PRIMARY KEY, case_number text UNIQUE, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\nCREATE TABLE legal_services.time_entries ( entry_id text PRIMARY KEY, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable bool, is_billed bool, invoice_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "I need the case_number and case_name along with the total billing amount (hours_spent * billing_rate) for cases that are currently open."}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, SUM(te.hours_spent * te.billing_rate) AS total_billing\nFROM legal_services.cases c\nJOIN legal_services.time_entries te ON c.case_id = te.case_id\nWHERE c.status = 'Open'\nGROUP BY c.case_number, c.case_name;"}, {"role": "user", "content": "Now order the results by total_billing in descending order and limit to the top 5."}, {"role": "assistant", "content": "SELECT c.case_number, c.case_name, SUM(te.hours_spent * te.billing_rate) AS total_billing\nFROM legal_services.cases c\nJOIN legal_services.time_entries te ON c.case_id = te.case_id\nWHERE c.status = 'Open'\nGROUP BY c.case_number, c.case_name\nORDER BY total_billing DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_token_performance ( token_address text, token_symbol text, pnl numeric, net_flow numeric, avg_cost numeric, price numeric, realized_ratio numeric, roi numeric, chain text )\n", "conversations": [{"role": "user", "content": "Which 3 tokens across all chains have the highest realized_ratio and what are their avg_cost and roi?"}, {"role": "assistant", "content": "SELECT token_symbol, chain, realized_ratio, avg_cost, roi\nFROM smart_money_token_performance\nORDER BY realized_ratio DESC\nLIMIT 3;"}, {"role": "user", "content": "I get an error, could you also display their pnl in the result?"}, {"role": "assistant", "content": "SELECT token_symbol, chain, realized_ratio, avg_cost, roi, pnl\nFROM smart_money_token_performance\nORDER BY realized_ratio DESC\nLIMIT 3;"}, {"role": "user", "content": "Actually, I want tokens where realized_ratio is above 0.7 and net_flow is positive only."}, {"role": "assistant", "content": "SELECT token_symbol, chain, realized_ratio, avg_cost, roi, pnl\nFROM smart_money_token_performance\nWHERE realized_ratio > 0.7 AND net_flow > 0\nORDER BY realized_ratio DESC\nLIMIT 3;"}, {"role": "user", "content": "And can you order the result by pnl descending instead?"}, {"role": "assistant", "content": "SELECT token_symbol, chain, realized_ratio, avg_cost, roi, pnl\nFROM smart_money_token_performance\nWHERE realized_ratio > 0.7 AND net_flow > 0\nORDER BY pnl DESC\nLIMIT 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "List the plan ID, name, provider, and type for all insurance plans from 'Healthcare Partners' with a plan type of 'PPO'."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, insurance_provider, plan_type FROM healthcare.insurance_plans WHERE insurance_provider = 'Healthcare Partners' AND plan_type = 'PPO';"}, {"role": "user", "content": "Now, only show those plans that also have a website listed."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, insurance_provider, plan_type FROM healthcare.insurance_plans WHERE insurance_provider = 'Healthcare Partners' AND plan_type = 'PPO' AND website IS NOT NULL;"}, {"role": "user", "content": "Further refine the results to only include plans where the plan name contains the word 'Plus'."}, {"role": "assistant", "content": "SELECT plan_id, plan_name, insurance_provider, plan_type FROM healthcare.insurance_plans WHERE insurance_provider = 'Healthcare Partners' AND plan_type = 'PPO' AND website IS NOT NULL AND plan_name ILIKE '%Plus%';"}, {"role": "user", "content": "Finally, count how many such plans exist."}, {"role": "assistant", "content": "SELECT COUNT(*) FROM healthcare.insurance_plans WHERE insurance_provider = 'Healthcare Partners' AND plan_type = 'PPO' AND website IS NOT NULL AND plan_name ILIKE '%Plus%';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.assets ( asset_id 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) )\nCREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, status character varying(32) NOT NULL, reviewed_at timestamp NOT NULL, PRIMARY KEY (kyc_audit_id) )\n", "conversations": [{"role": "user", "content": "Show a list of all asset names along with the current KYC status of each user, including the asset symbol. Join the assets and kyc_audit tables."}, {"role": "assistant", "content": "SELECT a.name AS asset_name, a.symbol, k.user_id, k.status AS kyc_status \nFROM trading_platform.assets a\nJOIN trading_platform.kyc_audit k ON 1=1"}, {"role": "user", "content": "I only want the result for users whose KYC status is 'approved' and for assets where the symbol is at least 3 characters long."}, {"role": "assistant", "content": "SELECT a.name AS asset_name, a.symbol, k.user_id, k.status AS kyc_status \nFROM trading_platform.assets a\nJOIN trading_platform.kyc_audit k ON 1=1\nWHERE k.status = 'approved' AND LENGTH(a.symbol) >= 3"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts ( contract_id text PRIMARY KEY, address text, abi text, bytecode text, deployer_address text, deployed_at timestamp, network_id text, status text )\nCREATE TABLE web3.events ( event_id character varying(64) NOT NULL, contract_id character varying(64) NOT NULL, event_name character varying(128) NOT NULL, data text NOT NULL, emitted_at timestamp NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (event_id) )\nCREATE TABLE web3.tokens (\n token_id character varying(64) NOT NULL, -- unique identifier for the token\n contract_address character varying(128) NOT NULL, -- address of the token contract\n token_name character varying(128) NOT NULL, -- name of the token\n token_symbol character varying(32) NOT NULL, -- symbol of the token\n decimals integer NOT NULL, -- number of decimals for the token\n total_supply numeric(38,14) NOT NULL, -- total supply of the token\n PRIMARY KEY (token_id)\n)\nCREATE TABLE web3.token_transfers ( transfer_id character varying(64) NOT NULL, token_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128) NOT NULL, value numeric(38,14) NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (transfer_id) )\nCREATE TABLE web3.wallets (\n wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet\n user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet\n address character varying(128) NOT NULL, -- address of the wallet\n private_key text NOT NULL, -- private key of the wallet\n created_at timestamp NOT NULL, -- time when the wallet was created\n PRIMARY KEY (wallet_id)\n)\nCREATE TABLE web3.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(128) NOT NULL, -- username of the user\n email character varying(128) NOT NULL, -- email address of the user\n password_hash text NOT NULL, -- hashed password of the user\n created_at timestamp NOT NULL, -- time when the user account was created\n PRIMARY KEY (user_id)\n)\n", "conversations": [{"role": "user", "content": "For each token transfer, show the transfer id, token symbol, and the username of the user who owns the sender address. Please order the result by transfer id."}, {"role": "assistant", "content": "SELECT tt.transfer_id, tk.token_symbol, u.username\nFROM web3.token_transfers tt\nJOIN web3.tokens tk ON tt.token_id = tk.token_id\nJOIN web3.wallets w ON tt.from_address = w.address\nJOIN web3.users u ON w.user_id = u.user_id\nORDER BY tt.transfer_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims (\n claim_id character varying(64) NOT NULL, -- unique identifier for the claim\n policy_id character varying(64) NOT NULL, -- identifier of the policy under which the claim is made (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the claim (FK to customers)\n incident_date timestamp NOT NULL, -- date and time of the incident leading to the claim\n reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the claim was reported\n description text NOT NULL, -- detailed description of the incident and claim\n estimated_loss numeric(15, 2), -- initial estimated cost of the loss\n status character varying(30) NOT NULL, -- e.g., Filed, Processing, Under Review, Approved, Denied, Settled\n settlement_amount numeric(15, 2), -- final amount paid out\n settlement_date date,\n claim_handler_id character varying(64), -- identifier for the employee handling the claim (FK to employees/adjusters)\n police_report_number character varying(100),\n PRIMARY KEY (claim_id)\n)\nCREATE TABLE insurance.insurance_products (\n product_id character varying(64) NOT NULL, -- unique identifier for the insurance product\n product_name character varying(150) NOT NULL, -- name of the insurance product (e.g., 'Comprehensive Auto Insurance')\n product_type character varying(50) NOT NULL, -- category like 'Auto', 'Home', 'Life', 'Health', 'Travel'\n description text, -- detailed description of the product\n base_premium numeric(10, 2) NOT NULL, -- starting premium before adjustments\n coverage_details text, -- details about what is covered (could be JSON or structured text)\n underwriting_rules text, -- rules used for assessing risk and eligibility\n is_active boolean NOT NULL DEFAULT true, -- whether the product is currently offered\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at timestamp,\n PRIMARY KEY (product_id)\n)\nCREATE TABLE insurance.premium_payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment\n policy_id character varying(64) NOT NULL, -- identifier of the policy the payment is for (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the payment (FK to customers)\n payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the payment was received\n amount_paid numeric(12, 2) NOT NULL, -- amount of the payment\n payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check\n transaction_reference character varying(128) UNIQUE, -- reference from payment processor\n due_date date, -- due date for this payment installment\n payment_period_start date, -- start date of the period this payment covers\n payment_period_end date, -- end date of the period this payment covers\n status character varying(30) NOT NULL DEFAULT 'Completed', -- e.g., Completed, Pending, Failed, Refunded\n PRIMARY KEY (payment_id)\n)\nCREATE TABLE insurance.claim_documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document\n claim_id character varying(64) NOT NULL, -- identifier of the claim this document relates to (FK to claims)\n document_type character varying(50) NOT NULL, -- e.g., Police Report, Photo, Invoice, Medical Bill\n file_name character varying(255) NOT NULL, -- original name of the uploaded file\n file_path character varying(512) NOT NULL, -- storage path (e.g., S3 URL, network path)\n file_size_bytes integer, -- size of the file in bytes\n mime_type character varying(100), -- MIME type of the file (e.g., 'image/jpeg', 'application/pdf')\n uploaded_by character varying(64), -- identifier of the user/system who uploaded (FK to users/customers)\n uploaded_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- time of upload\n description text, -- optional description of the document\n PRIMARY KEY (document_id)\n)\n", "conversations": [{"role": "user", "content": "List all premium payments with the amount_paid exactly 1000, showing the payment_id and payment_date."}, {"role": "assistant", "content": "SELECT payment_id, payment_date\nFROM insurance.premium_payments\nWHERE amount_paid = 1000;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\n", "conversations": [{"role": "user", "content": "List the full names of all employees who are currently employed (i.e., have no termination date)."}, {"role": "assistant", "content": "SELECT first_name || ' ' || last_name AS full_name FROM government_services.employees WHERE termination_date IS NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )\nCREATE TABLE trading_platform.trades ( trade_id.text, order_id.text, buyer_id.text, seller_id.text, asset_id.text, quantity.numeric, price.numeric, traded_at.timestamp )\nCREATE TABLE trading_platform.assets ( asset_id.text, name.text, symbol.text, type.text )\nCREATE TABLE trading_platform.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean )\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id.text, asset_id.text, key.text, value.text )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )\n", "conversations": [{"role": "user", "content": "Find the address that has the highest total amount across all its UTXOs."}, {"role": "assistant", "content": "SELECT address FROM utxos GROUP BY address ORDER BY SUM(amount) DESC LIMIT 1;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_profit ( address.text, rank.numeric, profit.numeric, roi.numeric, realized_ratio.numeric, most_profit_token.text, last_trade_time.text, chain.text )\n", "conversations": [{"role": "user", "content": "List the top 3 addresses with the highest profit on the Arbitrum chain, including roi and most_profit_token."}, {"role": "assistant", "content": "SELECT address, profit, roi, most_profit_token FROM smart_money_profit WHERE chain = 'Arbitrum' ORDER BY profit DESC LIMIT 3;"}, {"role": "user", "content": "Please add the realized_ratio and last_trade_time for each result."}, {"role": "assistant", "content": "SELECT address, profit, roi, most_profit_token, realized_ratio, last_trade_time FROM smart_money_profit WHERE chain = 'Arbitrum' ORDER BY profit DESC LIMIT 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.rooms ( room_id text PRIMARY KEY, property_id text, room_number text, room_type_id text, floor int, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\n", "conversations": [{"role": "user", "content": "List each property_name along with the count of rooms that are currently marked as 'Available'."}, {"role": "assistant", "content": "SELECT p.property_name, COUNT(r.room_id) AS available_room_count\nFROM hospitality_technology.properties p\nLEFT JOIN hospitality_technology.rooms r\n ON p.property_id = r.property_id AND r.status = 'Available'\nGROUP BY p.property_name;"}, {"role": "user", "content": "Only include properties with more than 10 available rooms and order by available_room_count descending."}, {"role": "assistant", "content": "SELECT p.property_name, COUNT(r.room_id) AS available_room_count\nFROM hospitality_technology.properties p\nLEFT JOIN hospitality_technology.rooms r\n ON p.property_id = r.property_id AND r.status = 'Available'\nGROUP BY p.property_name\nHAVING COUNT(r.room_id) > 10\nORDER BY available_room_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\n", "conversations": [{"role": "user", "content": "Can you show me all pairs of customers living in the same city but with different last names? Show both customer IDs, both full names, and their city."}, {"role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, CONCAT(a.first_name, ' ', a.last_name) AS full_name_a, b.customer_id AS customer_id_b, CONCAT(b.first_name, ' ', b.last_name) AS full_name_b, a.city FROM financial_services.customers a JOIN financial_services.customers b ON a.city = b.city AND a.last_name <> b.last_name AND a.customer_id < b.customer_id;"}, {"role": "user", "content": "Add a filter to only include pairs where both customers are in the same state as well."}, {"role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, CONCAT(a.first_name, ' ', a.last_name) AS full_name_a, b.customer_id AS customer_id_b, CONCAT(b.first_name, ' ', b.last_name) AS full_name_b, a.city, a.state FROM financial_services.customers a JOIN financial_services.customers b ON a.city = b.city AND a.state = b.state AND a.last_name <> b.last_name AND a.customer_id < b.customer_id;"}, {"role": "user", "content": "Please further restrict results to only pairs where both customers have a status of 'Active'."}, {"role": "assistant", "content": "SELECT a.customer_id AS customer_id_a, CONCAT(a.first_name, ' ', a.last_name) AS full_name_a, b.customer_id AS customer_id_b, CONCAT(b.first_name, ' ', b.last_name) AS full_name_b, a.city, a.state FROM financial_services.customers a JOIN financial_services.customers b ON a.city = b.city AND a.state = b.state AND a.last_name <> b.last_name AND a.status = 'Active' AND b.status = 'Active' AND a.customer_id < b.customer_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n// Use Hashes for ticket details. Key format: ticket:\n// HSET ticket:tkt_1a2b ticket_id \"tkt_1a2b\" booking_id \"book_zyx\" car_id \"car_abc\" seat_number \"12A\" ... is_checked_in 0 ...\n\n// To link tickets to bookings (optional):\n// SADD booking:book_zyx:tickets ticket:tkt_1a2b\n// Use Hashes for maintenance record details. Key format: maintenance_record:\n// HSET maintenance_record:maint_rec_001 record_id \"maint_rec_001\" asset_id \"train_789\" asset_type \"Train\" ... status \"Completed\"\n\n// To link records to assets (optional):\n// SADD train:train_789:maintenance maintenance_record:maint_rec_001\n// SADD platform:plat_123:maintenance maintenance_record:maint_rec_002\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u4e88\u7d04ID 'book_zyx' \u306b\u95a2\u9023\u3059\u308b\u3059\u3079\u3066\u306e\u30c1\u30b1\u30c3\u30c8\u306e\u8a73\u7d30\u3092\u53d6\u5f97\u3059\u308b\u306e\u3092\u624b\u4f1d\u3063\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f\u307e\u305f\u3001\u95a2\u9023\u3059\u308b\u8eca\u4e21\u60c5\u5831\u3082\u542b\u3081\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SMEMBERS booking:book_zyx:tickets\nHGETALL ticket:\nHGETALL car:"}, {"role": "user", "content": "\u30c1\u30a7\u30c3\u30af\u30a4\u30f3\u6e08\u307f\u306e\u30c1\u30b1\u30c3\u30c8\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS booking:book_zyx:tickets\nHGET ticket: is_checked_in\nHGETALL ticket: (only if is_checked_in = 1)\nHGETALL car:"}, {"role": "user", "content": "\u5ea7\u5e2d\u756a\u53f7\u3082\u7d50\u679c\u306b\u542b\u3081\u3066\u3001\u5ea7\u5e2d\u756a\u53f7\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS booking:book_zyx:tickets\nHGET ticket: is_checked_in\nHGETALL ticket: (only if is_checked_in = 1)\nHGETALL car:\n(Sort results by seat_number in ascending order)"}, {"role": "user", "content": "\u8eca\u4e21ID\u3054\u3068\u306b\u30c1\u30b1\u30c3\u30c8\u306e\u7dcf\u6570\u3092\u8ffd\u52a0\u3057\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS booking:book_zyx:tickets\nHGET ticket: is_checked_in\nHGETALL ticket: (only if is_checked_in = 1)\nHGETALL car:\n(Group by car_id and count total tickets per car_id)\n(Sort results by seat_number in ascending order)"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.accounts ( account_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, account_number character varying(128) NOT NULL UNIQUE, account_type character varying(50) NOT NULL, balance numeric(19, 4) NOT NULL DEFAULT 0.00, currency character varying(3) NOT NULL, opened_date date NOT NULL, status character varying(32) NOT NULL, interest_rate numeric(5, 4), last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (account_id), FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id) )\n", "conversations": [{"role": "user", "content": "Show me all accounts (account_id, account_number, account_type, balance, currency) for customers whose status is 'VIP'."}, {"role": "assistant", "content": "SELECT a.account_id, a.account_number, a.account_type, a.balance, a.currency FROM financial_services.accounts AS a JOIN financial_services.customers AS c ON a.customer_id = c.customer_id WHERE c.status = 'VIP';"}, {"role": "user", "content": "Also include the customer's email and the date they were created."}, {"role": "assistant", "content": "SELECT a.account_id, a.account_number, a.account_type, a.balance, a.currency, c.email, c.created_at FROM financial_services.accounts AS a JOIN financial_services.customers AS c ON a.customer_id = c.customer_id WHERE c.status = 'VIP';"}, {"role": "user", "content": "Filter the results to only include accounts opened before 2023-01-01."}, {"role": "assistant", "content": "SELECT a.account_id, a.account_number, a.account_type, a.balance, a.currency, c.email, c.created_at FROM financial_services.accounts AS a JOIN financial_services.customers AS c ON a.customer_id = c.customer_id WHERE c.status = 'VIP' AND a.opened_date < '2023-01-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me all invoices where the notes field is not null. Display invoice number, client ID, and notes."}, {"role": "assistant", "content": "SELECT invoice_number, client_id, notes FROM legal_services.invoices WHERE notes IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\nCREATE TABLE hospitality_technology.guests ( guest_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )\nCREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes text )\nCREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "Show me the latest payment timestamp for each guest who has made a payment, along with their full name."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, max(T2.payment_timestamp) FROM hospitality_technology.guests AS T1 JOIN hospitality_technology.payments AS T2 ON T1.guest_id = T2.guest_id GROUP BY T1.guest_id, T1.first_name, T1.last_name;"}]} +{"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE train_station_management.staff ( staff_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, role character varying(64) NOT NULL, primary_station_id character varying(64), employee_number character varying(32) UNIQUE NOT NULL, hire_date date NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), is_active boolean NOT NULL DEFAULT true, PRIMARY KEY (staff_id), FOREIGN KEY (primary_station_id) REFERENCES train_station_management.stations(station_id) )\n", "conversations": [{"role": "user", "content": "What is the salary or compensation package for a staff member with the role of Ticket Inspector?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide information about salary or compensation packages as this data is not included in the staff table. For details on salaries, please refer to the HR department or relevant documentation."}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\n", "conversations": [{"role": "user", "content": "I want to know the total number of appointments per location along with the location name for appointments scheduled in March 2024."}, {"role": "assistant", "content": "SELECT\n sl.location_name,\n COUNT(a.appointment_id) AS appointment_count\nFROM appointments a\nJOIN service_locations sl\n ON a.location_id = sl.location_id\nWHERE a.scheduled_start_time >= '2024-03-01'\n AND a.scheduled_start_time < '2024-04-01'\nGROUP BY sl.location_name;"}, {"role": "user", "content": "Actually, only include appointments with status 'Completed' and locations that are accessible."}, {"role": "assistant", "content": "SELECT\n sl.location_name,\n COUNT(a.appointment_id) AS completed_appointment_count\nFROM appointments a\nJOIN service_locations sl\n ON a.location_id = sl.location_id\nWHERE a.scheduled_start_time >= '2024-03-01'\n AND a.scheduled_start_time < '2024-04-01'\n AND a.status = 'Completed'\n AND sl.is_accessible = TRUE\nGROUP BY sl.location_name;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL )\nCREATE TABLE erc20_balances ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )\nCREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )\nCREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )\nCREATE TABLE sui_coins_metadata (\n object_id varchar NOT NULL, -- object id of the coin metadata object\n coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN\n status varchar NOT NULL, -- coin status, eg. exists, deleted\n decimals bigint NOT NULL, -- decimals of the coin\n description varchar NOT NULL, -- description of the coin\n icon_url varchar NOT NULL, -- icon url of the coin\n symbol varchar NOT NULL, -- symbol of the coin\n name varchar NOT NULL -- name of the coin\n)\nCREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )\nCREATE TABLE token_prices (\n uuid varchar(36) NOT NULL, -- uuid fields for the functionType in contract\n blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract\n address varchar(42) NOT NULL, -- address fields for the functionType in contract\n decimals bigint NOT NULL, -- decimals fields for the functionType in contract\n symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract\n price real NOT NULL, -- price fields for the functionType in contract\n timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract\n)\nCREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )\n", "conversations": [{"role": "user", "content": "Show me the wallet addresses that hold more than 1000 of any ERC20 token, along with the token symbol and amount, from the erc20_balances table."}, {"role": "assistant", "content": "SELECT e.wallet_address, t.symbol, e.amount FROM erc20_balances e JOIN token_prices_latest t ON e.contract_address = t.address WHERE CAST(e.amount AS decimal) > 1000;"}, {"role": "user", "content": "Can you also include the current price of each token from the token_prices_latest table and sort the results by amount in descending order?"}, {"role": "assistant", "content": "SELECT e.wallet_address, t.symbol, e.amount, t.price FROM erc20_balances e JOIN token_prices_latest t ON e.contract_address = t.address WHERE CAST(e.amount AS decimal) > 1000 ORDER BY CAST(e.amount AS decimal) DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.likes (\n like_id character varying(64) NOT NULL, -- unique identifier for the like\n user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id)\n post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable)\n comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred\n PRIMARY KEY (like_id),\n CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes\n CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something\n)\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)\n sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)\n notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')\n target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)\n target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created\n read_at timestamp, -- timestamp notification was marked as read\n PRIMARY KEY (notification_id)\n)\n", "conversations": [{"role": "user", "content": "How many notifications have been marked as read so far?"}, {"role": "assistant", "content": "SELECT COUNT(*) AS read_notifications_count\nFROM social_media.notifications\nWHERE read_at IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id.text, medication_name.text, generic_name.text, manufacturer.text, ndc_code.text, description.text )\n", "conversations": [{"role": "user", "content": "Find all medications whose generic_name matches the medication_name of another entry, displaying the brand medication_id, brand medication_name, generic medication_id, and generic medication_name."}, {"role": "assistant", "content": "SELECT b.medication_id AS brand_id, b.medication_name AS brand_name, g.medication_id AS generic_id, g.medication_name AS generic_name\nFROM healthcare.medications b\nJOIN healthcare.medications g\n ON b.generic_name = g.medication_name;"}, {"role": "user", "content": "Filter to include only those where the manufacturer of the brand differs from that of the generic match."}, {"role": "assistant", "content": "SELECT b.medication_id AS brand_id, b.medication_name AS brand_name, g.medication_id AS generic_id, g.medication_name AS generic_name\nFROM healthcare.medications b\nJOIN healthcare.medications g\n ON b.generic_name = g.medication_name\nWHERE b.manufacturer <> g.manufacturer;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.servers ( server_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, server_name character varying(150), region character varying(50) NOT NULL, ip_address character varying(45), port integer, current_players integer NOT NULL DEFAULT 0, max_players integer NOT NULL, status character varying(30) NOT NULL DEFAULT 'offline', last_heartbeat timestamp with time zone, PRIMARY KEY (server_id) )\n", "conversations": [{"role": "user", "content": "I need a report showing the count of servers grouped by their status."}, {"role": "assistant", "content": "SELECT status, COUNT(*) AS server_count\nFROM gaming_technology.servers\nGROUP BY status;"}, {"role": "user", "content": "Actually, can you also compute each status\u2019s percentage share of the total servers?"}, {"role": "assistant", "content": "SELECT\n status,\n COUNT(*) AS server_count,\n ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) AS percentage\nFROM gaming_technology.servers\nGROUP BY status;"}, {"role": "user", "content": "Now filter out any statuses that represent less than 5% of all servers."}, {"role": "assistant", "content": "SELECT\n status,\n server_count,\n percentage\nFROM (\n SELECT\n status,\n COUNT(*) AS server_count,\n ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) AS percentage\n FROM gaming_technology.servers\n GROUP BY status\n) sub\nWHERE percentage >= 5;"}, {"role": "user", "content": "Finally, order the results by percentage in descending order."}, {"role": "assistant", "content": "SELECT\n status,\n server_count,\n percentage\nFROM (\n SELECT\n status,\n COUNT(*) AS server_count,\n ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) AS percentage\n FROM gaming_technology.servers\n GROUP BY status\n) sub\nWHERE percentage >= 5\nORDER BY percentage DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.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) )\nCREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the location\n name character varying(255) NOT NULL, -- name of the location (e.g., Central Station, Depot Alpha, Pier 7)\n type character varying(64) NOT NULL, -- e.g., Station, Stop, Depot, Port, Airport, Customer Address\n address_line1 character varying(255), -- street address\n city character varying(128), -- city name\n state_province character varying(128), -- state or province\n postal_code character varying(32), -- postal code\n country character varying(64) NOT NULL, -- country name\n latitude numeric(9, 6), -- geographic latitude\n longitude numeric(9, 6), -- geographic longitude\n timezone character varying(64), -- IANA timezone name (e.g., America/New_York)\n PRIMARY KEY (location_id)\n)\nCREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\nCREATE TABLE transportation.fuel_logs (\n fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled\n trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred\n log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred\n fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type)\n quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh)\n unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh)\n cost_per_unit numeric(8, 4), -- price per unit of fuel\n total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase\n odometer_reading integer, -- vehicle mileage at time of fueling\n location_id character varying(64), -- identifier of the fueling station/location\n PRIMARY KEY (fuel_log_id)\n)\n", "conversations": [{"role": "user", "content": "How many routes start and end in the same city?"}, {"role": "assistant", "content": "SELECT COUNT(*) AS same_city_routes\nFROM transportation.routes AS r\nJOIN transportation.locations AS o ON r.origin_location_id = o.location_id\nJOIN transportation.locations AS d ON r.destination_location_id = d.location_id\nWHERE o.city = d.city;"}, {"role": "user", "content": "Actually, I would like to see each route_number and the city instead of just the count."}, {"role": "assistant", "content": "SELECT r.route_number,\n o.city AS common_city\nFROM transportation.routes AS r\nJOIN transportation.locations AS o ON r.origin_location_id = o.location_id\nJOIN transportation.locations AS d ON r.destination_location_id = d.location_id\nWHERE o.city = d.city;"}, {"role": "user", "content": "Can you also restrict it to routes where distance_km is greater than 100?"}, {"role": "assistant", "content": "SELECT r.route_number,\n o.city AS common_city\nFROM transportation.routes AS r\nJOIN transportation.locations AS o ON r.origin_location_id = o.location_id\nJOIN transportation.locations AS d ON r.destination_location_id = d.location_id\nWHERE o.city = d.city\n AND r.distance_km > 100;"}, {"role": "user", "content": "Please sort the results by route_number in ascending order."}, {"role": "assistant", "content": "SELECT r.route_number,\n o.city AS common_city\nFROM transportation.routes AS r\nJOIN transportation.locations AS o ON r.origin_location_id = o.location_id\nJOIN transportation.locations AS d ON r.destination_location_id = d.location_id\nWHERE o.city = d.city\n AND r.distance_km > 100\nORDER BY r.route_number ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.fuel_logs ( fuel_log_id.text, vehicle_id.text, trip_id.text, log_timestamp.timestamp, fuel_type.text, quantity.numeric, unit.text, cost_per_unit.numeric, total_cost.numeric, odometer_reading.integer, location_id.text )\n", "conversations": [{"role": "user", "content": "For each vehicle and unit combination, show the total quantity of fuel refueled and the total cost."}, {"role": "assistant", "content": "SELECT vehicle_id, unit, SUM(quantity) AS total_quantity, SUM(total_cost) AS total_cost\nFROM transportation.fuel_logs\nGROUP BY vehicle_id, unit;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) )\nCREATE TABLE healthcare.insurance_plans ( plan_id character varying(64) NOT NULL, plan_name character varying(200) NOT NULL, insurance_provider character varying(100) NOT NULL, plan_type character varying(50), contact_phone character varying(20), website character varying(255), PRIMARY KEY (plan_id) )\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "What is the average number of refills allowed across all prescriptions?"}, {"role": "assistant", "content": "SELECT AVG(refills_allowed) FROM healthcare.prescriptions;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.locations ( location_id.text, name.text, type.text, address_line1.text, city.text, state_province.text, postal_code.text, country.text, latitude.numeric, longitude.numeric, timezone.text )\n", "conversations": [{"role": "user", "content": "List pairs of distinct locations in the same city that share the same location type. Show both location IDs, names, city, and the shared type."}, {"role": "assistant", "content": "SELECT L1.location_id AS location1_id, L1.name AS location1_name, L2.location_id AS location2_id, L2.name AS location2_name, L1.city AS shared_city, L1.type AS shared_type FROM transportation.locations AS L1 JOIN transportation.locations AS L2 ON L1.city = L2.city AND L1.type = L2.type WHERE L1.location_id < L2.location_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n// Use Hashes for ticket details. Key format: ticket:\n// HSET ticket:tkt_1a2b ticket_id \"tkt_1a2b\" booking_id \"book_zyx\" car_id \"car_abc\" seat_number \"12A\" ... is_checked_in 0 ...\n\n// To link tickets to bookings (optional):\n// SADD booking:book_zyx:tickets ticket:tkt_1a2b\n// Use Hashes for maintenance record details. Key format: maintenance_record:\n// HSET maintenance_record:maint_rec_001 record_id \"maint_rec_001\" asset_id \"train_789\" asset_type \"Train\" ... status \"Completed\"\n\n// To link records to assets (optional):\n// SADD train:train_789:maintenance maintenance_record:maint_rec_001\n// SADD platform:plat_123:maintenance maintenance_record:maint_rec_002\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u5217\u8ecaID 'train_789' \u306b\u95a2\u9023\u3059\u308b\u3059\u3079\u3066\u306e\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u8a18\u9332\u306e\u8a73\u7d30\u3092\u53d6\u5f97\u3059\u308b\u306e\u3092\u624b\u4f1d\u3063\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS train:train_789:maintenance\nHGETALL maintenance_record:"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.trips ( trip_id character varying(64) NOT NULL, route_id character varying(64), vehicle_id character varying(64) NOT NULL, driver_id character varying(64) NOT NULL, scheduled_departure timestamp with time zone NOT NULL, actual_departure timestamp with time zone, scheduled_arrival timestamp with time zone NOT NULL, actual_arrival timestamp with time zone, origin_location_id character varying(64) NOT NULL, destination_location_id character varying(64) NOT NULL, status character varying(32) NOT NULL, passenger_count integer, cargo_manifest_id character varying(64), PRIMARY KEY (trip_id) )\n", "conversations": [{"role": "user", "content": "Show me pairs of trip IDs that used the same vehicle."}, {"role": "assistant", "content": "SELECT\n t1.trip_id AS trip1_id,\n t2.trip_id AS trip2_id\nFROM transportation.trips AS t1\nJOIN transportation.trips AS t2\n ON t1.vehicle_id = t2.vehicle_id\n AND t1.trip_id < t2.trip_id;"}, {"role": "user", "content": "Now, filter this list to only include pairs where both trips have a 'Completed' status."}, {"role": "assistant", "content": "SELECT\n t1.trip_id AS trip1_id,\n t2.trip_id AS trip2_id\nFROM transportation.trips AS t1\nJOIN transportation.trips AS t2\n ON t1.vehicle_id = t2.vehicle_id\n AND t1.trip_id < t2.trip_id\nWHERE\n t1.status = 'Completed' AND t2.status = 'Completed';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.agencies ( agency_id.text, agency_name.text, jurisdiction_level.text, primary_contact_email.text, main_phone_number.text, website_url.text, established_date.date, parent_agency_id.text )\nCREATE TABLE government_services.applications ( application_id.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text )\nCREATE TABLE government_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document instance\n application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly)\n citizen_id character varying(64) NOT NULL, -- FK to citizens table\n document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate\n file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path)\n upload_timestamp timestamp NOT NULL,\n expiry_date date,\n verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected\n verified_by_employee_id character varying(64), -- FK to employees table\n verification_timestamp timestamp,\n PRIMARY KEY (document_id)\n)\nCREATE TABLE government_services.payments ( payment_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, service_id character varying(64), amount numeric(12, 2) NOT NULL, currency character varying(3) NOT NULL DEFAULT 'USD', payment_method character varying(50), payment_provider_reference character varying(128), payment_timestamp timestamp NOT NULL, status character varying(30) NOT NULL, notes text, PRIMARY KEY (payment_id) )\nCREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.notifications ( notification_id text PRIMARY KEY, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "For each citizen who has made a payment for an application that is still in 'Processing' status, list their full name, application_id, payment_id, amount, currency, and the application status."}, {"role": "assistant", "content": "SELECT c.first_name || ' ' || c.last_name AS full_name,\n a.application_id,\n p.payment_id,\n p.amount,\n p.currency,\n a.status AS application_status\nFROM government_services.citizens c\nJOIN government_services.applications a ON c.citizen_id = a.citizen_id\nJOIN government_services.payments p ON a.application_id = p.application_id\nWHERE a.status = 'Processing';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.law_firms (\n firm_id character varying(64) NOT NULL, -- unique identifier for the law firm\n firm_name character varying(200) NOT NULL, -- official name of the law firm\n address text NOT NULL, -- primary address of the firm\n phone character varying(32), -- firm's main phone number\n website character varying(255), -- firm's website URL\n founded_date date, -- date the firm was established\n managing_partner_id character varying(64), -- FK to lawyers table (optional)\n PRIMARY KEY (firm_id)\n)\nCREATE TABLE legal_services.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List each client_id, first_name, last_name, and the sum of total_amount for all of their invoices."}, {"role": "assistant", "content": "SELECT c.client_id,\n c.first_name,\n c.last_name,\n SUM(i.total_amount) AS total_invoiced\nFROM legal_services.clients c\nJOIN legal_services.invoices i ON i.client_id = c.client_id\nGROUP BY c.client_id, c.first_name, c.last_name;"}, {"role": "user", "content": "Now show only clients whose total_invoiced exceeds 20000 and include the count of invoices as invoice_count."}, {"role": "assistant", "content": "SELECT c.client_id,\n c.first_name,\n c.last_name,\n SUM(i.total_amount) AS total_invoiced,\n COUNT(i.invoice_id) AS invoice_count\nFROM legal_services.clients c\nJOIN legal_services.invoices i ON i.client_id = c.client_id\nGROUP BY c.client_id, c.first_name, c.last_name\nHAVING SUM(i.total_amount) > 20000;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me all insurance products with coverage details mentioning 'liability', along with their product names and base premiums."}, {"role": "assistant", "content": "SELECT product_name, base_premium, coverage_details FROM insurance.insurance_products WHERE coverage_details LIKE '%liability%';"}, {"role": "user", "content": "Now filter to only show active products with base premium between $100 and $500."}, {"role": "assistant", "content": "SELECT product_name, base_premium, coverage_details FROM insurance.insurance_products WHERE coverage_details LIKE '%liability%' AND is_active = true AND base_premium BETWEEN 100 AND 500;"}, {"role": "user", "content": "I also want to see the count of these products by product type."}, {"role": "assistant", "content": "SELECT product_type, COUNT(*) as product_count FROM insurance.insurance_products WHERE coverage_details LIKE '%liability%' AND is_active = true AND base_premium BETWEEN 100 AND 500 GROUP BY product_type;"}, {"role": "user", "content": "Finally, show me the average base premium for these liability products by product type, ordered from highest to lowest average."}, {"role": "assistant", "content": "SELECT product_type, AVG(base_premium) as avg_base_premium FROM insurance.insurance_products WHERE coverage_details LIKE '%liability%' AND is_active = true AND base_premium BETWEEN 100 AND 500 GROUP BY product_type ORDER BY avg_base_premium DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.lawyers ( lawyer_id.text, first_name.text, last_name.text, bar_number.text, firm_id.text, email.text, phone.text, specialization.text, hire_date.timestamp, is_partner.boolean )\nCREATE TABLE legal_services.documents ( document_id.text, case_id.text, document_name.text, document_type.text, storage_path.text, uploaded_by_lawyer_id.text, upload_timestamp.timestamp, version.integer, description.text )\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Find the total number of distinct lawyers and distinct documents in the database."}, {"role": "assistant", "content": "SELECT (SELECT COUNT(DISTINCT lawyer_id) FROM legal_services.lawyers) AS distinct_lawyer_count, (SELECT COUNT(DISTINCT document_id) FROM legal_services.documents) AS distinct_document_count;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash text, transaction_index bigint, from_address text, contract_address text, symbol text, total_supply text, name text, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info text, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )\nCREATE TABLE nft_holder_historical ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk integer )\nCREATE TABLE sui_coins ( object_id text, status text, coin_type text, balance text, owner text )\nCREATE TABLE sui_coins_metadata ( object_id text, coin_type text, status text, decimals bigint, description text, icon_url text, symbol text, name text )\nCREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_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 )\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE mud_holesky_redstone ( address text, table_id text, key_bytes text, key0 text, key1 text, static_data text, encoded_lengths text, dynamic_data text, is_deleted boolean, block_number bigint, log_index bigint )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )\n", "conversations": [{"role": "user", "content": "List all wallet addresses holding NFT contract '0xbbbb...' and token ID '99'."}, {"role": "assistant", "content": "SELECT wallet_address, amount\nFROM nft_holders\nWHERE contract_address = '0xbbbb...'\n AND token_id = '99';"}, {"role": "user", "content": "How many unique holders are there?"}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT wallet_address) AS unique_holders\nFROM nft_holders\nWHERE contract_address = '0xbbbb...'\n AND token_id = '99';"}, {"role": "user", "content": "Only include wallets holding more than one token."}, {"role": "assistant", "content": "SELECT wallet_address, amount\nFROM nft_holders\nWHERE contract_address = '0xbbbb...'\n AND token_id = '99'\n AND CAST(amount AS numeric) > 1;"}, {"role": "user", "content": "Sort the result by amount descending and limit to top 5."}, {"role": "assistant", "content": "SELECT wallet_address, amount\nFROM nft_holders\nWHERE contract_address = '0xbbbb...'\n AND token_id = '99'\n AND CAST(amount AS numeric) > 1\nORDER BY CAST(amount AS numeric) DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.follows ( follow_id text, follower_user_id text, following_user_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Find pairs of user IDs (A, B) such that user A follows user B, and user B also follows user A (mutual follows). List user A's ID and user B's ID."}, {"role": "assistant", "content": "SELECT T1.follower_user_id AS user_a, T1.following_user_id AS user_b FROM social_media.follows AS T1 JOIN social_media.follows AS T2 ON T1.follower_user_id = T2.following_user_id AND T1.following_user_id = T2.follower_user_id;"}, {"role": "user", "content": "Only show pairs where user B started following user A after user A started following user B. Also include the follow dates for both."}, {"role": "assistant", "content": "SELECT T1.follower_user_id AS user_a, T1.following_user_id AS user_b, T1.created_at AS user_a_follows_b_date, T2.created_at AS user_b_follows_a_date FROM social_media.follows AS T1 JOIN social_media.follows AS T2 ON T1.follower_user_id = T2.following_user_id AND T1.following_user_id = T2.follower_user_id WHERE T2.created_at > T1.created_at;"}, {"role": "user", "content": "Order the results by the date user B followed user A, from oldest to newest."}, {"role": "assistant", "content": "SELECT T1.follower_user_id AS user_a, T1.following_user_id AS user_b, T1.created_at AS user_a_follows_b_date, T2.created_at AS user_b_follows_a_date FROM social_media.follows AS T1 JOIN social_media.follows AS T2 ON T1.follower_user_id = T2.following_user_id AND T1.following_user_id = T2.follower_user_id WHERE T2.created_at > T1.created_at ORDER BY user_b_follows_a_date ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "How many lawyers are there in each specialization, and what is the count per specialization?"}, {"role": "assistant", "content": "SELECT specialization,\n COUNT(*) AS lawyer_count\nFROM legal_services.lawyers\nGROUP BY specialization;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean )\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me the usernames and the group names of group chats where each user has posted at least one post containing a hashtag."}, {"role": "assistant", "content": "SELECT u.username, c.group_name\nFROM social_media.users u\nJOIN social_media.posts p ON u.user_id = p.user_id\nJOIN social_media.post_hashtags ph ON p.post_id = ph.post_id\nJOIN social_media.conversations c ON p.user_id = u.user_id AND c.is_group_chat = TRUE\nGROUP BY u.username, c.group_name;"}, {"role": "user", "content": "Can you also show when each group chat was created?"}, {"role": "assistant", "content": "SELECT u.username, c.group_name, c.created_at\nFROM social_media.users u\nJOIN social_media.posts p ON u.user_id = p.user_id\nJOIN social_media.post_hashtags ph ON p.post_id = ph.post_id\nJOIN social_media.conversations c ON p.user_id = u.user_id AND c.is_group_chat = TRUE\nGROUP BY u.username, c.group_name, c.created_at;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.users ( user_id text, username text, email text, password_hash text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the usernames and registration dates for all users whose email ends with '@gmail.com'."}, {"role": "assistant", "content": "SELECT username, created_at FROM web3.users WHERE email LIKE '%@gmail.com';"}, {"role": "user", "content": "Actually, can you also include how many such users there are in total in the result?"}, {"role": "assistant", "content": "SELECT username, created_at, COUNT(*) OVER() AS total_gmail_users FROM web3.users WHERE email LIKE '%@gmail.com';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.posts ( post_id text, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id text, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )\nCREATE TABLE social_media.follows ( follow_id text, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id text, tag_name text, created_at timestamp )\nCREATE TABLE social_media.messages ( message_id text, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp )\nCREATE TABLE social_media.conversations ( conversation_id text, created_at timestamp, last_message_at timestamp, is_group_chat boolean, group_name text )\nCREATE TABLE social_media.conversation_participants ( participant_id text, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.notifications ( notification_id text, recipient_user_id text, sender_user_id text, notification_type text, target_entity_id text, target_entity_type text, created_at timestamp, read_at timestamp )\nCREATE TABLE social_media.user_settings ( setting_id text, user_id text, theme text, email_notifications_enabled boolean, push_notifications_enabled boolean, private_profile boolean, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve all public posts that have geolocation coordinates specified, showing post_id, user_id, location_lat, location_lon, ordered by created_at descending."}, {"role": "assistant", "content": "SELECT post_id, user_id, location_lat, location_lon\nFROM social_media.posts\nWHERE visibility = 'public'\n AND location_lat IS NOT NULL\n AND location_lon IS NOT NULL\nORDER BY created_at DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.notifications ( notification_id.text, recipient_user_id.text, sender_user_id.text, notification_type.text, target_entity_id.text, target_entity_type.text, created_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "How many notifications are there for each distinct notification type?"}, {"role": "assistant", "content": "SELECT notification_type, COUNT(*) FROM social_media.notifications GROUP BY notification_type;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "I need a count of appointments per patient that took place between '2024-04-01' and '2024-04-30', showing patient_id, first_name, last_name, and the total number of appointments."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nJOIN healthcare.appointments a ON p.patient_id = a.patient_id\nWHERE a.appointment_time BETWEEN '2024-04-01' AND '2024-04-30'\nGROUP BY p.patient_id, p.first_name, p.last_name;"}, {"role": "user", "content": "Only include patients who had at least 2 appointments in that period."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.patients p\nJOIN healthcare.appointments a ON p.patient_id = a.patient_id\nWHERE a.appointment_time BETWEEN '2024-04-01' AND '2024-04-30'\nGROUP BY p.patient_id, p.first_name, p.last_name\nHAVING COUNT(a.appointment_id) >= 2;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (property_id)\n)\nCREATE TABLE hospitality_technology.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )\nCREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "List all staff members who have responded to at least one review in the last 6 months, including their first and last names and the count of responses."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name, COUNT(r.review_id) AS response_count\nFROM hospitality_technology.reviews AS r\nJOIN hospitality_technology.staff AS s\n ON r.response_staff_id = s.staff_id\nWHERE r.response_date >= CURRENT_DATE - INTERVAL '6 months'\nGROUP BY s.staff_id, s.first_name, s.last_name;"}, {"role": "user", "content": "Actually, only include responses to public reviews."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name, COUNT(r.review_id) AS response_count\nFROM hospitality_technology.reviews AS r\nJOIN hospitality_technology.staff AS s\n ON r.response_staff_id = s.staff_id\nWHERE r.response_date >= CURRENT_DATE - INTERVAL '6 months'\n AND r.is_public = TRUE\nGROUP BY s.staff_id, s.first_name, s.last_name;"}, {"role": "user", "content": "Also include the average response time in days for each staff member."}, {"role": "assistant", "content": "SELECT s.staff_id, s.first_name, s.last_name,\n COUNT(r.review_id) AS response_count,\n AVG(EXTRACT(EPOCH FROM (r.response_date - r.review_date)) / 86400) AS avg_response_days\nFROM hospitality_technology.reviews AS r\nJOIN hospitality_technology.staff AS s\n ON r.response_staff_id = s.staff_id\nWHERE r.response_date >= CURRENT_DATE - INTERVAL '6 months'\n AND r.is_public = TRUE\nGROUP BY s.staff_id, s.first_name, s.last_name;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id character varying(64) NOT NULL, national_id_number character varying(128) NOT NULL UNIQUE, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(20), primary_address text NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), registration_date timestamp NOT NULL, is_verified boolean DEFAULT false, PRIMARY KEY (citizen_id) )\nCREATE TABLE government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\nCREATE TABLE government_services.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_id) )\nCREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, submitted_at timestamp NOT NULL, status character varying(50) NOT NULL, last_updated_at timestamp NOT NULL, assigned_employee_id character varying(64), decision_date date, notes text, reference_number character varying(100) UNIQUE, PRIMARY KEY (application_id) )\nCREATE TABLE government_services.payments ( payment_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, service_id character varying(64), amount numeric(12, 2) NOT NULL, currency character varying(3) NOT NULL DEFAULT 'USD', payment_method character varying(50), payment_provider_reference character varying(128), payment_timestamp timestamp NOT NULL, status character varying(30) NOT NULL, notes text, PRIMARY KEY (payment_id) )\nCREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "For each service location in Texas, provide the location name, city, and the number of appointments scheduled there by verified citizens."}, {"role": "assistant", "content": "SELECT sl.location_name, sl.city, COUNT(a.appointment_id) AS appointment_count\nFROM government_services.service_locations sl\nJOIN government_services.appointments a ON sl.location_id = a.location_id\nJOIN government_services.citizens c ON a.citizen_id = c.citizen_id AND c.is_verified = TRUE\nWHERE sl.state = 'Texas'\nGROUP BY sl.location_id, sl.location_name, sl.city;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.staff (\n staff_id character varying(64) NOT NULL, -- unique identifier for the staff member\n property_id character varying(64) NOT NULL, -- FK to properties table (primary property)\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge\n work_email character varying(255) UNIQUE, -- staff member's work email\n work_phone character varying(30),\n hire_date date NOT NULL,\n termination_date date, -- date employment ended (if applicable)\n is_active boolean NOT NULL DEFAULT true, -- currently employed flag\n access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin)\n manager_id character varying(64), -- FK to staff table (self-referencing for supervisor)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (staff_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Which staff members have never been assigned a manager? List their full names and property IDs."}, {"role": "assistant", "content": "SELECT staff_id, first_name, last_name, property_id\nFROM hospitality_technology.staff\nWHERE manager_id IS NULL;"}, {"role": "user", "content": "Also include their work email and only show currently active staff."}, {"role": "assistant", "content": "SELECT staff_id, first_name, last_name, property_id, work_email\nFROM hospitality_technology.staff\nWHERE manager_id IS NULL AND is_active = true;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "How many reservations have been booked each month in 2023?"}, {"role": "assistant", "content": "SELECT DATE_TRUNC('month', created_at) AS month,\n COUNT(*) AS reservation_count\nFROM hospitality_technology.reservations\nWHERE created_at >= '2023-01-01' AND created_at < '2024-01-01'\nGROUP BY month;"}, {"role": "user", "content": "Actually, exclude reservations with status 'Canceled' and order by month."}, {"role": "assistant", "content": "SELECT DATE_TRUNC('month', created_at) AS month,\n COUNT(*) AS reservation_count\nFROM hospitality_technology.reservations\nWHERE created_at >= '2023-01-01'\n AND created_at < '2024-01-01'\n AND status <> 'Canceled'\nGROUP BY month\nORDER BY month;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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) )\n", "conversations": [{"role": "user", "content": "Find pairs of patients who share the same last name. Show the patient IDs, full names, and the shared last name."}, {"role": "assistant", "content": "SELECT p1.patient_id AS patient1_id, p1.first_name AS patient1_first_name, p1.last_name AS patient1_last_name, p2.patient_id AS patient2_id, p2.first_name AS patient2_first_name, p2.last_name AS patient2_last_name, p1.last_name AS shared_last_name FROM healthcare.patients p1 JOIN healthcare.patients p2 ON p1.last_name = p2.last_name AND p1.patient_id < p2.patient_id;"}, {"role": "user", "content": "Now, only include pairs where they also share the same date of birth."}, {"role": "assistant", "content": "SELECT p1.patient_id AS patient1_id, p1.first_name AS patient1_first_name, p1.last_name AS patient1_last_name, p2.patient_id AS patient2_id, p2.first_name AS patient2_first_name, p2.last_name AS patient2_last_name, p1.last_name AS shared_last_name, p1.date_of_birth AS shared_date_of_birth FROM healthcare.patients p1 JOIN healthcare.patients p2 ON p1.last_name = p2.last_name AND p1.date_of_birth = p2.date_of_birth AND p1.patient_id < p2.patient_id;"}, {"role": "user", "content": "Could you also restrict the results to only include pairs where at least one patient has a non-null phone number?"}, {"role": "assistant", "content": "SELECT p1.patient_id AS patient1_id, p1.first_name AS patient1_first_name, p1.last_name AS patient1_last_name, p2.patient_id AS patient2_id, p2.first_name AS patient2_first_name, p2.last_name AS patient2_last_name, p1.last_name AS shared_last_name, p1.date_of_birth AS shared_date_of_birth FROM healthcare.patients p1 JOIN healthcare.patients p2 ON p1.last_name = p2.last_name AND p1.date_of_birth = p2.date_of_birth AND p1.patient_id < p2.patient_id WHERE p1.phone_number IS NOT NULL OR p2.phone_number IS NOT NULL;"}, {"role": "user", "content": "Finally, sort the results by shared last name, then date of birth, ascending."}, {"role": "assistant", "content": "SELECT p1.patient_id AS patient1_id, p1.first_name AS patient1_first_name, p1.last_name AS patient1_last_name, p2.patient_id AS patient2_id, p2.first_name AS patient2_first_name, p2.last_name AS patient2_last_name, p1.last_name AS shared_last_name, p1.date_of_birth AS shared_date_of_birth FROM healthcare.patients p1 JOIN healthcare.patients p2 ON p1.last_name = p2.last_name AND p1.date_of_birth = p2.date_of_birth AND p1.patient_id < p2.patient_id WHERE p1.phone_number IS NOT NULL OR p2.phone_number IS NOT NULL ORDER BY shared_last_name ASC, shared_date_of_birth ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE healthcare.doctors (\n doctor_id character varying(64) NOT NULL, -- unique identifier for the doctor\n first_name character varying(100) NOT NULL, -- doctor's first name\n last_name character varying(100) NOT NULL, -- doctor's last name\n specialty character varying(100) NOT NULL, -- doctor's medical specialty\n license_number character varying(50) UNIQUE NOT NULL, -- doctor's medical license number\n phone_number character varying(20), -- doctor's contact phone\n email character varying(128) UNIQUE, -- doctor's contact email\n hospital_affiliation_id character varying(64), -- FK to hospitals table (optional)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (doctor_id)\n)\nCREATE TABLE healthcare.appointments ( appointment_id.text, patient_id.text, doctor_id.text, appointment_time.timestamp, duration_minutes.integer, reason.text, status.text, location_id.text, notes.text, created_at.timestamp )\nCREATE TABLE healthcare.medical_records (\n record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)\n record_date timestamp with time zone NOT NULL, -- date the record/observation was made\n chief_complaint text, -- patient's primary reason for visit\n present_illness_history text, -- detailed history of the current issue\n past_medical_history text, -- relevant past conditions/surgeries\n physical_examination_notes text, -- findings from the physical exam\n assessment text, -- doctor's assessment/diagnosis summary\n treatment_plan text, -- planned course of action\n vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (record_id)\n)\nCREATE TABLE healthcare.diagnoses (\n diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry\n record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)\n diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)\n code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used\n description text, -- textual description of the diagnosis\n diagnosis_date date NOT NULL, -- date the diagnosis was made\n status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out\n is_chronic boolean DEFAULT false, -- flag for chronic conditions\n PRIMARY KEY (diagnosis_id)\n)\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "List each doctor's ID, first name, last name, and the total number of appointments they have. Display columns doctor_id, first_name, last_name, and appointment_count."}, {"role": "assistant", "content": "SELECT d.doctor_id,\n d.first_name,\n d.last_name,\n COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.doctors d\nLEFT JOIN healthcare.appointments a\n ON d.doctor_id = a.doctor_id\nGROUP BY d.doctor_id, d.first_name, d.last_name;"}, {"role": "user", "content": "Actually, only include doctors with more than 5 appointments and sort by appointment_count descending."}, {"role": "assistant", "content": "SELECT d.doctor_id,\n d.first_name,\n d.last_name,\n COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.doctors d\nLEFT JOIN healthcare.appointments a\n ON d.doctor_id = a.doctor_id\nGROUP BY d.doctor_id, d.first_name, d.last_name\nHAVING COUNT(a.appointment_id) > 5\nORDER BY appointment_count DESC;"}, {"role": "user", "content": "Add each doctor's specialty to the output as well."}, {"role": "assistant", "content": "SELECT d.doctor_id,\n d.first_name,\n d.last_name,\n d.specialty,\n COUNT(a.appointment_id) AS appointment_count\nFROM healthcare.doctors d\nLEFT JOIN healthcare.appointments a\n ON d.doctor_id = a.doctor_id\nGROUP BY d.doctor_id, d.first_name, d.last_name, d.specialty\nHAVING COUNT(a.appointment_id) > 5\nORDER BY appointment_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE nft_holders ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )\nCREATE TABLE nft_holder_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE sui_coins_metadata (\n object_id varchar NOT NULL, -- object id of the coin metadata object\n coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN\n status varchar NOT NULL, -- coin status, eg. exists, deleted\n decimals bigint NOT NULL, -- decimals of the coin\n description varchar NOT NULL, -- description of the coin\n icon_url varchar NOT NULL, -- icon url of the coin\n symbol varchar NOT NULL, -- symbol of the coin\n name varchar NOT NULL -- name of the coin\n)\nCREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_info (\n block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)\n block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)\n tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)\n tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)\n tick varchar NOT NULL, -- Token tick\n max_supply decimal(38,0) NOT NULL, -- Max supply\n lim decimal(38,0) NOT NULL, -- Limit of each mint\n wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint\n dec integer NOT NULL, -- Decimal for minimum divie\n creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table)\n)\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )\n", "conversations": [{"role": "user", "content": "List collection name, contract address, token count, and floor price for NFT collections on the Ethereum blockchain."}, {"role": "assistant", "content": "SELECT name, contract_address, token_count, floor_price FROM nft_collections WHERE blockchain = 'Ethereum';"}, {"role": "user", "content": "Also include the average rarity score for NFTs within each collection."}, {"role": "assistant", "content": "SELECT nc.name, nc.contract_address, nc.token_count, nc.floor_price, AVG(nm.rarity_score) AS avg_rarity_score FROM nft_collections nc JOIN nft_metadata nm ON nc.contract_address = nm.contract_address WHERE nc.blockchain = 'Ethereum' GROUP BY nc.name, nc.contract_address, nc.token_count, nc.floor_price;"}, {"role": "user", "content": "Filter the results to only include collections with an average rarity score above 75."}, {"role": "assistant", "content": "SELECT nc.name, nc.contract_address, nc.token_count, nc.floor_price, AVG(nm.rarity_score) AS avg_rarity_score FROM nft_collections nc JOIN nft_metadata nm ON nc.contract_address = nm.contract_address WHERE nc.blockchain = 'Ethereum' GROUP BY nc.name, nc.contract_address, nc.token_count, nc.floor_price HAVING AVG(nm.rarity_score) > 75;"}, {"role": "user", "content": "Order the results by average rarity score descending and limit to the top 10 collections."}, {"role": "assistant", "content": "SELECT nc.name, nc.contract_address, nc.token_count, nc.floor_price, AVG(nm.rarity_score) AS avg_rarity_score FROM nft_collections nc JOIN nft_metadata nm ON nc.contract_address = nm.contract_address WHERE nc.blockchain = 'Ethereum' GROUP BY nc.name, nc.contract_address, nc.token_count, nc.floor_price HAVING AVG(nm.rarity_score) > 75 ORDER BY avg_rarity_score DESC LIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.securities ( security_id.text, ticker_symbol.text, isin_code.text, cusip_code.text, security_name.text, security_type.text, exchange.text, currency.text, issuer_name.text, sector.text, last_updated.timestamp )\n", "conversations": [{"role": "user", "content": "How many securities are there for each security type?"}, {"role": "assistant", "content": "SELECT security_type, COUNT(*) AS security_count FROM financial_services.securities GROUP BY security_type;"}, {"role": "user", "content": "Only show security types that have more than 50 securities."}, {"role": "assistant", "content": "SELECT security_type, COUNT(*) AS security_count FROM financial_services.securities GROUP BY security_type HAVING COUNT(*) > 50;"}, {"role": "user", "content": "Sort the result by the count in descending order."}, {"role": "assistant", "content": "SELECT security_type, COUNT(*) AS security_count FROM financial_services.securities GROUP BY security_type HAVING COUNT(*) > 50 ORDER BY security_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers (\n customer_id character varying(64) NOT NULL, -- unique identifier for the customer\n first_name character varying(100) NOT NULL, -- customer's first name\n last_name character varying(100) NOT NULL, -- customer's last name\n date_of_birth date NOT NULL, -- customer's date of birth\n ssn_hash character varying(128), -- Hashed social security number (or national ID)\n address_line1 character varying(255) NOT NULL,\n address_line2 character varying(255),\n city character varying(100) NOT NULL,\n state character varying(50) NOT NULL,\n zip_code character varying(20) NOT NULL,\n country character varying(50) NOT NULL DEFAULT 'USA',\n phone_number character varying(30),\n email character varying(128) UNIQUE, -- unique email address\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the customer record was created\n updated_at timestamp, -- when the customer record was last updated\n status character varying(20) NOT NULL DEFAULT 'Active', -- e.g., Active, Inactive, Prospect\n PRIMARY KEY (customer_id)\n)\nCREATE TABLE insurance.claims ( claim_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, incident_date timestamp NOT NULL, reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text NOT NULL, estimated_loss numeric(15, 2), status character varying(30) NOT NULL, settlement_amount numeric(15, 2), settlement_date date, claim_handler_id character varying(64), police_report_number character varying(100), PRIMARY KEY (claim_id) )\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE insurance.agents ( agent_id.text, first_name.text, last_name.text, agency_name.text, license_number.text, license_state.text, contact_email.text, contact_phone.text, hire_date.date, termination_date.date, status.text, commission_rate.numeric, manager_id.text )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\nCREATE TABLE insurance.policy_beneficiaries (\n beneficiary_id character varying(64) NOT NULL, -- unique identifier for the beneficiary entry\n policy_id character varying(64) NOT NULL, -- identifier of the life/relevant policy (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the beneficiary (could be FK to customers or store info directly)\n first_name character varying(100) NOT NULL, -- beneficiary first name (if not linking to customers table)\n last_name character varying(100) NOT NULL, -- beneficiary last name\n relationship character varying(50) NOT NULL, -- relationship to the policyholder (e.g., Spouse, Child, Parent)\n percentage_share numeric(5, 2) NOT NULL CHECK (percentage_share > 0 AND percentage_share <= 100), -- percentage of payout\n contact_info text, -- contact details for the beneficiary\n added_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (beneficiary_id),\n UNIQUE (policy_id, customer_id) -- Ensure a person is listed only once per policy\n)\n", "conversations": [{"role": "user", "content": "Show all claims and the full name of the customer who filed each claim."}, {"role": "assistant", "content": "SELECT T1.claim_id, T1.incident_date, T1.description, T2.first_name, T2.last_name FROM insurance.claims AS T1 JOIN insurance.customers AS T2 ON T1.customer_id = T2.customer_id"}, {"role": "user", "content": "Can you also include the ID of the claim handler for each claim?"}, {"role": "assistant", "content": "SELECT T1.claim_id, T1.incident_date, T1.description, T2.first_name, T2.last_name, T1.claim_handler_id FROM insurance.claims AS T1 JOIN insurance.customers AS T2 ON T1.customer_id = T2.customer_id"}, {"role": "user", "content": "Actually, only show claims with status 'Open' and an estimated loss greater than $10,000."}, {"role": "assistant", "content": "SELECT T1.claim_id, T1.incident_date, T1.description, T2.first_name, T2.last_name, T1.claim_handler_id FROM insurance.claims AS T1 JOIN insurance.customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.status = 'Open' AND T1.estimated_loss > 10000"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.posts ( post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, visibility character varying(20) NOT NULL DEFAULT 'public', location_lat numeric(9,6), location_lon numeric(9,6), PRIMARY KEY (post_id) )\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )\nCREATE TABLE social_media.post_hashtags (\n post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link\n post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id)\n hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id)\n PRIMARY KEY (post_hashtag_id),\n CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post\n)\nCREATE TABLE social_media.messages ( message_id text PRIMARY KEY, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp )\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.notifications ( notification_id.text, recipient_user_id.text, sender_user_id.text, notification_type.text, target_entity_id.text, target_entity_type.text, created_at.timestamp, read_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show a list of group chat names with their conversation_id, the total number of participants, and the total number of messages sent in each group chat."}, {"role": "assistant", "content": "SELECT c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS participant_count,\n COUNT(m.message_id) AS message_count\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nLEFT JOIN social_media.messages m ON c.conversation_id = m.conversation_id\nWHERE c.is_group_chat = TRUE\nGROUP BY c.conversation_id, c.group_name;"}, {"role": "user", "content": "Please filter to include only group chats that have at least 5 participants."}, {"role": "assistant", "content": "SELECT c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS participant_count,\n COUNT(m.message_id) AS message_count\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nLEFT JOIN social_media.messages m ON c.conversation_id = m.conversation_id\nWHERE c.is_group_chat = TRUE\nGROUP BY c.conversation_id, c.group_name\nHAVING COUNT(cp.participant_id) >= 5;"}, {"role": "user", "content": "Now order the results by message_count descending and limit to the top 10 group chats."}, {"role": "assistant", "content": "SELECT c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS participant_count,\n COUNT(m.message_id) AS message_count\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nLEFT JOIN social_media.messages m ON c.conversation_id = m.conversation_id\nWHERE c.is_group_chat = TRUE\nGROUP BY c.conversation_id, c.group_name\nHAVING COUNT(cp.participant_id) >= 5\nORDER BY message_count DESC\nLIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.service_orders ( order_id.text, reservation_id.text, guest_id.text, service_id.text, staff_id_ordered.text, staff_id_delivered.text, order_timestamp.timestamp, delivery_timestamp.timestamp, quantity.integer, unit_price.numeric, total_price.numeric, status.text, notes.text, bill_id.text )\nCREATE TABLE hospitality_technology.payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "Show all payments along with the guest's first and last name, and the staff member who processed each payment. Include payment_id, amount, currency_code, payment_timestamp, guest first_name, guest last_name, staff first_name, and staff last_name."}, {"role": "assistant", "content": "SELECT p.payment_id,\n p.amount,\n p.currency_code,\n p.payment_timestamp,\n g.first_name AS guest_first_name,\n g.last_name AS guest_last_name,\n s.first_name AS staff_first_name,\n s.last_name AS staff_last_name\nFROM hospitality_technology.payments p\nJOIN hospitality_technology.guests g ON p.guest_id = g.guest_id\nJOIN hospitality_technology.staff s ON p.staff_id_processed = s.staff_id;"}, {"role": "user", "content": "Filter to only include payments with status = 'Succeeded' and amount greater than 100."}, {"role": "assistant", "content": "SELECT p.payment_id,\n p.amount,\n p.currency_code,\n p.payment_timestamp,\n g.first_name AS guest_first_name,\n g.last_name AS guest_last_name,\n s.first_name AS staff_first_name,\n s.last_name AS staff_last_name\nFROM hospitality_technology.payments p\nJOIN hospitality_technology.guests g ON p.guest_id = g.guest_id\nJOIN hospitality_technology.staff s ON p.staff_id_processed = s.staff_id\nWHERE p.status = 'Succeeded'\n AND p.amount > 100;"}, {"role": "user", "content": "Also order the results by amount descending and limit to the top 10 payments."}, {"role": "assistant", "content": "SELECT p.payment_id,\n p.amount,\n p.currency_code,\n p.payment_timestamp,\n g.first_name AS guest_first_name,\n g.last_name AS guest_last_name,\n s.first_name AS staff_first_name,\n s.last_name AS staff_last_name\nFROM hospitality_technology.payments p\nJOIN hospitality_technology.guests g ON p.guest_id = g.guest_id\nJOIN hospitality_technology.staff s ON p.staff_id_processed = s.staff_id\nWHERE p.status = 'Succeeded'\n AND p.amount > 100\nORDER BY p.amount DESC\nLIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id text, post_id text, hashtag_id text )\nCREATE TABLE social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, recipient_user_id character varying(64) NOT NULL, sender_user_id character varying(64), notification_type character varying(30) NOT NULL, target_entity_id character varying(64), target_entity_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (notification_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List the five earliest hashtags created in 2024 along with their names."}, {"role": "assistant", "content": "SELECT hashtag_id, tag_name, created_at\nFROM social_media.hashtags\nWHERE created_at >= '2024-01-01' AND created_at < '2025-01-01'\nORDER BY created_at ASC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types (\n room_type_id character varying(64) NOT NULL, -- unique identifier for the room type\n property_id character varying(64) NOT NULL, -- FK to properties table (type might be property-specific)\n type_name character varying(100) NOT NULL, -- e.g., Standard King, Deluxe Queen, Executive Suite\n description text, -- description of the room type\n base_rate numeric(10, 2) NOT NULL, -- standard price per night\n max_occupancy integer NOT NULL, -- maximum number of guests\n bed_type character varying(50), -- e.g., King, Queen, 2 Doubles, Twin\n area_sqft numeric(8,2), -- size of the room in square feet\n amenities text, -- comma-separated list or JSON of amenities\n PRIMARY KEY (room_type_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Retrieve all room types with a base_rate above 150 for each property."}, {"role": "assistant", "content": "SELECT property_id, type_name, base_rate\nFROM hospitality_technology.room_types\nWHERE base_rate > 150;"}, {"role": "user", "content": "Also filter to only include room types with max_occupancy >= 3."}, {"role": "assistant", "content": "SELECT property_id, type_name, base_rate\nFROM hospitality_technology.room_types\nWHERE base_rate > 150\n AND max_occupancy >= 3;"}, {"role": "user", "content": "Finally, show guest first and last names of guests created after '2023-01-01' who could book these room types."}, {"role": "assistant", "content": "SELECT g.first_name, g.last_name, rt.property_id, rt.type_name, rt.base_rate\nFROM hospitality_technology.room_types rt\nCROSS JOIN hospitality_technology.guests g\nWHERE rt.base_rate > 150\n AND rt.max_occupancy >= 3\n AND g.created_at > '2023-01-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\n", "conversations": [{"role": "user", "content": "Provide a list of all future appointments showing appointment_id, scheduled_start_time, location_name, city, and state."}, {"role": "assistant", "content": "SELECT\n a.appointment_id,\n a.scheduled_start_time,\n sl.location_name,\n sl.city,\n sl.state\nFROM appointments a\nJOIN service_locations sl\n ON a.location_id = sl.location_id\nWHERE a.scheduled_start_time > CURRENT_TIMESTAMP;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id.text, patient_id.text, plan_id.text, policy_number.text, group_number.text, subscriber_name.text, effective_date.date, expiration_date.date, is_primary.boolean )\n", "conversations": [{"role": "user", "content": "Show me a list of all insurance policies along with the subscriber's name and the effective and expiration dates for each policy, including the associated plan ID."}, {"role": "assistant", "content": "SELECT policy_number, subscriber_name, effective_date, expiration_date, plan_id FROM healthcare.patient_insurance;"}, {"role": "user", "content": "Now, I only want to see policies that are primary and do not have a group number assigned. Please also include the patient_id."}, {"role": "assistant", "content": "SELECT policy_number, subscriber_name, effective_date, expiration_date, plan_id, patient_id FROM healthcare.patient_insurance WHERE is_primary = TRUE AND group_number IS NULL;"}, {"role": "user", "content": "Actually, please filter further to only show policies that expire after 2024-12-31."}, {"role": "assistant", "content": "SELECT policy_number, subscriber_name, effective_date, expiration_date, plan_id, patient_id FROM healthcare.patient_insurance WHERE is_primary = TRUE AND group_number IS NULL AND expiration_date > '2024-12-31';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id text PRIMARY KEY, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\n", "conversations": [{"role": "user", "content": "Find all pairs of drivers who share the same status. Include both driver_ids, full names, and the shared status."}, {"role": "assistant", "content": "SELECT d1.driver_id AS driver1_id, d1.first_name || ' ' || d1.last_name AS driver1_name, d2.driver_id AS driver2_id, d2.first_name || ' ' || d2.last_name AS driver2_name, d1.status FROM transportation.drivers d1 JOIN transportation.drivers d2 ON d1.status = d2.status AND d1.driver_id < d2.driver_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.fuel_logs (\n fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled\n trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred\n log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred\n fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type)\n quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh)\n unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh)\n cost_per_unit numeric(8, 4), -- price per unit of fuel\n total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase\n odometer_reading integer, -- vehicle mileage at time of fueling\n location_id character varying(64), -- identifier of the fueling station/location\n PRIMARY KEY (fuel_log_id)\n)\n", "conversations": [{"role": "user", "content": "Show all fuel logs for vehicle_id 'VH123', including the timestamp, fuel type, quantity, and the location_id. Sort the list by timestamp descending."}, {"role": "assistant", "content": "SELECT fuel_log_id, log_timestamp, fuel_type, quantity, location_id\nFROM transportation.fuel_logs\nWHERE vehicle_id = 'VH123'\nORDER BY log_timestamp DESC;"}, {"role": "user", "content": "Can you also include the odometer reading and total cost for each fuel log in the result?"}, {"role": "assistant", "content": "SELECT fuel_log_id, log_timestamp, fuel_type, quantity, location_id, odometer_reading, total_cost\nFROM transportation.fuel_logs\nWHERE vehicle_id = 'VH123'\nORDER BY log_timestamp DESC;"}, {"role": "user", "content": "I only want to see records where the total_cost is above 100."}, {"role": "assistant", "content": "SELECT fuel_log_id, log_timestamp, fuel_type, quantity, location_id, odometer_reading, total_cost\nFROM transportation.fuel_logs\nWHERE vehicle_id = 'VH123'\n AND total_cost > 100\nORDER BY log_timestamp DESC;"}, {"role": "user", "content": "Actually, please limit the results to just the 5 most recent logs."}, {"role": "assistant", "content": "SELECT fuel_log_id, log_timestamp, fuel_type, quantity, location_id, odometer_reading, total_cost\nFROM transportation.fuel_logs\nWHERE vehicle_id = 'VH123'\n AND total_cost > 100\nORDER BY log_timestamp DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )\nCREATE TABLE transportation.maintenance_logs ( log_id.text, vehicle_id.text, service_date.date, odometer_reading.integer, service_type.text, description.text, cost.numeric, mechanic_name.text, next_service_due_date.date )\nCREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp )\nCREATE TABLE transportation.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )\n", "conversations": [{"role": "user", "content": "List all routes showing the route_number, origin_location_id, destination_location_id, distance_km, and type."}, {"role": "assistant", "content": "SELECT\n route_number,\n origin_location_id,\n destination_location_id,\n distance_km,\n type\nFROM transportation.routes;"}, {"role": "user", "content": "Only include routes where distance_km is less than 100."}, {"role": "assistant", "content": "SELECT\n route_number,\n origin_location_id,\n destination_location_id,\n distance_km,\n type\nFROM transportation.routes\nWHERE distance_km < 100;"}, {"role": "user", "content": "Also, sort the results by estimated_duration_minutes in ascending order."}, {"role": "assistant", "content": "SELECT\n route_number,\n origin_location_id,\n destination_location_id,\n distance_km,\n type,\n estimated_duration_minutes\nFROM transportation.routes\nWHERE distance_km < 100\nORDER BY estimated_duration_minutes ASC;"}, {"role": "user", "content": "Actually, I want to see the duration per kilometer (estimated_duration_minutes divided by distance_km) as a new column named duration_per_km. Can you add that?"}, {"role": "assistant", "content": "SELECT\n route_number,\n origin_location_id,\n destination_location_id,\n distance_km,\n type,\n estimated_duration_minutes,\n estimated_duration_minutes / distance_km AS duration_per_km\nFROM transportation.routes\nWHERE distance_km < 100\nORDER BY estimated_duration_minutes ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.agencies ( agency_id text PRIMARY KEY, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )\nCREATE TABLE government_services.applications ( application_id text PRIMARY KEY, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees ( employee_id text PRIMARY KEY, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\nCREATE TABLE government_services.notifications ( notification_id text PRIMARY KEY, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "I want to get the total number of appointments scheduled at each agency in 2024. Please provide the agency name and the appointment count."}, {"role": "assistant", "content": "SELECT a.agency_name,\n COUNT(ap.appointment_id) AS appointment_count\nFROM government_services.appointments ap\nJOIN government_services.employees e\n ON ap.employee_id = e.employee_id\nJOIN government_services.agencies a\n ON e.agency_id = a.agency_id\nWHERE ap.scheduled_start_time BETWEEN '2024-01-01' AND '2024-12-31'\nGROUP BY a.agency_name;"}, {"role": "user", "content": "Now only include agencies with more than 100 appointments and order the results by appointment_count descending."}, {"role": "assistant", "content": "SELECT a.agency_name,\n COUNT(ap.appointment_id) AS appointment_count\nFROM government_services.appointments ap\nJOIN government_services.employees e\n ON ap.employee_id = e.employee_id\nJOIN government_services.agencies a\n ON e.agency_id = a.agency_id\nWHERE ap.scheduled_start_time BETWEEN '2024-01-01' AND '2024-12-31'\nGROUP BY a.agency_name\nHAVING COUNT(ap.appointment_id) > 100\nORDER BY appointment_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\nCREATE TABLE government_services.services ( service_id 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 )\nCREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "List the full name of employees and the names of the agencies they work for, but only for employees who are currently employed."}, {"role": "assistant", "content": "SELECT e.first_name || ' ' || e.last_name AS employee_full_name, a.agency_name\nFROM government_services.employees e\nJOIN government_services.agencies a ON e.agency_id = a.agency_id\nWHERE e.termination_date IS NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nIndex 'component_inventory'. Mapping: { properties: { inventory_record_id: { type: 'keyword' }, component_id: { type: 'keyword' }, quantity: { type: 'integer' }, location_warehouse: { type: 'keyword' }, location_bin: { type: 'keyword' }, received_date: { type: 'date' }, expiry_date: { type: 'date' }, batch_number: { type: 'keyword' }, last_updated: { type: 'date' } } }. Document _id can be inventory_record_id.\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u5009\u5eab\u306b\u3042\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5728\u5eab\u60c5\u5831\u3092\u53d6\u5f97\u3057\u305f\u3044\u3067\u3059\u3002\u5009\u5eab\u306e\u5834\u6240\u3001\u30d3\u30f3\u306e\u4f4d\u7f6e\u3001\u5728\u5eab\u6570\u91cf\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID\u3092\u8868\u793a\u3057\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SELECT location_warehouse, location_bin, quantity, component_id FROM component_inventory WHERE location_warehouse = 'specific_warehouse';"}, {"role": "user", "content": "\u53d7\u3051\u53d6\u308a\u65e5\u304c2023\u5e741\u67081\u65e5\u4ee5\u964d\u306e\u8a18\u9332\u3060\u3051\u306b\u7d5e\u308a\u8fbc\u3080\u3053\u3068\u306f\u3067\u304d\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SELECT location_warehouse, location_bin, quantity, component_id FROM component_inventory WHERE location_warehouse = 'specific_warehouse' AND received_date >= '2023-01-01';"}, {"role": "user", "content": "\u3055\u3089\u306b\u3001\u6700\u7d42\u66f4\u65b0\u65e5\u304c\u904e\u53bb1\u30f6\u6708\u4ee5\u5185\u306e\u3082\u306e\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3067\u304d\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SELECT location_warehouse, location_bin, quantity, component_id FROM component_inventory WHERE location_warehouse = 'specific_warehouse' AND received_date >= '2023-01-01' AND last_updated >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);"}, {"role": "user", "content": "\u6700\u5f8c\u306b\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID\u3054\u3068\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u3001\u5728\u5eab\u6570\u91cf\u306e\u5408\u8a08\u3092\u8868\u793a\u3057\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SELECT location_warehouse, location_bin, component_id, SUM(quantity) AS total_quantity FROM component_inventory WHERE location_warehouse = 'specific_warehouse' AND received_date >= '2023-01-01' AND last_updated >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY component_id, location_warehouse, location_bin;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.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 )\n", "conversations": [{"role": "user", "content": "Show the total payment amount and the number of payments processed by each staff member, including their staff_id_processed."}, {"role": "assistant", "content": "SELECT staff_id_processed, SUM(amount) AS total_payment_amount, COUNT(payment_id) AS payment_count FROM hospitality_technology.payments GROUP BY staff_id_processed;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (property_id)\n)\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.staff (\n staff_id character varying(64) NOT NULL, -- unique identifier for the staff member\n property_id character varying(64) NOT NULL, -- FK to properties table (primary property)\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge\n work_email character varying(255) UNIQUE, -- staff member's work email\n work_phone character varying(30),\n hire_date date NOT NULL,\n termination_date date, -- date employment ended (if applicable)\n is_active boolean NOT NULL DEFAULT true, -- currently employed flag\n access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin)\n manager_id character varying(64), -- FK to staff table (self-referencing for supervisor)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (staff_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "Show the number of staff members for each property, along with the property name."}, {"role": "assistant", "content": "SELECT p.property_name, COUNT(s.staff_id) AS staff_count\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.staff s ON p.property_id = s.property_id\nGROUP BY p.property_name;"}, {"role": "user", "content": "Only include properties with more than 20 staff members, and order the result by staff count descending."}, {"role": "assistant", "content": "SELECT p.property_name, COUNT(s.staff_id) AS staff_count\nFROM hospitality_technology.properties p\nJOIN hospitality_technology.staff s ON p.property_id = s.property_id\nGROUP BY p.property_name\nHAVING COUNT(s.staff_id) > 20\nORDER BY staff_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.achievements ( achievement_id uuid PRIMARY KEY, game_id uuid, name text, description text, icon_url text, points int, hidden boolean )\n", "conversations": [{"role": "user", "content": "List all pairs of achievements in the same game, returning game_id, the first achievement name as achv1, and the second as achv2."}, {"role": "assistant", "content": "SELECT a1.game_id, a1.name AS achv1, a2.name AS achv2\nFROM achievements a1\nJOIN achievements a2\n ON a1.game_id = a2.game_id\n AND a1.achievement_id < a2.achievement_id;"}, {"role": "user", "content": "Only include pairs where the sum of their points exceeds 150."}, {"role": "assistant", "content": "SELECT a1.game_id,\n a1.name AS achv1,\n a2.name AS achv2\nFROM achievements a1\nJOIN achievements a2\n ON a1.game_id = a2.game_id\n AND a1.achievement_id < a2.achievement_id\nWHERE a1.points + a2.points > 150;"}, {"role": "user", "content": "Exclude any pairs where either achievement is hidden."}, {"role": "assistant", "content": "SELECT a1.game_id,\n a1.name AS achv1,\n a2.name AS achv2\nFROM achievements a1\nJOIN achievements a2\n ON a1.game_id = a2.game_id\n AND a1.achievement_id < a2.achievement_id\nWHERE a1.points + a2.points > 150\n AND a1.hidden = false\n AND a2.hidden = false;"}, {"role": "user", "content": "Finally, order the results by the combined points descending."}, {"role": "assistant", "content": "SELECT a1.game_id,\n a1.name AS achv1,\n a2.name AS achv2\nFROM achievements a1\nJOIN achievements a2\n ON a1.game_id = a2.game_id\n AND a1.achievement_id < a2.achievement_id\nWHERE a1.points + a2.points > 150\n AND a1.hidden = false\n AND a2.hidden = false\nORDER BY (a1.points + a2.points) DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\nCREATE TABLE financial_services.accounts ( account_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, account_number character varying(128) NOT NULL UNIQUE, account_type character varying(50) NOT NULL, balance numeric(19, 4) NOT NULL DEFAULT 0.00, currency character varying(3) NOT NULL, opened_date date NOT NULL, status character varying(32) NOT NULL, interest_rate numeric(5, 4), last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (account_id), FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id) )\nCREATE TABLE financial_services.transactions ( transaction_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, related_account_id character varying(64), transaction_type character varying(50) NOT NULL, amount numeric(19, 4) NOT NULL, currency character varying(3) NOT NULL, transaction_date timestamp NOT NULL, effective_date date NOT NULL, description text, status character varying(32) NOT NULL, reference_number character varying(128), PRIMARY KEY (transaction_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (related_account_id) REFERENCES financial_services.accounts(account_id) )\nCREATE TABLE financial_services.trades ( trade_id text PRIMARY KEY, account_id text, security_id text, order_id text, trade_type text, quantity numeric, price_per_unit numeric, total_amount numeric, commission numeric, trade_timestamp timestamp, settlement_date date, status text, execution_venue text )\nCREATE TABLE financial_services.market_data (\n data_point_id bigserial NOT NULL, -- auto-incrementing primary key\n security_id character varying(64) NOT NULL, -- identifier for the security\n data_timestamp timestamp NOT NULL, -- timestamp for the data point (e.g., end of day, intraday)\n open_price numeric(19, 8), -- opening price for the period\n high_price numeric(19, 8), -- highest price during the period\n low_price numeric(19, 8), -- lowest price during the period\n close_price numeric(19, 8) NOT NULL, -- closing price for the period\n adjusted_close_price numeric(19, 8), -- closing price adjusted for dividends and splits\n volume bigint, -- trading volume during the period\n source character varying(50), -- source of the market data (e.g., Bloomberg, Refinitiv)\n PRIMARY KEY (data_point_id),\n UNIQUE (security_id, data_timestamp), -- Ensure unique data point per security per time\n FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id)\n)\nCREATE TABLE financial_services.loans ( loan_id.text, account_id.text, loan_type.text, principal_amount.numeric, current_principal_balance.numeric, interest_rate.numeric, term_months.integer, origination_date.date, maturity_date.date, monthly_payment.numeric, collateral_description.text, status.text )\n", "conversations": [{"role": "user", "content": "For each account, show the account number, currency, and the sum of all incoming transaction amounts, where an incoming transaction is one where the account appears as related_account_id."}, {"role": "assistant", "content": "SELECT a.account_number, a.currency, COALESCE(SUM(t.amount), 0) AS total_incoming\nFROM financial_services.accounts a\nLEFT JOIN financial_services.transactions t ON a.account_id = t.related_account_id\nGROUP BY a.account_id, a.account_number, a.currency;"}, {"role": "user", "content": "Only include accounts with total incoming over 2000 and show the account type as well. Please order by total_incoming descending."}, {"role": "assistant", "content": "SELECT a.account_number, a.currency, a.account_type, COALESCE(SUM(t.amount), 0) AS total_incoming\nFROM financial_services.accounts a\nLEFT JOIN financial_services.transactions t ON a.account_id = t.related_account_id\nGROUP BY a.account_id, a.account_number, a.currency, a.account_type\nHAVING COALESCE(SUM(t.amount), 0) > 2000\nORDER BY total_incoming DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Show the total payment amount grouped by currency_code and filtered to only include payments with status 'Pending' or 'Failed'."}, {"role": "assistant", "content": "SELECT currency_code, SUM(amount) AS total_amount FROM hospitality_technology.payments WHERE status IN ('Pending', 'Failed') GROUP BY currency_code;"}, {"role": "user", "content": "Actually, please break down the result further by payment method as well."}, {"role": "assistant", "content": "SELECT currency_code, payment_method, SUM(amount) AS total_amount FROM hospitality_technology.payments WHERE status IN ('Pending', 'Failed') GROUP BY currency_code, payment_method;"}, {"role": "user", "content": "Can you also count the number of distinct guests for each combination of currency_code and payment_method in the result?"}, {"role": "assistant", "content": "SELECT currency_code, payment_method, SUM(amount) AS total_amount, COUNT(DISTINCT guest_id) AS guest_count FROM hospitality_technology.payments WHERE status IN ('Pending', 'Failed') GROUP BY currency_code, payment_method;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.passengers ( passenger_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Count the number of passengers in each month of the year 2024 based on their created_at date."}, {"role": "assistant", "content": "SELECT EXTRACT(MONTH FROM created_at) AS month, COUNT(*) AS passenger_count\nFROM transportation.passengers\nWHERE created_at >= '2024-01-01' AND created_at < '2025-01-01'\nGROUP BY EXTRACT(MONTH FROM created_at)\nORDER BY month;"}, {"role": "user", "content": "Now, only include months where the passenger_count exceeds 50."}, {"role": "assistant", "content": "SELECT EXTRACT(MONTH FROM created_at) AS month, COUNT(*) AS passenger_count\nFROM transportation.passengers\nWHERE created_at >= '2024-01-01' AND created_at < '2025-01-01'\nGROUP BY EXTRACT(MONTH FROM created_at)\nHAVING COUNT(*) > 50\nORDER BY month;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Show me all replies to comments, including the reply's comment ID, the parent comment ID, and the content."}, {"role": "assistant", "content": "SELECT comment_id, parent_comment_id, content FROM social_media.comments WHERE parent_comment_id IS NOT NULL;"}, {"role": "user", "content": "I also want to see which post each reply was made on. Can you include the post ID as well?"}, {"role": "assistant", "content": "SELECT comment_id, parent_comment_id, post_id, content FROM social_media.comments WHERE parent_comment_id IS NOT NULL;"}, {"role": "user", "content": "Now, only show replies made after June 1, 2024."}, {"role": "assistant", "content": "SELECT comment_id, parent_comment_id, post_id, content FROM social_media.comments WHERE parent_comment_id IS NOT NULL AND created_at > '2024-06-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE cex_token_balance ( snapshot_time.text, chain.text, address.text, exchange.text, token_address.text, token_symbol.text, balance.numeric, usd_value.numeric, price.numeric )\n", "conversations": [{"role": "user", "content": "Which exchanges hold the largest total USD value of tokens on the BSC chain in the most recent snapshot, and what is the top token (by usd_value) held by each exchange?"}, {"role": "assistant", "content": "WITH latest_snapshot AS (\n SELECT MAX(snapshot_time) AS max_time FROM cex_token_balance\n),\nexchange_totals AS (\n SELECT \n c.exchange, \n SUM(c.usd_value) AS total_usd_value\n FROM cex_token_balance c\n JOIN latest_snapshot l ON c.snapshot_time = l.max_time\n WHERE c.chain = 'BSC'\n GROUP BY c.exchange\n),\ntop_token_per_exchange AS (\n SELECT c.exchange, c.token_symbol, c.usd_value, ROW_NUMBER() OVER (PARTITION BY c.exchange ORDER BY c.usd_value DESC) AS rn\n FROM cex_token_balance c\n JOIN latest_snapshot l ON c.snapshot_time = l.max_time\n WHERE c.chain = 'BSC'\n)\nSELECT \n t.exchange, \n e.total_usd_value, \n t.token_symbol AS top_token_symbol, \n t.usd_value AS top_token_usd_value\nFROM exchange_totals e\nJOIN top_token_per_exchange t ON e.exchange = t.exchange AND t.rn = 1\nORDER BY e.total_usd_value DESC;"}, {"role": "user", "content": "Can you add the number of distinct tokens each exchange holds on BSC in the latest snapshot to the result?"}, {"role": "assistant", "content": "WITH latest_snapshot AS (\n SELECT MAX(snapshot_time) AS max_time FROM cex_token_balance\n),\nexchange_totals AS (\n SELECT \n c.exchange, \n SUM(c.usd_value) AS total_usd_value,\n COUNT(DISTINCT c.token_symbol) AS token_count\n FROM cex_token_balance c\n JOIN latest_snapshot l ON c.snapshot_time = l.max_time\n WHERE c.chain = 'BSC'\n GROUP BY c.exchange\n),\ntop_token_per_exchange AS (\n SELECT c.exchange, c.token_symbol, c.usd_value, ROW_NUMBER() OVER (PARTITION BY c.exchange ORDER BY c.usd_value DESC) AS rn\n FROM cex_token_balance c\n JOIN latest_snapshot l ON c.snapshot_time = l.max_time\n WHERE c.chain = 'BSC'\n)\nSELECT \n t.exchange, \n e.total_usd_value, \n e.token_count,\n t.token_symbol AS top_token_symbol, \n t.usd_value AS top_token_usd_value\nFROM exchange_totals e\nJOIN top_token_per_exchange t ON e.exchange = t.exchange AND t.rn = 1\nORDER BY e.total_usd_value DESC;"}, {"role": "user", "content": "I'd like the results filtered so only exchanges holding more than $2,000,000 in total on BSC are included."}, {"role": "assistant", "content": "WITH latest_snapshot AS (\n SELECT MAX(snapshot_time) AS max_time FROM cex_token_balance\n),\nexchange_totals AS (\n SELECT \n c.exchange, \n SUM(c.usd_value) AS total_usd_value,\n COUNT(DISTINCT c.token_symbol) AS token_count\n FROM cex_token_balance c\n JOIN latest_snapshot l ON c.snapshot_time = l.max_time\n WHERE c.chain = 'BSC'\n GROUP BY c.exchange\n HAVING SUM(c.usd_value) > 2000000\n),\ntop_token_per_exchange AS (\n SELECT c.exchange, c.token_symbol, c.usd_value, ROW_NUMBER() OVER (PARTITION BY c.exchange ORDER BY c.usd_value DESC) AS rn\n FROM cex_token_balance c\n JOIN latest_snapshot l ON c.snapshot_time = l.max_time\n WHERE c.chain = 'BSC'\n)\nSELECT \n t.exchange, \n e.total_usd_value, \n e.token_count,\n t.token_symbol AS top_token_symbol, \n t.usd_value AS top_token_usd_value\nFROM exchange_totals e\nJOIN top_token_per_exchange t ON e.exchange = t.exchange AND t.rn = 1\nORDER BY e.total_usd_value DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.lawyers ( lawyer_id.text, first_name.text, last_name.text, bar_number.text, firm_id.text, email.text, phone.text, specialization.text, hire_date.timestamp, is_partner.boolean )\nCREATE TABLE legal_services.law_firms ( firm_id.text, firm_name.text, address.text, phone.text, website.text, founded_date.date, managing_partner_id.text )\nCREATE TABLE legal_services.cases ( case_id.text, case_number.text, case_name.text, client_id.text, lead_lawyer_id.text, case_type.text, status.text, date_opened.timestamp, date_closed.timestamp, description.text, court_jurisdiction.text )\nCREATE TABLE legal_services.time_entries ( entry_id.text, case_id.text, lawyer_id.text, date_worked.date, hours_spent.numeric, billing_rate.numeric, description.text, is_billable.boolean, is_billed.boolean, invoice_id.text, created_at.timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me the names of all law firms and the total number of lawyers associated with each firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, count(T2.lawyer_id) FROM legal_services.law_firms AS T1 JOIN legal_services.lawyers AS T2 ON T1.firm_id = T2.firm_id GROUP BY T1.firm_id, T1.firm_name"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.law_firms (\n firm_id character varying(64) NOT NULL, -- unique identifier for the law firm\n firm_name character varying(200) NOT NULL, -- official name of the law firm\n address text NOT NULL, -- primary address of the firm\n phone character varying(32), -- firm's main phone number\n website character varying(255), -- firm's website URL\n founded_date date, -- date the firm was established\n managing_partner_id character varying(64), -- FK to lawyers table (optional)\n PRIMARY KEY (firm_id)\n)\n", "conversations": [{"role": "user", "content": "Can you provide a list of all law firms, including their address and phone number?"}, {"role": "assistant", "content": "SELECT firm_id, firm_name, address, phone FROM legal_services.law_firms;"}, {"role": "user", "content": "I would like to see only those firms founded before 2010."}, {"role": "assistant", "content": "SELECT firm_id, firm_name, address, phone FROM legal_services.law_firms WHERE founded_date < '2010-01-01';"}, {"role": "user", "content": "Filter the list further to include only firms that have a phone number specified."}, {"role": "assistant", "content": "SELECT firm_id, firm_name, address, phone FROM legal_services.law_firms WHERE founded_date < '2010-01-01' AND phone IS NOT NULL;"}, {"role": "user", "content": "Please display the results ordered by firm name alphabetically."}, {"role": "assistant", "content": "SELECT firm_id, firm_name, address, phone FROM legal_services.law_firms WHERE founded_date < '2010-01-01' AND phone IS NOT NULL ORDER BY firm_name ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Give me the number of patient insurance policies for each plan where the policy is currently active. Return plan_id and policy_count."}, {"role": "assistant", "content": "SELECT\n plan_id,\n COUNT(*) AS policy_count\nFROM healthcare.patient_insurance\nWHERE (expiration_date IS NULL OR expiration_date >= CURRENT_DATE)\nGROUP BY plan_id;"}, {"role": "user", "content": "Now, only include plans where the count is greater than 5 and sort by policy_count descending."}, {"role": "assistant", "content": "SELECT\n plan_id,\n COUNT(*) AS policy_count\nFROM healthcare.patient_insurance\nWHERE (expiration_date IS NULL OR expiration_date >= CURRENT_DATE)\nGROUP BY plan_id\nHAVING COUNT(*) > 5\nORDER BY policy_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.market_data ( data_point_id bigint, security_id text, data_timestamp timestamp, open_price numeric, high_price numeric, low_price numeric, close_price numeric, adjusted_close_price numeric, volume bigint, source text )\n", "conversations": [{"role": "user", "content": "I need to compare consecutive daily close_prices for each security to find when the close_price increased compared to the previous day."}, {"role": "assistant", "content": "SELECT a.security_id, b.data_timestamp AS prev_date, b.close_price AS prev_close, a.data_timestamp AS curr_date, a.close_price AS curr_close\nFROM financial_services.market_data a\nJOIN financial_services.market_data b\n ON a.security_id = b.security_id\n AND CAST(a.data_timestamp AS date) = CAST(b.data_timestamp + INTERVAL '1 day' AS date)\nWHERE a.close_price > b.close_price;"}, {"role": "user", "content": "Now, restrict this to only securities whose average volume over the past 30 days exceeds 1,000,000."}, {"role": "assistant", "content": "WITH high_vol AS (\n SELECT security_id\n FROM financial_services.market_data\n WHERE data_timestamp >= NOW() - INTERVAL '30 days'\n GROUP BY security_id\n HAVING AVG(volume) > 1000000\n)\nSELECT a.security_id, b.data_timestamp AS prev_date, b.close_price AS prev_close, a.data_timestamp AS curr_date, a.close_price AS curr_close\nFROM financial_services.market_data a\nJOIN financial_services.market_data b\n ON a.security_id = b.security_id\n AND CAST(a.data_timestamp AS date) = CAST(b.data_timestamp + INTERVAL '1 day' AS date)\nJOIN high_vol h\n ON a.security_id = h.security_id\nWHERE a.close_price > b.close_price;"}, {"role": "user", "content": "Also, only include those increases where the percentage change between days is greater than 2%."}, {"role": "assistant", "content": "WITH high_vol AS (\n SELECT security_id\n FROM financial_services.market_data\n WHERE data_timestamp >= NOW() - INTERVAL '30 days'\n GROUP BY security_id\n HAVING AVG(volume) > 1000000\n)\nSELECT a.security_id,\n b.data_timestamp AS prev_date,\n b.close_price AS prev_close,\n a.data_timestamp AS curr_date,\n a.close_price AS curr_close,\n ROUND((a.close_price - b.close_price) / b.close_price * 100, 2) AS pct_change\nFROM financial_services.market_data a\nJOIN financial_services.market_data b\n ON a.security_id = b.security_id\n AND CAST(a.data_timestamp AS date) = CAST(b.data_timestamp + INTERVAL '1 day' AS date)\nJOIN high_vol h\n ON a.security_id = h.security_id\nWHERE (a.close_price - b.close_price) / b.close_price * 100 > 2;"}, {"role": "user", "content": "Finally, add the adjusted_close_price for both current and previous days to the result."}, {"role": "assistant", "content": "WITH high_vol AS (\n SELECT security_id\n FROM financial_services.market_data\n WHERE data_timestamp >= NOW() - INTERVAL '30 days'\n GROUP BY security_id\n HAVING AVG(volume) > 1000000\n)\nSELECT a.security_id,\n b.data_timestamp AS prev_date,\n b.close_price AS prev_close,\n b.adjusted_close_price AS prev_adj_close,\n a.data_timestamp AS curr_date,\n a.close_price AS curr_close,\n a.adjusted_close_price AS curr_adj_close,\n ROUND((a.close_price - b.close_price) / b.close_price * 100, 2) AS pct_change\nFROM financial_services.market_data a\nJOIN financial_services.market_data b\n ON a.security_id = b.security_id\n AND CAST(a.data_timestamp AS date) = CAST(b.data_timestamp + INTERVAL '1 day' AS date)\nJOIN high_vol h\n ON a.security_id = h.security_id\nWHERE (a.close_price - b.close_price) / b.close_price * 100 > 2;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\nCREATE TABLE financial_services.accounts ( account_id text PRIMARY KEY, customer_id text, account_number text, account_type text, balance numeric, currency text, opened_date date, status text, interest_rate numeric, last_updated_at timestamp )\nCREATE TABLE financial_services.transactions (\n transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction\n account_id character varying(64) NOT NULL, -- account involved in the transaction\n related_account_id character varying(64), -- counterpart account for transfers\n transaction_type character varying(50) NOT NULL, -- e.g., Deposit, Withdrawal, Transfer, Payment, Fee, Interest\n amount numeric(19, 4) NOT NULL, -- transaction amount\n currency character varying(3) NOT NULL, -- transaction currency\n transaction_date timestamp NOT NULL, -- exact time of the transaction\n effective_date date NOT NULL, -- date the transaction affects the balance\n description text, -- description or memo of the transaction\n status character varying(32) NOT NULL, -- e.g., Pending, Completed, Failed, Reversed\n reference_number character varying(128), -- external reference if applicable (e.g., check number)\n PRIMARY KEY (transaction_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id),\n FOREIGN KEY (related_account_id) REFERENCES financial_services.accounts(account_id)\n)\nCREATE TABLE financial_services.securities ( security_id text, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )\nCREATE TABLE financial_services.trades ( trade_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, security_id character varying(64) NOT NULL, order_id character varying(64), trade_type character varying(10) NOT NULL, quantity numeric(19, 8) NOT NULL, price_per_unit numeric(19, 8) NOT NULL, total_amount numeric(19, 4) NOT NULL, commission numeric(10, 4), trade_timestamp timestamp NOT NULL, settlement_date date, status character varying(32) NOT NULL, execution_venue character varying(100), PRIMARY KEY (trade_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the employee\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(100) NOT NULL, -- e.g., Teller, Branch Manager, Financial Advisor, Analyst\n department character varying(100), -- e.g., Retail Banking, Wealth Management, IT\n branch_id character varying(64), -- Identifier for the branch they work at (if applicable)\n email character varying(128) NOT NULL UNIQUE,\n phone_extension character varying(20),\n hire_date date NOT NULL,\n termination_date date, -- Date of termination, null if currently employed\n manager_id character varying(64), -- Self-referencing key for manager relationship\n status character varying(32) NOT NULL, -- e.g., Active, Terminated, On Leave\n PRIMARY KEY (employee_id),\n FOREIGN KEY (branch_id) REFERENCES financial_services.branches(branch_id), -- Assuming a branches table exists\n FOREIGN KEY (manager_id) REFERENCES financial_services.employees(employee_id)\n)\n", "conversations": [{"role": "user", "content": "List all trades with their order_id, trade_type, and commission for trades with commission higher than 100."}, {"role": "assistant", "content": "SELECT trade_id, order_id, trade_type, commission FROM financial_services.trades WHERE commission > 100;"}, {"role": "user", "content": "Include the security_name and ticker_symbol for each trade as well."}, {"role": "assistant", "content": "SELECT t.trade_id, t.order_id, t.trade_type, t.commission, s.security_name, s.ticker_symbol FROM financial_services.trades t INNER JOIN financial_services.securities s ON t.security_id = s.security_id WHERE t.commission > 100;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the names of law firms founded after 2010, along with the full name of their managing partner."}, {"role": "assistant", "content": "SELECT f.firm_name, l.first_name, l.last_name FROM legal_services.law_firms AS f JOIN legal_services.lawyers AS l ON f.managing_partner_id = l.lawyer_id WHERE f.founded_date > '2010-12-31';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.applications ( application_id.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text )\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\nCREATE TABLE government_services.appointments ( appointment_id text, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "Show me the number of appointments scheduled at each location, along with the location name and city."}, {"role": "assistant", "content": "SELECT loc.location_name, loc.city, COUNT(appt.appointment_id) AS appointment_count\nFROM government_services.appointments appt\nJOIN government_services.service_locations loc ON appt.location_id = loc.location_id\nGROUP BY loc.location_name, loc.city;"}, {"role": "user", "content": "Can you add the state for each location as well?"}, {"role": "assistant", "content": "SELECT loc.location_name, loc.city, loc.state, COUNT(appt.appointment_id) AS appointment_count\nFROM government_services.appointments appt\nJOIN government_services.service_locations loc ON appt.location_id = loc.location_id\nGROUP BY loc.location_name, loc.city, loc.state;"}, {"role": "user", "content": "Now only include locations where the number of appointments is greater than 20."}, {"role": "assistant", "content": "SELECT loc.location_name, loc.city, loc.state, COUNT(appt.appointment_id) AS appointment_count\nFROM government_services.appointments appt\nJOIN government_services.service_locations loc ON appt.location_id = loc.location_id\nGROUP BY loc.location_name, loc.city, loc.state\nHAVING COUNT(appt.appointment_id) > 20;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\n", "conversations": [{"role": "user", "content": "For each driver, find the other driver whose license_expiry_date is the next one after theirs. Show both IDs, names and their expiry dates."}, {"role": "assistant", "content": "SELECT\n d1.driver_id AS driver_id,\n d1.first_name || ' ' || d1.last_name AS driver_name,\n d1.license_expiry_date AS expiry_date,\n d2.driver_id AS next_driver_id,\n d2.first_name || ' ' || d2.last_name AS next_driver_name,\n d2.license_expiry_date AS next_expiry_date\nFROM transportation.drivers d1\nJOIN transportation.drivers d2\n ON d2.license_expiry_date = (\n SELECT MIN(d3.license_expiry_date)\n FROM transportation.drivers d3\n WHERE d3.license_expiry_date > d1.license_expiry_date\n );"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.accounts (\n account_id character varying(64) NOT NULL, -- unique identifier for the account\n customer_id character varying(64) NOT NULL, -- foreign key linking to the customer\n account_number character varying(128) NOT NULL UNIQUE, -- unique account number visible to customer\n account_type character varying(50) NOT NULL, -- e.g., Checking, Savings, Investment, Loan, Credit Card\n balance numeric(19, 4) NOT NULL DEFAULT 0.00, -- current account balance\n currency character varying(3) NOT NULL, -- currency code (e.g., USD, EUR)\n opened_date date NOT NULL, -- date the account was opened\n status character varying(32) NOT NULL, -- e.g., Open, Closed, Frozen\n interest_rate numeric(5, 4), -- annual interest rate, if applicable\n last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last account update\n PRIMARY KEY (account_id),\n FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id)\n)\nCREATE TABLE financial_services.transactions ( transaction_id.text, account_id.text, related_account_id.text, transaction_type.text, amount.numeric, currency.text, transaction_date.timestamp, effective_date.date, description.text, status.text, reference_number.text )\nCREATE TABLE financial_services.securities ( security_id text PRIMARY KEY, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.employees ( employee_id text PRIMARY KEY, first_name text, last_name text, job_title text, department text, branch_id text, email text, phone_extension text, hire_date date, termination_date date, manager_id text, status text )\nCREATE TABLE financial_services.loans (\n loan_id character varying(64) NOT NULL, -- unique identifier for the loan, could be same as account_id\n account_id character varying(64) NOT NULL UNIQUE, -- link to the general account record\n loan_type character varying(50) NOT NULL, -- e.g., Mortgage, Personal, Auto, Student\n principal_amount numeric(19, 4) NOT NULL, -- original loan amount\n current_principal_balance numeric(19, 4) NOT NULL, -- remaining principal\n interest_rate numeric(6, 4) NOT NULL, -- annual interest rate\n term_months integer NOT NULL, -- loan term in months\n origination_date date NOT NULL, -- date the loan was disbursed\n maturity_date date NOT NULL, -- date the loan is due to be fully repaid\n monthly_payment numeric(12, 4), -- scheduled monthly payment amount\n collateral_description text, -- description of collateral, if secured loan\n status character varying(32) NOT NULL, -- e.g., Active, Paid Off, Defaulted\n PRIMARY KEY (loan_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id)\n)\n", "conversations": [{"role": "user", "content": "For each customer, show their full name and the average amount of all transactions linked to any of their accounts."}, {"role": "assistant", "content": "SELECT c.first_name || ' ' || c.last_name AS customer_full_name, AVG(t.amount) AS average_transaction_amount FROM financial_services.customers AS c JOIN financial_services.accounts AS a ON c.customer_id = a.customer_id JOIN financial_services.transactions AS t ON a.account_id = t.account_id OR a.account_id = t.related_account_id GROUP BY c.customer_id, customer_full_name;"}, {"role": "user", "content": "Only consider transactions that occurred within the last 90 days for this calculation."}, {"role": "assistant", "content": "SELECT c.first_name || ' ' || c.last_name AS customer_full_name, AVG(t.amount) AS average_transaction_amount FROM financial_services.customers AS c JOIN financial_services.accounts AS a ON c.customer_id = a.customer_id JOIN financial_services.transactions AS t ON a.account_id = t.account_id OR a.account_id = t.related_account_id WHERE t.transaction_date >= CURRENT_DATE - INTERVAL '90 day' GROUP BY c.customer_id, customer_full_name;"}, {"role": "user", "content": "Filter the results to only show customers where this average transaction amount is greater than 1000."}, {"role": "assistant", "content": "SELECT c.first_name || ' ' || c.last_name AS customer_full_name, AVG(t.amount) AS average_transaction_amount FROM financial_services.customers AS c JOIN financial_services.accounts AS a ON c.customer_id = a.customer_id JOIN financial_services.transactions AS t ON a.account_id = t.account_id OR a.account_id = t.related_account_id WHERE t.transaction_date >= CURRENT_DATE - INTERVAL '90 day' GROUP BY c.customer_id, customer_full_name HAVING AVG(t.amount) > 1000;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "How many primary insurance policies are currently active for each plan_id? Show plan_id and active_count."}, {"role": "assistant", "content": "SELECT plan_id,\n COUNT(*) AS active_count\nFROM healthcare.patient_insurance\nWHERE is_primary = TRUE\n AND (expiration_date IS NULL OR expiration_date > CURRENT_DATE)\nGROUP BY plan_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\n", "conversations": [{"role": "user", "content": "Find employees who work in the same department as their manager. Display the employee's full name, the manager's full name, and the department they share."}, {"role": "assistant", "content": "SELECT e.first_name || ' ' || e.last_name AS employee_full_name, m.first_name || ' ' || m.last_name AS manager_full_name, e.department FROM government_services.employees AS e JOIN government_services.employees AS m ON e.manager_employee_id = m.employee_id WHERE e.department = m.department;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid PRIMARY KEY, player_id uuid, game_id uuid, server_id uuid, start_time timestamptz, end_time timestamptz, duration_seconds int, score int, session_data jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, achievement_id uuid NOT NULL, unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\n", "conversations": [{"role": "user", "content": "List all servers that are currently online and have a player count greater than their average player count across all servers in the same region."}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, s.current_players\nFROM gaming_technology.servers s\nJOIN (SELECT region, AVG(current_players) AS avg_players FROM gaming_technology.servers GROUP BY region) r\n ON s.region = r.region\nWHERE s.status = 'online' AND s.current_players > r.avg_players;"}, {"role": "user", "content": "Can you also include the maximum players of each server in the result?"}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, s.current_players, s.max_players\nFROM gaming_technology.servers s\nJOIN (SELECT region, AVG(current_players) AS avg_players FROM gaming_technology.servers GROUP BY region) r\n ON s.region = r.region\nWHERE s.status = 'online' AND s.current_players > r.avg_players;"}, {"role": "user", "content": "Now only show servers where current_players is at least 75% of max_players."}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, s.current_players, s.max_players\nFROM gaming_technology.servers s\nJOIN (SELECT region, AVG(current_players) AS avg_players FROM gaming_technology.servers GROUP BY region) r\n ON s.region = r.region\nWHERE s.status = 'online'\n AND s.current_players > r.avg_players\n AND s.current_players >= 0.75 * s.max_players;"}, {"role": "user", "content": "Please also show the average player count for the region in each row."}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, s.current_players, s.max_players, r.avg_players\nFROM gaming_technology.servers s\nJOIN (SELECT region, AVG(current_players) AS avg_players FROM gaming_technology.servers GROUP BY region) r\n ON s.region = r.region\nWHERE s.status = 'online'\n AND s.current_players > r.avg_players\n AND s.current_players >= 0.75 * s.max_players;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers ( lawyer_id.text, first_name.text, last_name.text, bar_number.text, firm_id.text, email.text, phone.text, specialization.text, hire_date.timestamp, is_partner.boolean )\nCREATE TABLE legal_services.law_firms (\n firm_id character varying(64) NOT NULL, -- unique identifier for the law firm\n firm_name character varying(200) NOT NULL, -- official name of the law firm\n address text NOT NULL, -- primary address of the firm\n phone character varying(32), -- firm's main phone number\n website character varying(255), -- firm's website URL\n founded_date date, -- date the firm was established\n managing_partner_id character varying(64), -- FK to lawyers table (optional)\n PRIMARY KEY (firm_id)\n)\nCREATE TABLE legal_services.cases (\n case_id character varying(64) NOT NULL, -- unique identifier for the case/matter\n case_number character varying(100) UNIQUE, -- official case number (court or internal)\n case_name text NOT NULL, -- descriptive name or title for the case\n client_id character varying(64) NOT NULL, -- FK to clients table\n lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)\n case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP\n status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed\n date_opened timestamp NOT NULL, -- date the case was formally opened\n date_closed timestamp, -- date the case was closed (nullable)\n description text, -- detailed description of the case\n court_jurisdiction character varying(128), -- court or jurisdiction if applicable\n PRIMARY KEY (case_id)\n)\nCREATE TABLE legal_services.documents ( document_id character varying(64) NOT NULL, case_id character varying(64) NOT NULL, document_name character varying(255) NOT NULL, document_type character varying(100), storage_path text NOT NULL, uploaded_by_lawyer_id character varying(64), upload_timestamp timestamp NOT NULL, version integer DEFAULT 1, description text, PRIMARY KEY (document_id) )\nCREATE TABLE legal_services.time_entries ( entry_id.text, case_id.text, lawyer_id.text, date_worked.date, hours_spent.numeric, billing_rate.numeric, description.text, is_billable.boolean, is_billed.boolean, invoice_id.text, created_at.timestamp )\nCREATE TABLE legal_services.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the name of each law firm and the full name of its managing partner."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.managing_partner_id = T2.lawyer_id;"}, {"role": "user", "content": "Only include firms founded before '2010-01-01' and exclude those without a managing partner listed."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.managing_partner_id = T2.lawyer_id WHERE T1.founded_date < '2010-01-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nIndex 'component_inventory'. Mapping: { properties: { inventory_record_id: { type: 'keyword' }, component_id: { type: 'keyword' }, quantity: { type: 'integer' }, location_warehouse: { type: 'keyword' }, location_bin: { type: 'keyword' }, received_date: { type: 'date' }, expiry_date: { type: 'date' }, batch_number: { type: 'keyword' }, last_updated: { type: 'date' } } }. Document _id can be inventory_record_id.\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5728\u5eab\u60c5\u5831\u3092\u53d6\u5f97\u3057\u305f\u3044\u3067\u3059\u3002\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8ID\u3068\u5728\u5eab\u6570\u91cf\u3001\u5009\u5eab\u306e\u5834\u6240\u3092\u542b\u3081\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SELECT component_id, quantity, location_warehouse FROM component_inventory WHERE component_id = 'specific_component_id';"}, {"role": "user", "content": "\u3055\u3089\u306b\u3001\u53d7\u3051\u53d6\u308a\u65e5\u304c2022\u5e74\u4ee5\u964d\u306e\u8a18\u9332\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3067\u304d\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SELECT component_id, quantity, location_warehouse FROM component_inventory WHERE component_id = 'specific_component_id' AND received_date >= '2022-01-01';"}, {"role": "user", "content": "\u5728\u5eab\u6570\u91cf\u304c100\u672a\u6e80\u306e\u3082\u306e\u3060\u3051\u306b\u7d5e\u308a\u8fbc\u3080\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SELECT component_id, quantity, location_warehouse FROM component_inventory WHERE component_id = 'specific_component_id' AND received_date >= '2022-01-01' AND quantity < 100;"}, {"role": "user", "content": "\u6700\u5f8c\u306b\u3001\u53d7\u3051\u53d6\u308a\u65e5\u3092\u65b0\u3057\u3044\u9806\u306b\u4e26\u3079\u66ff\u3048\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SELECT component_id, quantity, location_warehouse FROM component_inventory WHERE component_id = 'specific_component_id' AND received_date >= '2022-01-01' AND quantity < 100 ORDER BY received_date DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id text PRIMARY KEY, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id text PRIMARY KEY, tag_name text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Count the number of posts that have received at least one comment."}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT post_id) FROM social_media.comments"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.token_transfers (\n transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer\n token_id character varying(64) NOT NULL, -- identifier of the token being transferred\n from_address character varying(128) NOT NULL, -- address of the sender\n to_address character varying(128) NOT NULL, -- address of the receiver\n value numeric(38,14) NOT NULL, -- amount of tokens transferred\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer\n log_index integer NOT NULL, -- index of the transfer log in the transaction\n PRIMARY KEY (transfer_id)\n)\n", "conversations": [{"role": "user", "content": "For each sender address, count how many distinct tokens they have transferred. Show from_address and token_count."}, {"role": "assistant", "content": "SELECT from_address, COUNT(DISTINCT token_id) AS token_count\nFROM web3.token_transfers\nGROUP BY from_address;"}, {"role": "user", "content": "Now filter to only include senders who have transferred more than 5 distinct tokens."}, {"role": "assistant", "content": "SELECT from_address, COUNT(DISTINCT token_id) AS token_count\nFROM web3.token_transfers\nGROUP BY from_address\nHAVING COUNT(DISTINCT token_id) > 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE manufacturing.components (\n component_id character varying(64) NOT NULL, -- unique identifier for the component\n part_number character varying(100) NOT NULL UNIQUE, -- manufacturer-specific part number\n component_name character varying(255) NOT NULL, -- descriptive name (e.g., Landing Gear Strut, Wing Spar)\n description text, -- detailed description\n material_id character varying(64), -- FK linking to the material used\n supplier_id character varying(64), -- FK linking to the supplier\n weight_kg numeric(10,3), -- weight of the component in kg\n cost_usd numeric(12,2), -- cost of the component in USD\n criticality_level character varying(20), -- e.g., 'High', 'Medium', 'Low'\n PRIMARY KEY (component_id)\n)\nCREATE TABLE manufacturing.suppliers (\n supplier_id character varying(64) NOT NULL, -- unique identifier for the supplier\n supplier_name character varying(255) NOT NULL, -- legal name of the supplier company\n address text, -- primary address of the supplier\n country character varying(100), -- country of the supplier\n contact_person character varying(128), -- primary contact person\n contact_email character varying(128), -- contact email\n quality_rating numeric(3,1), -- supplier quality rating (e.g., 1.0 to 5.0)\n certified_date date, -- date when supplier certification was last validated\n PRIMARY KEY (supplier_id)\n)\nCREATE TABLE manufacturing.materials (\n material_id character varying(64) NOT NULL, -- unique identifier for the material\n material_name character varying(128) NOT NULL, -- common name (e.g., Titanium Alloy Grade 5, Carbon Fiber Prepreg)\n specification character varying(255), -- specification standard (e.g., AMS 4928)\n description text, -- detailed description of properties\n density_kg_m3 numeric(10, 4), -- density in kg per cubic meter\n tensile_strength_mpa integer, -- tensile strength in Megapascals\n PRIMARY KEY (material_id)\n)\nCREATE TABLE manufacturing.assembly_steps (\n step_id character varying(64) NOT NULL, -- unique identifier for an assembly step/task\n line_id character varying(64) NOT NULL, -- FK to the assembly line where this step occurs\n step_number integer NOT NULL, -- sequence number of the step on the line\n step_name character varying(255) NOT NULL, -- name of the task (e.g., Install Wing Root Fairing)\n description text, -- detailed instructions or description\n standard_duration_hours numeric(8,2), -- estimated time to complete the step\n required_skill_level character varying(50), -- skill level needed (e.g., 'Mechanic II', 'Electrician I')\n workstation character varying(100), -- specific workstation or area for the step\n PRIMARY KEY (step_id)\n)\nCREATE TABLE manufacturing.inspections (\n inspection_id character varying(64) NOT NULL, -- unique identifier for the inspection event\n build_id character varying(64) NOT NULL, -- FK to the specific aircraft build being inspected\n component_id character varying(64), -- FK to the specific component inspected (if applicable)\n step_id character varying(64), -- FK to the assembly step after which inspection occurred (if applicable)\n inspection_type character varying(100) NOT NULL, -- e.g., 'Visual', 'NDT', 'Functional Test'\n inspector_employee_id character varying(64) NOT NULL, -- FK to the employee who performed the inspection\n inspection_timestamp timestamp NOT NULL, -- time when the inspection was completed\n result character varying(20) NOT NULL, -- 'Pass', 'Fail', 'Rework Needed'\n remarks text, -- detailed notes or findings\n PRIMARY KEY (inspection_id)\n)\nCREATE TABLE manufacturing.component_inventory (\n inventory_record_id character varying(64) NOT NULL, -- unique ID for this inventory record/batch\n component_id character varying(64) NOT NULL, -- FK to the component\n quantity integer NOT NULL, -- number of units of this component in stock for this batch\n location_warehouse character varying(100), -- warehouse identifier\n location_bin character varying(100), -- specific bin or shelf location\n received_date timestamp NOT NULL, -- when this batch was received\n expiry_date date, -- expiry date if applicable (e.g., for sealants, adhesives)\n batch_number character varying(100), -- supplier batch number\n last_updated timestamp NOT NULL, -- timestamp of the last update to this record\n PRIMARY KEY (inventory_record_id)\n)\n", "conversations": [{"role": "user", "content": "\u6211\u60f3\u67e5\u8be2\u67d0\u4e2a\u7ec4\u4ef6\u7684\u68c0\u67e5\u8bb0\u5f55\uff0c\u5305\u62ec\u68c0\u67e5\u7c7b\u578b\u3001\u68c0\u67e5\u7ed3\u679c\u548c\u68c0\u67e5\u65f6\u95f4\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u7ec4\u4ef6\u7684\u540d\u79f0\u548c\u63cf\u8ff0\u3002"}, {"role": "assistant", "content": "SELECT i.inspection_type, i.result, i.inspection_timestamp, c.component_name, c.description\nFROM manufacturing.inspections i\nJOIN manufacturing.components c ON i.component_id = c.component_id\nWHERE c.component_id = 'specific_component_id';"}, {"role": "user", "content": "\u80fd\u4e0d\u80fd\u53ea\u663e\u793a\u68c0\u67e5\u7ed3\u679c\u4e3a'Fail'\u7684\u8bb0\u5f55\uff1f"}, {"role": "assistant", "content": "SELECT i.inspection_type, i.result, i.inspection_timestamp, c.component_name, c.description\nFROM manufacturing.inspections i\nJOIN manufacturing.components c ON i.component_id = c.component_id\nWHERE c.component_id = 'specific_component_id' AND i.result = 'Fail';"}, {"role": "user", "content": "\u5982\u679c\u6211\u60f3\u8fdb\u4e00\u6b65\u7b5b\u9009\u51fa\u68c0\u67e5\u65f6\u95f4\u5728\u8fc7\u53bb\u4e00\u4e2a\u6708\u5185\u7684\u8bb0\u5f55\uff0c\u5e94\u8be5\u600e\u4e48\u505a\uff1f"}, {"role": "assistant", "content": "SELECT i.inspection_type, i.result, i.inspection_timestamp, c.component_name, c.description\nFROM manufacturing.inspections i\nJOIN manufacturing.components c ON i.component_id = c.component_id\nWHERE c.component_id = 'specific_component_id' AND i.result = 'Fail' AND i.inspection_timestamp >= NOW() - INTERVAL '1 month';"}, {"role": "user", "content": "\u8bf7\u518d\u52a0\u4e0a\u68c0\u67e5\u5907\u6ce8\u4fe1\u606f\uff0c\u5e76\u6309\u68c0\u67e5\u65f6\u95f4\u4ece\u65b0\u5230\u65e7\u6392\u5e8f\u3002"}, {"role": "assistant", "content": "SELECT i.inspection_type, i.result, i.inspection_timestamp, c.component_name, c.description, i.remarks\nFROM manufacturing.inspections i\nJOIN manufacturing.components c ON i.component_id = c.component_id\nWHERE c.component_id = 'specific_component_id' AND i.result = 'Fail' AND i.inspection_timestamp >= NOW() - INTERVAL '1 month'\nORDER BY i.inspection_timestamp DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.locations ( location_id text, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\n", "conversations": [{"role": "user", "content": "Find pairs of distinct locations in the same city that have different types. Include location IDs, names, city, and type for both locations."}, {"role": "assistant", "content": "SELECT l1.location_id AS location1_id, l1.name AS location1_name, l1.city, l1.type AS location1_type, l2.location_id AS location2_id, l2.name AS location2_name, l2.type AS location2_type FROM transportation.locations AS l1 JOIN transportation.locations AS l2 ON l1.city = l2.city AND l1.location_id < l2.location_id WHERE l1.type != l2.type;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.reservations ( reservation_id.text, property_id.text, guest_id.text, room_id.text, room_type_id.text, check_in_date.date, check_out_date.date, actual_check_in_ts.timestamp, actual_check_out_ts.timestamp, num_adults.integer, num_children.integer, status.text, booking_source.text, rate_plan_id.text, total_amount.numeric, amount_paid.numeric, special_requests.text, created_at.timestamp, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Find pairs of reservations for the same guest at the same property where the check-in date of the second reservation is the same as the check-out date of the first reservation. List guest ID, property ID, and both reservation IDs."}, {"role": "assistant", "content": "SELECT r1.guest_id, r1.property_id, r1.reservation_id AS first_reservation_id, r2.reservation_id AS second_reservation_id FROM reservations r1 JOIN reservations r2 ON r1.guest_id = r2.guest_id AND r1.property_id = r2.property_id AND r1.check_out_date = r2.check_in_date AND r1.reservation_id != r2.reservation_id;"}, {"role": "user", "content": "Only include pairs where the first reservation had a status of 'CheckedOut'."}, {"role": "assistant", "content": "SELECT r1.guest_id, r1.property_id, r1.reservation_id AS first_reservation_id, r2.reservation_id AS second_reservation_id FROM reservations r1 JOIN reservations r2 ON r1.guest_id = r2.guest_id AND r1.property_id = r2.property_id AND r1.check_out_date = r2.check_in_date AND r1.reservation_id != r2.reservation_id WHERE r1.status = 'CheckedOut';"}, {"role": "user", "content": "Additionally, filter to show only those pairs where the first reservation occurred in 2023."}, {"role": "assistant", "content": "SELECT r1.guest_id, r1.property_id, r1.reservation_id AS first_reservation_id, r2.reservation_id AS second_reservation_id FROM reservations r1 JOIN reservations r2 ON r1.guest_id = r2.guest_id AND r1.property_id = r2.property_id AND r1.check_out_date = r2.check_in_date AND r1.reservation_id != r2.reservation_id WHERE r1.status = 'CheckedOut' AND EXTRACT(YEAR FROM r1.check_in_date) = 2023;"}]} +{"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE manufacturing.aircraft_models ( model_id.text, model_name.text, manufacturer.text, passenger_capacity.integer, max_range_km.integer, engine_type.text, wingspan_m.numeric, status.text, first_flight_date.date )\n", "conversations": [{"role": "user", "content": "What are the fuel consumption rates per hour for the Boeing 747-8 model?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide information on the fuel consumption rates for the Boeing 747-8 model as this data is not included in the aircraft_models table. The table contains details such as model name, manufacturer, passenger capacity, and other specifications, but fuel consumption data is not available. If you have another question or need assistance with something else related to the table, I'm happy to help."}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_profit ( address.text, rank.numeric, profit.numeric, roi.numeric, realized_ratio.numeric, most_profit_token.text, last_trade_time.text, chain.text )\n", "conversations": [{"role": "user", "content": "Which token had the highest ROI for smart money addresses on the BSC chain? Please show the token symbol and the highest ROI as well as the address."}, {"role": "assistant", "content": "SELECT most_profit_token, MAX(roi) AS highest_roi, address\nFROM smart_money_profit\nWHERE chain = 'BSC'\nGROUP BY most_profit_token, address\nORDER BY highest_roi DESC\nLIMIT 1;"}, {"role": "user", "content": "Can you also include the realized ratio for that address and token, and only show results where the realized ratio is above 0.7?"}, {"role": "assistant", "content": "SELECT most_profit_token, roi AS highest_roi, address, realized_ratio\nFROM smart_money_profit\nWHERE chain = 'BSC' AND realized_ratio > 0.7\nORDER BY roi DESC\nLIMIT 1;"}, {"role": "user", "content": "What if I want to see the top 3 tokens and their corresponding addresses by ROI, still only for BSC and realized_ratio over 0.7?"}, {"role": "assistant", "content": "SELECT most_profit_token, roi AS highest_roi, address, realized_ratio\nFROM smart_money_profit\nWHERE chain = 'BSC' AND realized_ratio > 0.7\nORDER BY roi DESC\nLIMIT 3;"}, {"role": "user", "content": "Additionally, please show the last trade time for each result."}, {"role": "assistant", "content": "SELECT most_profit_token, roi AS highest_roi, address, realized_ratio, last_trade_time\nFROM smart_money_profit\nWHERE chain = 'BSC' AND realized_ratio > 0.7\nORDER BY roi DESC\nLIMIT 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "Count the number of unique users who are being followed."}, {"role": "assistant", "content": "SELECT COUNT(DISTINCT following_user_id) FROM social_media.follows"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )\n", "conversations": [{"role": "user", "content": "List the number of bookings for each day."}, {"role": "assistant", "content": "SELECT DATE(booking_time) AS booking_date, COUNT(*) AS booking_count\nFROM transportation.bookings\nGROUP BY DATE(booking_time);\n"}, {"role": "user", "content": "Now only include days where booking_count > 10."}, {"role": "assistant", "content": "SELECT DATE(booking_time) AS booking_date, COUNT(*) AS booking_count\nFROM transportation.bookings\nGROUP BY DATE(booking_time)\nHAVING COUNT(*) > 10;\n"}, {"role": "user", "content": "Also include the total fare collected for those days."}, {"role": "assistant", "content": "SELECT DATE(booking_time) AS booking_date,\n COUNT(*) AS booking_count,\n SUM(fare) AS total_fare\nFROM transportation.bookings\nGROUP BY DATE(booking_time)\nHAVING COUNT(*) > 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the government employee\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(150) NOT NULL,\n department character varying(100),\n work_email character varying(128) NOT NULL UNIQUE,\n work_phone character varying(32),\n hire_date date NOT NULL,\n termination_date date, -- null if currently employed\n access_level character varying(50), -- Role or permission level\n manager_employee_id character varying(64), -- FK to self for reporting structure\n PRIMARY KEY (employee_id)\n)\n", "conversations": [{"role": "user", "content": "Find employees who were hired after their managers. Display the employee's full name, their hire date, the manager's full name, and the manager's hire date."}, {"role": "assistant", "content": "SELECT e.first_name || ' ' || e.last_name AS employee_name, e.hire_date AS employee_hire_date, m.first_name || ' ' || m.last_name AS manager_name, m.hire_date AS manager_hire_date FROM government_services.employees e JOIN government_services.employees m ON e.manager_employee_id = m.employee_id WHERE e.hire_date > m.hire_date;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.applications ( application_id text PRIMARY KEY, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\n", "conversations": [{"role": "user", "content": "Find all applications that were submitted in 2023 but received a decision ('Approved' or 'Rejected') in 2024. List the application ID, submitted date, decision date, and status."}, {"role": "assistant", "content": "SELECT application_id, submitted_at, decision_date, status FROM government_services.applications WHERE submitted_at BETWEEN '2023-01-01 00:00:00' AND '2023-12-31 23:59:59' AND status IN ('Approved', 'Rejected') AND decision_date BETWEEN '2024-01-01' AND '2024-12-31';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\n", "conversations": [{"role": "user", "content": "I need to find doctors whose phone number contains the digit '7'. Display their full name and phone number."}, {"role": "assistant", "content": "SELECT first_name, last_name, phone_number FROM healthcare.doctors WHERE phone_number LIKE '%7%';"}, {"role": "user", "content": "Additionally, only show those records where the doctor has a listed email address."}, {"role": "assistant", "content": "SELECT first_name, last_name, phone_number FROM healthcare.doctors WHERE phone_number LIKE '%7%' AND email IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "List the document name, upload timestamp, and the full name of the lawyer who uploaded it, for all documents associated with case number 'CASE123'."}, {"role": "assistant", "content": "SELECT T1.document_name , T1.upload_timestamp , T2.full_name FROM legal_services.documents AS T1 JOIN legal_services.lawyers AS T2 ON T1.uploaded_by_lawyer_id = T2.lawyer_id WHERE T1.case_id = 'CASE123'"}, {"role": "user", "content": "Only include documents of type 'Pleading'."}, {"role": "assistant", "content": "SELECT T1.document_name , T1.upload_timestamp , T2.full_name FROM legal_services.documents AS T1 JOIN legal_services.lawyers AS T2 ON T1.uploaded_by_lawyer_id = T2.lawyer_id WHERE T1.case_id = 'CASE123' AND T1.document_type = 'Pleading'"}, {"role": "user", "content": "Also show the version and restrict results to documents with version greater than 1."}, {"role": "assistant", "content": "SELECT T1.document_name , T1.upload_timestamp , T1.version , T2.full_name FROM legal_services.documents AS T1 JOIN legal_services.lawyers AS T2 ON T1.uploaded_by_lawyer_id = T2.lawyer_id WHERE T1.case_id = 'CASE123' AND T1.document_type = 'Pleading' AND T1.version > 1"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp.timestamp, block_number.bigint, transaction_hash.text, transaction_index.bigint, from_address.text, contract_address.text, symbol.text, total_supply.text, name.text, decimals.bigint, is_erc20.integer, is_erc721.integer, is_erc1155.integer, is_proxy.integer, extra_info.text, pk.integer )\nCREATE TABLE erc1155_approval_for_all ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text )\nCREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text )\nCREATE TABLE erc20_balances_historical ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.integer )\nCREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )\nCREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )\nCREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )\nCREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )\nCREATE TABLE nft_metadata ( blockchain.text, contract_address.text, token_id.text, contract_name.text, erc_type.text, amount.bigint, minter.text, owner.text, mint_block_number.bigint, mint_time.bigint, mint_transaction_hash.text, mint_price.text, token_uri.text, metadata.text, name.text, image_uri.text, traits.text, updated_at.bigint, status.text, rarity_score.real, rarity_rank.integer, unique_attribute_count.integer, pk.integer )\nCREATE TABLE nft_collections ( blockchain.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer )\nCREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )\nCREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE 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 )\nCREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE mud_holesky_redstone ( address.text, table_id.text, key_bytes.text, key0.text, key1.text, static_data.text, encoded_lengths.text, dynamic_data.text, is_deleted.boolean, block_number.bigint, log_index.bigint )\nCREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )\nCREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_activities_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )\nCREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )\n", "conversations": [{"role": "user", "content": "Which ERC20 tokens have more than 8 decimals? Show their symbol, name, and decimals."}, {"role": "assistant", "content": "SELECT symbol, name, decimals FROM token_metas WHERE decimals > 8;"}, {"role": "user", "content": "Can you also show the contract address and the total supply for each of these tokens?"}, {"role": "assistant", "content": "SELECT contract_address, symbol, name, decimals, total_supply FROM token_metas WHERE decimals > 8;"}, {"role": "user", "content": "Now, include only tokens where total_supply is greater than '100000000000' and order the results by total_supply descending."}, {"role": "assistant", "content": "SELECT contract_address, symbol, name, decimals, total_supply FROM token_metas WHERE decimals > 8 AND CAST(total_supply AS NUMERIC) > 100000000000 ORDER BY CAST(total_supply AS NUMERIC) DESC;"}, {"role": "user", "content": "Show me the is_proxy field for each token as well."}, {"role": "assistant", "content": "SELECT contract_address, symbol, name, decimals, total_supply, is_proxy FROM token_metas WHERE decimals > 8 AND CAST(total_supply AS NUMERIC) > 100000000000 ORDER BY CAST(total_supply AS NUMERIC) DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool )\n", "conversations": [{"role": "user", "content": "Count how many users have not specified a value for their bio."}, {"role": "assistant", "content": "SELECT COUNT(*) FROM social_media.users WHERE bio IS NULL OR bio = '';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(50) NOT NULL UNIQUE, -- user's unique handle\n email character varying(128) NOT NULL UNIQUE, -- user's email address\n password_hash text NOT NULL, -- hashed password\n full_name character varying(100), -- user's full name\n profile_picture_url text, -- URL to the profile picture\n bio text, -- short user biography\n location character varying(100), -- user's location\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update\n is_verified boolean NOT NULL DEFAULT false, -- verification status\n PRIMARY KEY (user_id)\n)\nCREATE TABLE social_media.posts (\n post_id character varying(64) NOT NULL, -- unique identifier for the post\n user_id character varying(64) NOT NULL, -- identifier of the user who created the post (FK to users.user_id)\n content text, -- textual content of the post\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of post creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last post edit\n visibility character varying(20) NOT NULL DEFAULT 'public', -- visibility ('public', 'friends', 'private')\n location_lat numeric(9,6), -- latitude of post location\n location_lon numeric(9,6), -- longitude of post location\n PRIMARY KEY (post_id)\n)\nCREATE TABLE social_media.comments (\n comment_id character varying(64) NOT NULL, -- unique identifier for the comment\n post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id)\n user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id)\n parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id)\n content text NOT NULL, -- textual content of the comment\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit\n PRIMARY KEY (comment_id)\n)\nCREATE TABLE social_media.likes (\n like_id character varying(64) NOT NULL, -- unique identifier for the like\n user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id)\n post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable)\n comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred\n PRIMARY KEY (like_id),\n CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes\n CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something\n)\nCREATE TABLE social_media.follows (\n follow_id character varying(64) NOT NULL, -- unique identifier for the follow relationship\n follower_user_id character varying(64) NOT NULL, -- identifier of the user who is following (FK to users.user_id)\n following_user_id character varying(64) NOT NULL, -- identifier of the user being followed (FK to users.user_id)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the follow started\n PRIMARY KEY (follow_id),\n CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) -- prevent duplicate follows\n)\nCREATE TABLE social_media.hashtags (\n hashtag_id character varying(64) NOT NULL, -- unique identifier for the hashtag\n tag_name character varying(100) NOT NULL UNIQUE, -- the actual hashtag text (without '#')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when the hashtag was first used\n PRIMARY KEY (hashtag_id)\n)\nCREATE TABLE social_media.post_hashtags (\n post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link\n post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id)\n hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id)\n PRIMARY KEY (post_hashtag_id),\n CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post\n)\nCREATE TABLE social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.conversation_participants (\n participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry\n conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)\n user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)\n joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation\n last_read_at timestamp, -- timestamp indicating up to when the user has read messages\n PRIMARY KEY (participant_id),\n CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times\n)\n", "conversations": [{"role": "user", "content": "For each user, show their username, email, and the number of posts they've created that contain at least one hashtag. Only include users who have created such posts."}, {"role": "assistant", "content": "SELECT u.username, u.email, COUNT(DISTINCT p.post_id) AS posts_with_hashtag_count\nFROM social_media.users u\nJOIN social_media.posts p ON u.user_id = p.user_id\nJOIN social_media.post_hashtags ph ON p.post_id = ph.post_id\nGROUP BY u.user_id, u.username, u.email\nHAVING COUNT(DISTINCT p.post_id) > 0;"}, {"role": "user", "content": "Actually, I'd like to see, for each user, the total number of unique hashtags they've used across their posts too. Please include that as unique_hashtags_count."}, {"role": "assistant", "content": "SELECT u.username, u.email, COUNT(DISTINCT p.post_id) AS posts_with_hashtag_count, COUNT(DISTINCT ph.hashtag_id) AS unique_hashtags_count\nFROM social_media.users u\nJOIN social_media.posts p ON u.user_id = p.user_id\nJOIN social_media.post_hashtags ph ON p.post_id = ph.post_id\nGROUP BY u.user_id, u.username, u.email\nHAVING COUNT(DISTINCT p.post_id) > 0;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.metadata ( metadata_id text, asset_id text, key text, value text )\nCREATE TABLE trading_platform.notifications ( notification_id text, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "Which assets have at least two different types of metadata keys, and for each asset, list its asset_id and a comma-separated list of the unique keys?"}, {"role": "assistant", "content": "SELECT asset_id, string_agg(DISTINCT key, ', ') AS unique_keys\nFROM trading_platform.metadata\nGROUP BY asset_id\nHAVING COUNT(DISTINCT key) >= 2;"}, {"role": "user", "content": "Also, show the total count of metadata entries for each asset in the result."}, {"role": "assistant", "content": "SELECT asset_id, string_agg(DISTINCT key, ', ') AS unique_keys, COUNT(*) AS metadata_count\nFROM trading_platform.metadata\nGROUP BY asset_id\nHAVING COUNT(DISTINCT key) >= 2;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_id) )\n", "conversations": [{"role": "user", "content": "Count the number of services in each category. Return the category and the count."}, {"role": "assistant", "content": "SELECT category, COUNT(*) AS service_count FROM government_services.services GROUP BY category;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\n", "conversations": [{"role": "user", "content": "Show me all servers in the same region that have different statuses. I want to see the server names, regions, and their statuses for each pair."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1, s2.server_name AS server2, s1.region, s1.status AS status1, s2.status AS status2\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\n AND s1.server_id <> s2.server_id\n AND s1.status <> s2.status;"}, {"role": "user", "content": "Please also include the current_players of both servers in the result."}, {"role": "assistant", "content": "SELECT s1.server_name AS server1, s2.server_name AS server2, s1.region, s1.status AS status1, s2.status AS status2, s1.current_players AS server1_current_players, s2.current_players AS server2_current_players\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\n AND s1.server_id <> s2.server_id\n AND s1.status <> s2.status;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\n", "conversations": [{"role": "user", "content": "List all document IDs and their corresponding location names for documents that are associated with applications assigned to a service location in the city of 'Los Angeles'."}, {"role": "assistant", "content": "SELECT d.document_id, sl.location_name\nFROM government_services.documents d\nJOIN government_services.service_locations sl\n ON d.application_id = sl.location_id\nWHERE sl.city = 'Los Angeles';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id text PRIMARY KEY, case_number text UNIQUE, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\nCREATE TABLE legal_services.documents ( document_id text PRIMARY KEY, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version int, description text )\nCREATE TABLE legal_services.time_entries ( entry_id text PRIMARY KEY, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable bool, is_billed bool, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.invoices ( invoice_id text PRIMARY KEY, invoice_number text UNIQUE, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text PRIMARY KEY, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List the case_number, case_name, and the total amount invoiced for each case."}, {"role": "assistant", "content": "SELECT ca.case_number, ca.case_name, SUM(i.total_amount) AS total_invoiced\nFROM legal_services.cases ca\nLEFT JOIN legal_services.invoices i ON ca.case_id = i.case_id\nGROUP BY ca.case_number, ca.case_name;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.premium_payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment\n policy_id character varying(64) NOT NULL, -- identifier of the policy the payment is for (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the payment (FK to customers)\n payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the payment was received\n amount_paid numeric(12, 2) NOT NULL, -- amount of the payment\n payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check\n transaction_reference character varying(128) UNIQUE, -- reference from payment processor\n due_date date, -- due date for this payment installment\n payment_period_start date, -- start date of the period this payment covers\n payment_period_end date, -- end date of the period this payment covers\n status character varying(30) NOT NULL DEFAULT 'Completed', -- e.g., Completed, Pending, Failed, Refunded\n PRIMARY KEY (payment_id)\n)\n", "conversations": [{"role": "user", "content": "Find all pairs of overlapping payment periods for the same customer. Return customer_id, first payment_id as payment1_id, second payment_id as payment2_id, and both periods' start and end dates."}, {"role": "assistant", "content": "SELECT p1.customer_id,\n p1.payment_id AS payment1_id,\n p2.payment_id AS payment2_id,\n p1.payment_period_start AS start1,\n p1.payment_period_end AS end1,\n p2.payment_period_start AS start2,\n p2.payment_period_end AS end2\nFROM insurance.premium_payments p1\nJOIN insurance.premium_payments p2\n ON p1.customer_id = p2.customer_id\n AND p1.payment_id < p2.payment_id\n -- periods overlap\n AND p1.payment_period_start <= p2.payment_period_end\n AND p2.payment_period_start <= p1.payment_period_end;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash text, transaction_index bigint, from_address text, contract_address text, symbol text, total_supply text, name text, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info text, pk integer )\nCREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text )\nCREATE TABLE erc20_balances ( block_number bigint, contract_address text, wallet_address text, amount text, pk text )\nCREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )\nCREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )\nCREATE TABLE nft_holder_historical ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk integer )\nCREATE TABLE sui_coins ( object_id text, status text, coin_type text, balance text, owner text )\nCREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )\nCREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer )\nCREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )\nCREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer )\nCREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_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 )\nCREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE mud_holesky_redstone ( address text, table_id text, key_bytes text, key0 text, key1 text, static_data text, encoded_lengths text, dynamic_data text, is_deleted boolean, block_number bigint, log_index bigint )\nCREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text )\nCREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )\nCREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )\nCREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )\nCREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )\n", "conversations": [{"role": "user", "content": "List all SUI coins with 'active' status and their object_id, owner address, coin_type, and balance."}, {"role": "assistant", "content": "SELECT object_id, owner, coin_type, balance FROM sui_coins WHERE status = 'active';"}, {"role": "user", "content": "Can you also include the coin's symbol and name from the sui_coins_metadata table?"}, {"role": "assistant", "content": "SELECT sc.object_id, sc.owner, sc.coin_type, sc.balance, scm.symbol, scm.name\nFROM sui_coins sc\nLEFT JOIN sui_coins_metadata scm ON sc.coin_type = scm.coin_type\nWHERE sc.status = 'active';"}, {"role": "user", "content": "Filter the results to only show coins with a balance greater than 1,000,000 and order by balance descending."}, {"role": "assistant", "content": "SELECT sc.object_id, sc.owner, sc.coin_type, sc.balance, scm.symbol, scm.name\nFROM sui_coins sc\nLEFT JOIN sui_coins_metadata scm ON sc.coin_type = scm.coin_type\nWHERE sc.status = 'active' AND CAST(sc.balance AS NUMERIC) > 1000000\nORDER BY CAST(sc.balance AS NUMERIC) DESC;"}, {"role": "user", "content": "Now, limit the output to the top 10 records and include the coin description as well."}, {"role": "assistant", "content": "SELECT sc.object_id, sc.owner, sc.coin_type, sc.balance, scm.symbol, scm.name, scm.description\nFROM sui_coins sc\nLEFT JOIN sui_coins_metadata scm ON sc.coin_type = scm.coin_type\nWHERE sc.status = 'active' AND CAST(sc.balance AS NUMERIC) > 1000000\nORDER BY CAST(sc.balance AS NUMERIC) DESC\nLIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.developers ( developer_id uuid, name text, country text, founded_year integer, website text, created_at timestamp with time zone )\nCREATE 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 )\nCREATE TABLE gaming_technology.servers ( server_id uuid, game_id uuid, server_name text, region text, ip_address text, port integer, current_players integer, max_players integer, status text, last_heartbeat timestamp with time zone )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\n", "conversations": [{"role": "user", "content": "Give me a list of developers and how many unique games they have created. Show developer name and total_games."}, {"role": "assistant", "content": "SELECT d.name AS developer_name, COUNT(DISTINCT g.game_id) AS total_games\nFROM gaming_technology.developers d\nLEFT JOIN gaming_technology.games g ON d.developer_id = g.developer_id\nGROUP BY d.developer_id, d.name;"}, {"role": "user", "content": "Oops, it says table 'gaming_technology.games' does not exist. Please adjust the SQL to just show information about the developers."}, {"role": "assistant", "content": "SELECT name AS developer_name, country, founded_year\nFROM gaming_technology.developers;"}, {"role": "user", "content": "I only want to see developers founded after 2015."}, {"role": "assistant", "content": "SELECT name AS developer_name, country, founded_year\nFROM gaming_technology.developers\nWHERE founded_year > 2015;"}, {"role": "user", "content": "Also include the website column, and order by founded_year descending."}, {"role": "assistant", "content": "SELECT name AS developer_name, country, founded_year, website\nFROM gaming_technology.developers\nWHERE founded_year > 2015\nORDER BY founded_year DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.payments ( payment_id.text, application_id.text, citizen_id.text, service_id.text, amount.numeric, currency.text, payment_method.text, payment_provider_reference.text, payment_timestamp.timestamp, status.text, notes.text )\nCREATE TABLE government_services.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text )\n", "conversations": [{"role": "user", "content": "For each citizen, list the documents they uploaded and the notifications they received. Show citizen ID, document ID, document type, and notification ID."}, {"role": "assistant", "content": "SELECT T1.citizen_id, T1.document_id, T1.document_type, T2.notification_id FROM government_services.documents AS T1 JOIN government_services.notifications AS T2 ON T1.citizen_id = T2.citizen_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.trades ( trade_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL, security_id character varying(64) NOT NULL, order_id character varying(64), trade_type character varying(10) NOT NULL, quantity numeric(19, 8) NOT NULL, price_per_unit numeric(19, 8) NOT NULL, total_amount numeric(19, 4) NOT NULL, commission numeric(10, 4), trade_timestamp timestamp NOT NULL, settlement_date date, status character varying(32) NOT NULL, execution_venue character varying(100), PRIMARY KEY (trade_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\n", "conversations": [{"role": "user", "content": "Show me the total quantity traded and total amount for each security, identified by its ticker symbol, for trades in the last month."}, {"role": "assistant", "content": "SELECT T2.ticker_symbol, SUM(T1.quantity), SUM(T1.total_amount) FROM financial_services.trades AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.trade_timestamp >= DATE('now', '-1 month') GROUP BY 1"}, {"role": "user", "content": "Can you also show the average price per unit and filter to only include securities where the total quantity traded is greater than 5000?"}, {"role": "assistant", "content": "SELECT T2.ticker_symbol, SUM(T1.quantity), SUM(T1.total_amount), AVG(T1.price_per_unit) FROM financial_services.trades AS T1 JOIN financial_services.securities AS T2 ON T1.security_id = T2.security_id WHERE T1.trade_timestamp >= DATE('now', '-1 month') GROUP BY 1 HAVING SUM(T1.quantity) > 5000"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction\n reservation_id character varying(64), -- FK to reservations (if payment is for a stay)\n guest_id character varying(64) NOT NULL, -- FK to guests (who paid)\n bill_id character varying(64), -- FK to bills/invoices this payment applies to\n amount numeric(12,2) NOT NULL, -- amount of the payment\n currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR)\n payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher\n card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC)\n card_last_four character varying(4), -- last 4 digits of CC (if CC)\n transaction_ref character varying(128), -- reference ID from payment gateway or processor\n payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred\n status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed\n staff_id_processed character varying(64), -- FK to staff (who processed the payment)\n notes text, -- notes about the payment\n PRIMARY KEY (payment_id),\n FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id),\n FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id),\n FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id)\n)\n", "conversations": [{"role": "user", "content": "For each property, list the property name and the count of payments processed."}, {"role": "assistant", "content": "SELECT\n prop.property_name,\n COUNT(p.payment_id) AS payment_count\nFROM hospitality_technology.properties AS prop\nJOIN hospitality_technology.reservations AS r ON prop.property_id = r.property_id -- Assuming reservations links properties and payments\nJOIN hospitality_technology.payments AS p ON r.reservation_id = p.reservation_id\nGROUP BY\n prop.property_name\nORDER BY\n payment_count DESC;"}, {"role": "user", "content": "Filter the list to only include properties that have processed more than 20 payments."}, {"role": "assistant", "content": "SELECT\n prop.property_name,\n COUNT(p.payment_id) AS payment_count\nFROM hospitality_technology.properties AS prop\nJOIN hospitality_technology.reservations AS r ON prop.property_id = r.property_id\nJOIN hospitality_technology.payments AS p ON r.reservation_id = p.reservation_id\nGROUP BY\n prop.property_name\nHAVING\n COUNT(p.payment_id) > 20\nORDER BY\n payment_count DESC;"}, {"role": "user", "content": "Actually, instead of the count, show the average payment amount for these properties, still limited to properties with more than 20 payments."}, {"role": "assistant", "content": "SELECT\n prop.property_name,\n AVG(p.amount) AS average_payment_amount\nFROM hospitality_technology.properties AS prop\nJOIN hospitality_technology.reservations AS r ON prop.property_id = r.property_id\nJOIN hospitality_technology.payments AS p ON r.reservation_id = p.reservation_id\nGROUP BY\n prop.property_name\nHAVING\n COUNT(p.payment_id) > 20\nORDER BY\n average_payment_amount DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players ( player_id uuid PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb )\nCREATE TABLE gaming_technology.games (\n game_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game\n title character varying(200) NOT NULL, -- official title of the game\n developer_id uuid NOT NULL, -- FK linking to the developers table\n publisher_id uuid, -- FK linking to a potential publishers table (optional)\n genre character varying(100), -- primary genre (e.g., RPG, FPS, Strategy)\n release_date date, -- official release date\n description text, -- short description or synopsis of the game\n platform character varying(50) NOT NULL, -- primary platform (e.g., PC, PlayStation 5, Xbox Series X, Mobile)\n engine character varying(100), -- game engine used (e.g., Unreal Engine 5, Unity)\n website character varying(255), -- official website URL\n PRIMARY KEY (game_id)\n -- FOREIGN KEY (developer_id) REFERENCES gaming_technology.developers(developer_id) -- Example FK constraint\n)\nCREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid, 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 )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, achievement_id uuid NOT NULL, unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) )\nCREATE TABLE gaming_technology.in_game_items (\n item_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the item definition\n game_id uuid NOT NULL, -- FK linking to the game this item belongs to\n item_name character varying(150) NOT NULL, -- name of the item\n item_type character varying(50) NOT NULL, -- type (e.g., Cosmetic, Consumable, Weapon, Armor)\n description text, -- description of the item\n rarity character varying(30), -- item rarity (e.g., Common, Rare, Epic, Legendary)\n cost_currency character varying(10), -- currency code if purchasable (e.g., USD, EUR, GOLD)\n cost_amount numeric(12, 2), -- price if purchasable\n attributes jsonb, -- flexible field for item stats or properties\n PRIMARY KEY (item_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\nCREATE TABLE gaming_technology.player_inventory ( inventory_id.uuid, player_id.uuid, item_id.uuid, quantity.integer, acquired_at.timestamptz, instance_data.jsonb )\n", "conversations": [{"role": "user", "content": "List players who have completed at least one game session with a score greater than 100, showing their player_id and username."}, {"role": "assistant", "content": "SELECT DISTINCT T1.player_id, T1.username FROM gaming_technology.players AS T1 JOIN gaming_technology.game_sessions AS T2 ON T1.player_id = T2.player_id WHERE T2.score > 100;"}, {"role": "user", "content": "For these players, show the total number of sessions they have played where their score was above 100."}, {"role": "assistant", "content": "SELECT T1.player_id, T1.username, COUNT(T2.session_id) AS high_score_sessions FROM gaming_technology.players AS T1 JOIN gaming_technology.game_sessions AS T2 ON T1.player_id = T2.player_id WHERE T2.score > 100 GROUP BY T1.player_id, T1.username;"}, {"role": "user", "content": "Include the total duration in minutes of all sessions played by these players (even those below 100 score)."}, {"role": "assistant", "content": "SELECT T1.player_id, T1.username, COUNT(T2.session_id) AS high_score_sessions, SUM(T3.duration_seconds) / 60.0 AS total_duration_minutes FROM gaming_technology.players AS T1 JOIN gaming_technology.game_sessions AS T2 ON T1.player_id = T2.player_id AND T2.score > 100 JOIN gaming_technology.game_sessions AS T3 ON T1.player_id = T3.player_id GROUP BY T1.player_id, T1.username;"}, {"role": "user", "content": "Order the results by the total duration in minutes descending and limit to the top 5 players."}, {"role": "assistant", "content": "SELECT T1.player_id, T1.username, COUNT(T2.session_id) AS high_score_sessions, SUM(T3.duration_seconds) / 60.0 AS total_duration_minutes FROM gaming_technology.players AS T1 JOIN gaming_technology.game_sessions AS T2 ON T1.player_id = T2.player_id AND T2.score > 100 JOIN gaming_technology.game_sessions AS T3 ON T1.player_id = T3.player_id GROUP BY T1.player_id, T1.username ORDER BY total_duration_minutes DESC LIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Show me all insurance plans where the website includes 'secure'."}, {"role": "assistant", "content": "SELECT * FROM healthcare.insurance_plans WHERE website ILIKE '%secure%';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )\nCREATE TABLE trading_platform.peers ( peer_id.text, ip_address.text, port.integer, last_seen.timestamp )\nCREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )\nCREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )\nCREATE TABLE trading_platform.notifications ( notification_id text, user_id text, message text, sent_at timestamp, read_at timestamp )\n", "conversations": [{"role": "user", "content": "List each user's username, email, and the total count of log entries they have recorded."}, {"role": "assistant", "content": "SELECT T1.username, T1.email, count(T2.log_id) FROM users AS T1 LEFT JOIN logs AS T2 ON T1.user_id = T2.user_id GROUP BY T1.user_id, T1.username, T1.email"}, {"role": "user", "content": "Also include the date of their most recent log entry."}, {"role": "assistant", "content": "SELECT T1.username, T1.email, count(T2.log_id), max(T2.logged_at) FROM users AS T1 LEFT JOIN logs AS T2 ON T1.user_id = T2.user_id GROUP BY T1.user_id, T1.username, T1.email"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players ( player_id uuid NOT NULL DEFAULT gen_random_uuid(), username character varying(100) NOT NULL UNIQUE, email character varying(255) NOT NULL UNIQUE, password_hash text NOT NULL, registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, last_login timestamp with time zone, country_code character(2), status character varying(20) NOT NULL DEFAULT 'active', profile_data jsonb, PRIMARY KEY (player_id) )\nCREATE TABLE gaming_technology.games ( game_id uuid PRIMARY KEY, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, game_id uuid NOT NULL, server_id uuid, start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, end_time timestamp with time zone, duration_seconds integer, score integer, session_data jsonb, PRIMARY KEY (session_id) )\nCREATE TABLE gaming_technology.servers ( server_id uuid PRIMARY KEY, game_id uuid, server_name text, region text, ip_address text, port int, current_players int, max_players int, status text, last_heartbeat timestamptz )\nCREATE TABLE gaming_technology.achievements ( achievement_id.uuid, game_id.uuid, name.text, description.text, icon_url.text, points.integer, hidden.boolean )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid PRIMARY KEY, player_id uuid, achievement_id uuid, unlocked_at timestamptz )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid PRIMARY KEY, player_id uuid, item_id uuid, quantity int, acquired_at timestamptz, instance_data jsonb )\n", "conversations": [{"role": "user", "content": "Show each player's username and the number of distinct games they have played sessions on."}, {"role": "assistant", "content": "SELECT\n p.username,\n COUNT(DISTINCT gs.game_id) AS games_played\nFROM gaming_technology.players p\nJOIN gaming_technology.game_sessions gs\n ON p.player_id = gs.player_id\nGROUP BY p.username;"}, {"role": "user", "content": "Now include each player's total number of achievements unlocked."}, {"role": "assistant", "content": "SELECT\n p.username,\n COUNT(DISTINCT gs.game_id) AS games_played,\n COUNT(pa.achievement_id) AS achievements_unlocked\nFROM gaming_technology.players p\nJOIN gaming_technology.game_sessions gs\n ON p.player_id = gs.player_id\nLEFT JOIN gaming_technology.player_achievements pa\n ON p.player_id = pa.player_id\nGROUP BY p.username;"}, {"role": "user", "content": "Exclude players who have played fewer than 3 games or have not unlocked any achievements."}, {"role": "assistant", "content": "SELECT\n p.username,\n COUNT(DISTINCT gs.game_id) AS games_played,\n COUNT(pa.achievement_id) AS achievements_unlocked\nFROM gaming_technology.players p\nJOIN gaming_technology.game_sessions gs\n ON p.player_id = gs.player_id\nLEFT JOIN gaming_technology.player_achievements pa\n ON p.player_id = pa.player_id\nGROUP BY p.username\nHAVING COUNT(DISTINCT gs.game_id) >= 3\n AND COUNT(pa.achievement_id) > 0;"}, {"role": "user", "content": "Also include the first session start_time as first_play and the first achievement unlocked date as first_achievement."}, {"role": "assistant", "content": "SELECT\n p.username,\n COUNT(DISTINCT gs.game_id) AS games_played,\n COUNT(pa.achievement_id) AS achievements_unlocked,\n MIN(gs.start_time) AS first_play,\n MIN(pa.unlocked_at) AS first_achievement\nFROM gaming_technology.players p\nJOIN gaming_technology.game_sessions gs\n ON p.player_id = gs.player_id\nLEFT JOIN gaming_technology.player_achievements pa\n ON p.player_id = pa.player_id\nGROUP BY p.username\nHAVING COUNT(DISTINCT gs.game_id) >= 3\n AND COUNT(pa.achievement_id) > 0;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.orders ( order_id.text, user_id.text, wallet_id.text, asset_id.text, order_type.text, quantity.numeric, price.numeric, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Count the number of orders in each status."}, {"role": "assistant", "content": "SELECT status, COUNT(*) AS order_count\nFROM trading_platform.orders\nGROUP BY status;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCollection 'inspections'. Document structure: { _id: , inspection_id: String, build_id: String (reference), component_id: String (reference, optional), step_id: String (reference, optional), inspection_type: String, inspector_employee_id: String (reference), inspection_timestamp: ISODate, result: String, remarks: String }. Required: inspection_id, build_id, inspection_type, inspector_employee_id, inspection_timestamp, result. Indexes on build_id, component_id, step_id, inspector_employee_id, result.\n", "conversations": [{"role": "user", "content": "\u6211\u60f3\u67e5\u770b\u6240\u6709\u68c0\u67e5\u8bb0\u5f55\u4e2d\u68c0\u67e5\u5458\u7684ID\u548c\u68c0\u67e5\u7ed3\u679c\uff0c\u540c\u65f6\u7edf\u8ba1\u6bcf\u4e2a\u68c0\u67e5\u5458\u7684\u68c0\u67e5\u6b21\u6570\u3002"}, {"role": "assistant", "content": "db.inspections.aggregate([\n {\n $group: {\n _id: '$inspector_employee_id',\n total_inspections: { $count: {} },\n results: { $push: '$result' }\n }\n },\n {\n $project: {\n inspector_employee_id: '$_id',\n total_inspections: 1,\n results: 1,\n _id: 0\n }\n }\n]);"}, {"role": "user", "content": "\u5982\u679c\u6211\u60f3\u53ea\u7edf\u8ba1\u68c0\u67e5\u7ed3\u679c\u4e3a'Fail'\u7684\u6b21\u6570\uff0c\u5e94\u8be5\u600e\u4e48\u6539\uff1f"}, {"role": "assistant", "content": "db.inspections.aggregate([\n {\n $match: {\n result: 'Fail'\n }\n },\n {\n $group: {\n _id: '$inspector_employee_id',\n failed_inspections: { $count: {} }\n }\n },\n {\n $project: {\n inspector_employee_id: '$_id',\n failed_inspections: 1,\n _id: 0\n }\n }\n]);"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\nCREATE TABLE trading_platform.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )\nCREATE TABLE trading_platform.orders ( order_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, wallet_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, order_type character varying(32) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, status character varying(32) NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (order_id) )\nCREATE TABLE trading_platform.trades ( trade_id character varying(64) NOT NULL, order_id character varying(64) NOT NULL, buyer_id character varying(64) NOT NULL, seller_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, quantity numeric(38,14) NOT NULL, price numeric(38,14) NOT NULL, traded_at timestamp NOT NULL, PRIMARY KEY (trade_id) )\nCREATE TABLE trading_platform.utxos ( utxo_id character varying(64) NOT NULL, transaction_id character varying(64) NOT NULL, output_index integer NOT NULL, address character varying(128) NOT NULL, amount numeric(38,14) NOT NULL, spent boolean NOT NULL, PRIMARY KEY (utxo_id) )\nCREATE TABLE trading_platform.dapps ( dapp_id character varying(64) NOT NULL, name character varying(128) NOT NULL, description text NOT NULL, url character varying(256) NOT NULL, PRIMARY KEY (dapp_id) )\nCREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) )\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, status character varying(32) NOT NULL, reviewed_at timestamp NOT NULL, PRIMARY KEY (kyc_audit_id) )\nCREATE TABLE trading_platform.logs ( log_id character varying(64) NOT NULL, user_id character varying(64), action character varying(128) NOT NULL, details text NOT NULL, logged_at timestamp NOT NULL, PRIMARY KEY (log_id) )\nCREATE TABLE trading_platform.notifications ( notification_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, message text NOT NULL, sent_at timestamp NOT NULL, read_at timestamp, PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "List each user\u2019s user_id and username along with their total trading value (sum of quantity * price from trades) as a buyer for trades executed in June 2024. Show the top 5 users by total value descending."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, SUM(t.quantity * t.price) AS total_value\nFROM trading_platform.users u\nJOIN trading_platform.trades t ON u.user_id = t.buyer_id\nWHERE t.traded_at >= '2024-06-01' AND t.traded_at < '2024-07-01'\nGROUP BY u.user_id, u.username\nORDER BY total_value DESC\nLIMIT 5;"}, {"role": "user", "content": "Refine the query to include only users whose most recent KYC audit status is 'approved'."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, SUM(t.quantity * t.price) AS total_value\nFROM trading_platform.users u\nJOIN trading_platform.trades t ON u.user_id = t.buyer_id\nJOIN (\n SELECT user_id, status\n FROM trading_platform.kyc_audit\n WHERE (user_id, reviewed_at) IN (\n SELECT user_id, MAX(reviewed_at) FROM trading_platform.kyc_audit GROUP BY user_id\n )\n) ka ON u.user_id = ka.user_id AND ka.status = 'approved'\nWHERE t.traded_at >= '2024-06-01' AND t.traded_at < '2024-07-01'\nGROUP BY u.user_id, u.username\nORDER BY total_value DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )\n", "conversations": [{"role": "user", "content": "List all tokens on the BSC chain with a price below $1."}, {"role": "assistant", "content": "SELECT token_symbol, token_name, price FROM token_dexpool_info WHERE chain = 'BSC' AND price < 1;"}, {"role": "user", "content": "Only show tokens where the 24-hour trading volume is above $200,000 and order the results by price ascending."}, {"role": "assistant", "content": "SELECT token_symbol, token_name, price FROM token_dexpool_info WHERE chain = 'BSC' AND price < 1 AND volume_24h > 200000 ORDER BY price ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies (\n policy_id character varying(64) NOT NULL, -- unique identifier for the policy\n customer_id character varying(64) NOT NULL, -- identifier for the policyholder (FK to customers)\n product_id character varying(64) NOT NULL, -- identifier for the insurance product (FK to insurance_products)\n agent_id character varying(64), -- identifier for the agent who sold the policy (FK to agents)\n policy_number character varying(100) NOT NULL UNIQUE, -- customer-facing policy number\n start_date date NOT NULL, -- date the policy coverage begins\n end_date date NOT NULL, -- date the policy coverage ends\n premium_amount numeric(12, 2) NOT NULL, -- total premium for the policy term\n coverage_limit numeric(15, 2) NOT NULL, -- maximum amount covered\n deductible numeric(10, 2) NOT NULL, -- amount customer pays before coverage kicks in\n status character varying(30) NOT NULL, -- e.g., Active, Expired, Cancelled, Pending\n issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the policy was issued\n cancellation_date date,\n cancellation_reason text,\n PRIMARY KEY (policy_id)\n)\n", "conversations": [{"role": "user", "content": "Which agents have sold more than 10 insurance policies, and what are the average premium amounts of the policies they sold? Also, include the agent ID and their name."}, {"role": "assistant", "content": "SELECT a.agent_id, a.first_name, a.last_name, COUNT(p.policy_id) AS policies_sold, AVG(p.premium_amount) AS avg_premium\nFROM insurance.policies p\nJOIN insurance.agents a ON p.agent_id = a.agent_id\nGROUP BY a.agent_id, a.first_name, a.last_name\nHAVING COUNT(p.policy_id) > 10;"}, {"role": "user", "content": "Actually, could you add the license_state of each agent as well?"}, {"role": "assistant", "content": "SELECT a.agent_id, a.first_name, a.last_name, a.license_state, COUNT(p.policy_id) AS policies_sold, AVG(p.premium_amount) AS avg_premium\nFROM insurance.policies p\nJOIN insurance.agents a ON p.agent_id = a.agent_id\nGROUP BY a.agent_id, a.first_name, a.last_name, a.license_state\nHAVING COUNT(p.policy_id) > 10;"}, {"role": "user", "content": "Please only include agents where the average premium amount is above $3000."}, {"role": "assistant", "content": "SELECT a.agent_id, a.first_name, a.last_name, a.license_state, COUNT(p.policy_id) AS policies_sold, AVG(p.premium_amount) AS avg_premium\nFROM insurance.policies p\nJOIN insurance.agents a ON p.agent_id = a.agent_id\nGROUP BY a.agent_id, a.first_name, a.last_name, a.license_state\nHAVING COUNT(p.policy_id) > 10 AND AVG(p.premium_amount) > 3000;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\nCREATE TABLE financial_services.securities ( security_id text PRIMARY KEY, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial PRIMARY KEY, security_id text, data_timestamp timestamp, open_price numeric, high_price numeric, low_price numeric, close_price numeric, adjusted_close_price numeric, volume bigint, source text )\nCREATE TABLE financial_services.loans ( loan_id text PRIMARY KEY, account_id text, loan_type text, principal_amount numeric, current_principal_balance numeric, interest_rate numeric, term_months int, origination_date date, maturity_date date, monthly_payment numeric, collateral_description text, status text )\n", "conversations": [{"role": "user", "content": "For each security sector, calculate the total trading volume and the average closing price from market data for the past year. Include the sector name."}, {"role": "assistant", "content": "SELECT T1.sector, SUM(T2.volume) AS total_volume, AVG(T2.close_price) AS average_close_price FROM financial_services.securities AS T1 JOIN financial_services.market_data AS T2 ON T1.security_id = T2.security_id WHERE T2.data_timestamp >= CURRENT_DATE - INTERVAL '1 year' GROUP BY T1.sector;"}, {"role": "user", "content": "Exclude any sectors where the total volume is less than 10,000,000."}, {"role": "assistant", "content": "SELECT T1.sector, SUM(T2.volume) AS total_volume, AVG(T2.close_price) AS average_close_price FROM financial_services.securities AS T1 JOIN financial_services.market_data AS T2 ON T1.security_id = T2.security_id WHERE T2.data_timestamp >= CURRENT_DATE - INTERVAL '1 year' GROUP BY T1.sector HAVING SUM(T2.volume) >= 10000000;"}, {"role": "user", "content": "Order the results by the average closing price in descending order."}, {"role": "assistant", "content": "SELECT T1.sector, SUM(T2.volume) AS total_volume, AVG(T2.close_price) AS average_close_price FROM financial_services.securities AS T1 JOIN financial_services.market_data AS T2 ON T1.security_id = T2.security_id WHERE T2.data_timestamp >= CURRENT_DATE - INTERVAL '1 year' GROUP BY T1.sector HAVING SUM(T2.volume) >= 10000000 ORDER BY average_close_price DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players (\n player_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the player\n username character varying(100) NOT NULL UNIQUE, -- player's chosen display name\n email character varying(255) NOT NULL UNIQUE, -- player's email address for login/recovery\n password_hash text NOT NULL, -- securely hashed password\n registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the player account was created\n last_login timestamp with time zone, -- timestamp of the last successful login\n country_code character(2), -- player's country (ISO 3166-1 alpha-2)\n status character varying(20) NOT NULL DEFAULT 'active', -- account status (e.g., active, banned, suspended)\n profile_data jsonb, -- flexible field for avatar url, bio, preferences etc.\n PRIMARY KEY (player_id)\n)\nCREATE TABLE gaming_technology.games (\n game_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game\n title character varying(200) NOT NULL, -- official title of the game\n developer_id uuid NOT NULL, -- FK linking to the developers table\n publisher_id uuid, -- FK linking to a potential publishers table (optional)\n genre character varying(100), -- primary genre (e.g., RPG, FPS, Strategy)\n release_date date, -- official release date\n description text, -- short description or synopsis of the game\n platform character varying(50) NOT NULL, -- primary platform (e.g., PC, PlayStation 5, Xbox Series X, Mobile)\n engine character varying(100), -- game engine used (e.g., Unreal Engine 5, Unity)\n website character varying(255), -- official website URL\n PRIMARY KEY (game_id)\n -- FOREIGN KEY (developer_id) REFERENCES gaming_technology.developers(developer_id) -- Example FK constraint\n)\nCREATE TABLE gaming_technology.developers (\n developer_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the developer studio\n name character varying(150) NOT NULL UNIQUE, -- name of the development studio\n country character varying(100), -- country where the studio is based\n founded_year integer, -- year the studio was founded\n website character varying(255), -- developer's official website\n created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (developer_id)\n)\nCREATE TABLE gaming_technology.servers (\n server_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game server instance\n game_id uuid NOT NULL, -- FK linking to the game this server hosts\n server_name character varying(150), -- display name for the server\n region character varying(50) NOT NULL, -- geographical region (e.g., us-east-1, eu-west-2)\n ip_address character varying(45), -- IP address (IPv4 or IPv6)\n port integer, -- network port number\n current_players integer NOT NULL DEFAULT 0, -- number of players currently connected\n max_players integer NOT NULL, -- maximum player capacity\n status character varying(30) NOT NULL DEFAULT 'offline', -- server status (e.g., online, offline, maintenance)\n last_heartbeat timestamp with time zone, -- last time the server reported its status\n PRIMARY KEY (server_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\nCREATE TABLE gaming_technology.achievements (\n achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition\n game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to\n name character varying(150) NOT NULL, -- name of the achievement\n description text NOT NULL, -- how to unlock the achievement\n icon_url character varying(255), -- URL for the achievement's icon\n points integer DEFAULT 0, -- points awarded for unlocking (optional)\n hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked\n PRIMARY KEY (achievement_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\nCREATE TABLE gaming_technology.player_achievements (\n player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for this unlock instance\n player_id uuid NOT NULL, -- FK linking to the player who unlocked it\n achievement_id uuid NOT NULL, -- FK linking to the achievement definition\n unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the achievement was unlocked\n PRIMARY KEY (player_achievement_id),\n UNIQUE (player_id, achievement_id) -- Ensure a player can only unlock an achievement once\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (achievement_id) REFERENCES gaming_technology.achievements(achievement_id)\n)\nCREATE TABLE gaming_technology.in_game_items (\n item_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the item definition\n game_id uuid NOT NULL, -- FK linking to the game this item belongs to\n item_name character varying(150) NOT NULL, -- name of the item\n item_type character varying(50) NOT NULL, -- type (e.g., Cosmetic, Consumable, Weapon, Armor)\n description text, -- description of the item\n rarity character varying(30), -- item rarity (e.g., Common, Rare, Epic, Legendary)\n cost_currency character varying(10), -- currency code if purchasable (e.g., USD, EUR, GOLD)\n cost_amount numeric(12, 2), -- price if purchasable\n attributes jsonb, -- flexible field for item stats or properties\n PRIMARY KEY (item_id)\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id)\n)\nCREATE TABLE gaming_technology.player_inventory (\n inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an inventory entry\n player_id uuid NOT NULL, -- FK linking to the player owning the item\n item_id uuid NOT NULL, -- FK linking to the item definition\n quantity integer NOT NULL DEFAULT 1, -- number of items held (for stackable items)\n acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the item was acquired\n instance_data jsonb, -- data specific to this instance (e.g., weapon mods, durability)\n PRIMARY KEY (inventory_id),\n -- Optional unique constraint if items are non-stackable or unique instances\n -- UNIQUE (player_id, item_id) -- Use if quantity is always 1\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (item_id) REFERENCES gaming_technology.in_game_items(item_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve the player_id, username, and game title for all players who have at least one item in their inventory."}, {"role": "assistant", "content": "SELECT DISTINCT p.player_id, p.username, g.title\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id;"}, {"role": "user", "content": "Now include the total quantity of items each player holds per game."}, {"role": "assistant", "content": "SELECT p.player_id, p.username, g.title, SUM(pi.quantity) AS total_quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nGROUP BY p.player_id, p.username, g.title;"}, {"role": "user", "content": "Filter out entries where the total_quantity is less than 5."}, {"role": "assistant", "content": "SELECT p.player_id, p.username, g.title, SUM(pi.quantity) AS total_quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nGROUP BY p.player_id, p.username, g.title\nHAVING SUM(pi.quantity) >= 5;"}, {"role": "user", "content": "Sort the results by total_quantity in descending order and limit to the top 10."}, {"role": "assistant", "content": "SELECT p.player_id, p.username, g.title, SUM(pi.quantity) AS total_quantity\nFROM gaming_technology.players p\nJOIN gaming_technology.player_inventory pi ON p.player_id = pi.player_id\nJOIN gaming_technology.in_game_items i ON pi.item_id = i.item_id\nJOIN gaming_technology.games g ON i.game_id = g.game_id\nGROUP BY p.player_id, p.username, g.title\nHAVING SUM(pi.quantity) >= 5\nORDER BY total_quantity DESC\nLIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.developers (\n developer_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the developer studio\n name character varying(150) NOT NULL UNIQUE, -- name of the development studio\n country character varying(100), -- country where the studio is based\n founded_year integer, -- year the studio was founded\n website character varying(255), -- developer's official website\n created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (developer_id)\n)\n", "conversations": [{"role": "user", "content": "Could you list all pairs of developers that are based in the same country and share the same website domain?"}, {"role": "assistant", "content": "SELECT\n d1.name AS developer1_name,\n d2.name AS developer2_name,\n d1.country,\n d1.website\nFROM\n gaming_technology.developers AS d1\nJOIN\n gaming_technology.developers AS d2 ON d1.country = d2.country\n AND d1.website = d2.website\n AND d1.developer_id < d2.developer_id\nWHERE\n d1.country IS NOT NULL\n AND d1.website IS NOT NULL AND d1.website != '';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, -- the id of the token token_name character varying(100) NOT NULL, -- the token's name token_symbol character varying(100) NOT NULL, -- the token's symbol token_address character varying(100) NOT NULL, -- the token's address chain text, -- the chain that the token resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours price_change_percentage_7d double precision, -- change in value divided by the absolute price value of the original token price in 7 days highest_price_24h double precision, -- the highest price of the token in 24 hours lowest_price_24h double precision, -- the lowest price of the token in 24 hours market_cap double precision, -- the market cap of the token market_cap_rank bigint, -- the rank of the token market cap in desc market_cap_change_percentage_24h text, -- the percentage of market cap changes in 24 hours total_volume text, -- the trade volum of the token both in decentralized exchange(DEX) and centralized exchange(CEX) narrative text, -- the category or narrative of the token trend_rank biging, -- the trending rank of the token, value 1 expresses the most popular token. ,PRIMARY KEY (coin_id, chain) )\nCREATE TABLE 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) )\nCREATE TABLE smart_money_token_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, chain.text )\n", "conversations": [{"role": "user", "content": "Show tokens held by CEX addresses that have a positive ROI from smart money. Display the token symbol, chain, the exchange holding it, the CEX USD value of the holding, and the smart money ROI. Limit the results to the top 10 tokens ranked by smart money ROI in descending order."}, {"role": "assistant", "content": "SELECT c.token_symbol, c.chain, c.exchange, c.usd_value, s.roi FROM cex_token_balance c JOIN smart_money_token_performance s ON c.token_address = s.token_address AND c.chain = s.chain WHERE s.roi > 0 ORDER BY s.roi DESC LIMIT 10;"}, {"role": "user", "content": "Modify the query to also include the token's narrative and its current price from the basic info table."}, {"role": "assistant", "content": "SELECT c.token_symbol, c.chain, c.exchange, c.usd_value, s.roi, b.narrative, b.price FROM cex_token_balance c JOIN smart_money_token_performance s ON c.token_address = s.token_address AND c.chain = s.chain JOIN token_basic_info b ON c.token_address = b.token_address AND c.chain = b.chain WHERE s.roi > 0 ORDER BY s.roi DESC LIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool )\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id text PRIMARY KEY, post_id text, hashtag_id text )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\nCREATE TABLE social_media.notifications ( notification_id text 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 )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the usernames and emails of users who have liked any comment, along with the comment IDs and when the like occurred."}, {"role": "assistant", "content": "SELECT u.username, u.email, l.comment_id, l.created_at\nFROM social_media.likes l\nJOIN social_media.users u ON l.user_id = u.user_id\nWHERE l.comment_id IS NOT NULL;"}, {"role": "user", "content": "Can you also include the content of the comment for each like in the result?"}, {"role": "assistant", "content": "SELECT u.username, u.email, l.comment_id, c.content AS comment_content, l.created_at\nFROM social_media.likes l\nJOIN social_media.users u ON l.user_id = u.user_id\nJOIN social_media.posts p ON l.post_id = p.post_id\nJOIN social_media.comments c ON l.comment_id = c.comment_id\nWHERE l.comment_id IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents ( document_id text PRIMARY KEY, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version int, description text )\n", "conversations": [{"role": "user", "content": "Show me all documents uploaded by lawyers from law firms located in 'New York'. Include the document name, upload timestamp, the first and last name of the uploading lawyer, and the firm name."}, {"role": "assistant", "content": "SELECT d.document_name, d.upload_timestamp, l.first_name AS lawyer_first_name, l.last_name AS lawyer_last_name, lf.firm_name FROM documents AS d JOIN lawyers AS l ON d.uploaded_by_lawyer_id = l.lawyer_id JOIN law_firms AS lf ON l.firm_id = lf.firm_id WHERE lf.address LIKE '%New York%';"}, {"role": "user", "content": "Okay, but only show documents where the document type is 'Contract'."}, {"role": "assistant", "content": "SELECT d.document_name, d.upload_timestamp, l.first_name AS lawyer_first_name, l.last_name AS lawyer_last_name, lf.firm_name FROM documents AS d JOIN lawyers AS l ON d.uploaded_by_lawyer_id = l.lawyer_id JOIN law_firms AS lf ON l.firm_id = lf.firm_id WHERE lf.address LIKE '%New York%' AND d.document_type = 'Contract';"}, {"role": "user", "content": "Also, sort the results by upload timestamp descending and include the document version."}, {"role": "assistant", "content": "SELECT d.document_name, d.upload_timestamp, d.version, l.first_name AS lawyer_first_name, l.last_name AS lawyer_last_name, lf.firm_name FROM documents AS d JOIN lawyers AS l ON d.uploaded_by_lawyer_id = l.lawyer_id JOIN law_firms AS lf ON l.firm_id = lf.firm_id WHERE lf.address LIKE '%New York%' AND d.document_type = 'Contract' ORDER BY d.upload_timestamp DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id text PRIMARY KEY, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "Show all reviews with the guest's ID, review comment, and the full name of the staff member who responded."}, {"role": "assistant", "content": "SELECT r.review_id, r.guest_id, r.comment, s.first_name AS response_staff_first_name, s.last_name AS response_staff_last_name\nFROM hospitality_technology.reviews r\nLEFT JOIN hospitality_technology.staff s ON r.response_staff_id = s.staff_id;"}, {"role": "user", "content": "Can you include the property name as well?"}, {"role": "assistant", "content": "SELECT r.review_id, r.guest_id, r.comment, p.property_name, s.first_name AS response_staff_first_name, s.last_name AS response_staff_last_name\nFROM hospitality_technology.reviews r\nJOIN hospitality_technology.properties p ON r.property_id = p.property_id\nLEFT JOIN hospitality_technology.staff s ON r.response_staff_id = s.staff_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nNode Label ':Component'. Properties: { component_id: String (Constraint: UNIQUE), part_number: String (Constraint: UNIQUE), component_name: String, description: String, weight_kg: Float, cost_usd: Float, criticality_level: String }. Relationships: (:Component)-[:MADE_OF]->(:Material {material_id}), (:Component)-[:SUPPLIED_BY]->(:Supplier {supplier_id}). Index on component_id, part_number.\nNode Label ':Supplier'. Properties: { supplier_id: String (Constraint: UNIQUE), supplier_name: String, address: String, country: String, contact_person: String, contact_email: String, quality_rating: Float, certified_date: Date }. Index on supplier_id.\nNode Label ':Material'. Properties: { material_id: String (Constraint: UNIQUE), material_name: String, specification: String, description: String, density_kg_m3: Float, tensile_strength_mpa: Integer }. Index on material_id.\nNode Label ':AssemblyLine'. Properties: { line_id: String (Constraint: UNIQUE), line_name: String, location_building: String, location_area: String, capacity_units_per_month: Integer, status: String }. Relationship: (:AssemblyLine)-[:BUILDS_MODEL]->(:AircraftModel {model_id}). Index on line_id.\nNode Label ':AssemblyStep'. Properties: { step_id: String (Constraint: UNIQUE), step_number: Integer, step_name: String, description: String, standard_duration_hours: Float, required_skill_level: String, workstation: String }. Relationship: (:AssemblyLine {line_id})-[:HAS_STEP {sequence: }]->(:AssemblyStep). Index on step_id.\nNode Label ':AircraftBuild'. Properties: { build_id: String (Constraint: UNIQUE), serial_number: String (Constraint: UNIQUE), build_start_date: Datetime, estimated_completion_date: Date, actual_completion_date: Datetime, current_status: String, customer_order_id: String }. Relationships: (:AircraftBuild)-[:IS_MODEL]->(:AircraftModel {model_id}), (:AircraftBuild)-[:ASSEMBLED_ON]->(:AssemblyLine {line_id}). Index on build_id, serial_number, current_status.\nNode Label ':Inspection'. Properties: { inspection_id: String (Constraint: UNIQUE), inspection_type: String, inspection_timestamp: Datetime, result: String, remarks: String }. Relationships: (:AircraftBuild {build_id})-[:UNDERWENT]->(:Inspection), (:Inspection)-[:PERFORMED_BY]->(:Employee {employee_id}), (:Inspection)-[:INSPECTED_COMPONENT]->(:Component {component_id}) (optional), (:Inspection)-[:FOLLOWED_STEP]->(:AssemblyStep {step_id}) (optional). Index on inspection_id.\nNode Label ':Employee'. Properties: { employee_id: String (Constraint: UNIQUE), first_name: String, last_name: String, job_title: String, skill_certifications: String[], hire_date: Date, employment_status: String }. Relationships: (:Employee)-[:ASSIGNED_TO]->(:AssemblyLine {line_id}), (:Employee)-[:REPORTS_TO]->(:Employee {employee_id as supervisor_id}). Index on employee_id.\nNode Label ':InventoryBatch'. Properties: { inventory_record_id: String (Constraint: UNIQUE), quantity: Integer, location_warehouse: String, location_bin: String, received_date: Datetime, expiry_date: Date, batch_number: String, last_updated: Datetime }. Relationship: (:InventoryBatch)-[:IS_INSTANCE_OF]->(:Component {component_id}). Index on inventory_record_id, component_id.\n", "conversations": [{"role": "user", "content": "Can you help me get a list of inspections performed on a specific aircraft build, including the employee who performed them and the inspected component details?"}, {"role": "assistant", "content": "MATCH (ab:AircraftBuild {build_id: 'specific_build_id'})-[:UNDERWENT]->(i:Inspection)-[:PERFORMED_BY]->(e:Employee)\nOPTIONAL MATCH (i)-[:INSPECTED_COMPONENT]->(c:Component)\nRETURN i.inspection_id, i.inspection_type, i.inspection_timestamp, i.result, e.employee_id, e.first_name, e.last_name, c.component_id, c.component_name"}, {"role": "user", "content": "Can you filter this to show only inspections with a result of 'Fail'?"}, {"role": "assistant", "content": "MATCH (ab:AircraftBuild {build_id: 'specific_build_id'})-[:UNDERWENT]->(i:Inspection)-[:PERFORMED_BY]->(e:Employee)\nOPTIONAL MATCH (i)-[:INSPECTED_COMPONENT]->(c:Component)\nWHERE i.result = 'Fail'\nRETURN i.inspection_id, i.inspection_type, i.inspection_timestamp, i.result, e.employee_id, e.first_name, e.last_name, c.component_id, c.component_name"}, {"role": "user", "content": "What if I also want to include the assembly step details for each inspection?"}, {"role": "assistant", "content": "MATCH (ab:AircraftBuild {build_id: 'specific_build_id'})-[:UNDERWENT]->(i:Inspection)-[:PERFORMED_BY]->(e:Employee)\nOPTIONAL MATCH (i)-[:INSPECTED_COMPONENT]->(c:Component)\nOPTIONAL MATCH (i)-[:FOLLOWED_STEP]->(s:AssemblyStep)\nWHERE i.result = 'Fail'\nRETURN i.inspection_id, i.inspection_type, i.inspection_timestamp, i.result, e.employee_id, e.first_name, e.last_name, c.component_id, c.component_name, s.step_id, s.step_name, s.description"}, {"role": "user", "content": "Can you sort the results by inspection timestamp in ascending order?"}, {"role": "assistant", "content": "MATCH (ab:AircraftBuild {build_id: 'specific_build_id'})-[:UNDERWENT]->(i:Inspection)-[:PERFORMED_BY]->(e:Employee)\nOPTIONAL MATCH (i)-[:INSPECTED_COMPONENT]->(c:Component)\nOPTIONAL MATCH (i)-[:FOLLOWED_STEP]->(s:AssemblyStep)\nWHERE i.result = 'Fail'\nRETURN i.inspection_id, i.inspection_type, i.inspection_timestamp, i.result, e.employee_id, e.first_name, e.last_name, c.component_id, c.component_name, s.step_id, s.step_name, s.description\nORDER BY i.inspection_timestamp ASC"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.invoices ( invoice_id text, invoice_number text, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me the total hours worked and total amount billed for each case that has associated invoices, along with the case ID and invoice number."}, {"role": "assistant", "content": "SELECT t.case_id, i.invoice_number, SUM(t.hours_spent) AS total_hours, SUM(t.hours_spent * t.billing_rate) AS total_billed_amount\nFROM legal_services.time_entries t\nJOIN legal_services.invoices i ON t.invoice_id = i.invoice_id\nGROUP BY t.case_id, i.invoice_number;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text )\n", "conversations": [{"role": "user", "content": "For each driver, show their driver_id, email, and the number of days until their license expires."}, {"role": "assistant", "content": "SELECT driver_id, email, (license_expiry_date - CURRENT_DATE) AS days_until_expiry\nFROM transportation.drivers;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses (\n diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry\n record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)\n diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)\n code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used\n description text, -- textual description of the diagnosis\n diagnosis_date date NOT NULL, -- date the diagnosis was made\n status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out\n is_chronic boolean DEFAULT false, -- flag for chronic conditions\n PRIMARY KEY (diagnosis_id)\n)\n", "conversations": [{"role": "user", "content": "Find the diagnosis code and description for all non-chronic diagnoses for patient 'patient_789' made by doctor 'doctor_abc'."}, {"role": "assistant", "content": "SELECT diagnosis_code, description FROM healthcare.diagnoses WHERE patient_id = 'patient_789' AND doctor_id = 'doctor_abc' AND is_chronic = false;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.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 )\n", "conversations": [{"role": "user", "content": "For each player, can you find the username and registration_date of the player who registered immediately before them in the same country?"}, {"role": "assistant", "content": "SELECT p.player_id,\n p.username AS current_username,\n p.registration_date,\n prev.username AS prev_username,\n prev.registration_date AS prev_registration_date\nFROM gaming_technology.players p\nLEFT JOIN gaming_technology.players prev\n ON p.country_code = prev.country_code\n AND prev.registration_date = (\n SELECT MAX(registration_date)\n FROM gaming_technology.players\n WHERE country_code = p.country_code\n AND registration_date < p.registration_date\n );"}, {"role": "user", "content": "Actually, I'd like to exclude players who don't have a previous registrant, so only show rows where prev_username is not null."}, {"role": "assistant", "content": "SELECT p.player_id,\n p.username AS current_username,\n p.registration_date,\n prev.username AS prev_username,\n prev.registration_date AS prev_registration_date\nFROM gaming_technology.players p\nJOIN gaming_technology.players prev\n ON p.country_code = prev.country_code\n AND prev.registration_date = (\n SELECT MAX(registration_date)\n FROM gaming_technology.players\n WHERE country_code = p.country_code\n AND registration_date < p.registration_date\n );"}, {"role": "user", "content": "I'd like the final result ordered by country_code and then by the player's registration_date."}, {"role": "assistant", "content": "SELECT p.player_id,\n p.username AS current_username,\n p.registration_date,\n prev.username AS prev_username,\n prev.registration_date AS prev_registration_date\nFROM gaming_technology.players p\nJOIN gaming_technology.players prev\n ON p.country_code = prev.country_code\n AND prev.registration_date = (\n SELECT MAX(registration_date)\n FROM gaming_technology.players\n WHERE country_code = p.country_code\n AND registration_date < p.registration_date\n )\nORDER BY p.country_code, p.registration_date;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "List all pairs of servers in the same region that are both 'online', showing server1_name, server2_name, and the absolute difference in current_players."}, {"role": "assistant", "content": "SELECT\n s1.server_name AS server1_name,\n s2.server_name AS server2_name,\n ABS(s1.current_players - s2.current_players) AS player_diff\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\nWHERE s1.server_id <> s2.server_id\n AND s1.status = 'online'\n AND s2.status = 'online';"}, {"role": "user", "content": "Actually, only include each pair once (server1_id < server2_id) and where player_diff is less than 20."}, {"role": "assistant", "content": "SELECT\n s1.server_name AS server1_name,\n s2.server_name AS server2_name,\n ABS(s1.current_players - s2.current_players) AS player_diff\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\n AND s1.server_id < s2.server_id\nWHERE s1.status = 'online'\n AND s2.status = 'online'\n AND ABS(s1.current_players - s2.current_players) < 20;"}, {"role": "user", "content": "Now, only include pairs where both servers have max_players greater than 100."}, {"role": "assistant", "content": "SELECT\n s1.server_name AS server1_name,\n s2.server_name AS server2_name,\n ABS(s1.current_players - s2.current_players) AS player_diff\nFROM gaming_technology.servers s1\nJOIN gaming_technology.servers s2\n ON s1.region = s2.region\n AND s1.server_id < s2.server_id\nWHERE s1.status = 'online'\n AND s2.status = 'online'\n AND ABS(s1.current_players - s2.current_players) < 20\n AND s1.max_players > 100\n AND s2.max_players > 100;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\n", "conversations": [{"role": "user", "content": "List all developers founded before the year 2000, showing their name, country, and the year they were founded."}, {"role": "assistant", "content": "SELECT name, country, founded_year FROM gaming_technology.developers WHERE founded_year < 2000;"}, {"role": "user", "content": "Could you also include the website for these developers?"}, {"role": "assistant", "content": "SELECT name, country, founded_year, website FROM gaming_technology.developers WHERE founded_year < 2000;"}, {"role": "user", "content": "Now, only include developers located in 'USA', 'Canada', or 'Mexico'."}, {"role": "assistant", "content": "SELECT name, country, founded_year, website FROM gaming_technology.developers WHERE founded_year < 2000 AND country IN ('USA', 'Canada', 'Mexico');"}, {"role": "user", "content": "Finally, order the results by country ascending and then by founded year ascending."}, {"role": "assistant", "content": "SELECT name, country, founded_year, website FROM gaming_technology.developers WHERE founded_year < 2000 AND country IN ('USA', 'Canada', 'Mexico') ORDER BY country ASC, founded_year ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me all rooms on floor 4 or above together with their room number, features, and current status."}, {"role": "assistant", "content": "SELECT room_id, room_number, features, status\nFROM hospitality_technology.rooms\nWHERE floor >= 4;"}, {"role": "user", "content": "Only include rooms that are marked as non-smoking and sort the results by floor descending."}, {"role": "assistant", "content": "SELECT room_id, room_number, features, status, floor\nFROM hospitality_technology.rooms\nWHERE floor >= 4 AND is_smoking = FALSE\nORDER BY floor DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.locations ( location_id text PRIMARY KEY, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text )\n", "conversations": [{"role": "user", "content": "Find all distinct pairs of locations that are located in the same city. List their IDs, names, and the shared city."}, {"role": "assistant", "content": "SELECT l1.location_id AS location1_id, l1.name AS location1_name, l2.location_id AS location2_id, l2.name AS location2_name, l1.city FROM transportation.locations AS l1 JOIN transportation.locations AS l2 ON l1.city = l2.city AND l1.location_id < l2.location_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.services (\n service_id character varying(64) NOT NULL, -- unique identifier for the service\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n service_name character varying(255) NOT NULL, -- name of the service (e.g., Driver's License Renewal)\n description text,\n category character varying(100), -- e.g., Licensing, Benefits, Taxation, Permits\n eligibility_criteria text, -- description of who is eligible\n standard_fee numeric(10, 2) DEFAULT 0.00, -- typical fee for the service\n average_processing_time_days integer, -- estimated processing time\n is_active boolean DEFAULT true, -- whether the service is currently offered\n online_application_url character varying(255),\n PRIMARY KEY (service_id)\n)\nCREATE TABLE government_services.documents ( document_id text PRIMARY KEY, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\n", "conversations": [{"role": "user", "content": "Retrieve the service names, location names, and cities for active services offered at accessible locations in California."}, {"role": "assistant", "content": "SELECT s.service_name,\n sl.location_name,\n sl.city\nFROM government_services.services AS s\nJOIN government_services.service_locations AS sl\n ON s.agency_id = sl.agency_id\nWHERE s.is_active = TRUE\n AND sl.is_accessible = TRUE\n AND sl.state = 'California';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.agents ( agent_id text, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )\nCREATE TABLE insurance.premium_payments (\n payment_id character varying(64) NOT NULL, -- unique identifier for the payment\n policy_id character varying(64) NOT NULL, -- identifier of the policy the payment is for (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the payment (FK to customers)\n payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the payment was received\n amount_paid numeric(12, 2) NOT NULL, -- amount of the payment\n payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check\n transaction_reference character varying(128) UNIQUE, -- reference from payment processor\n due_date date, -- due date for this payment installment\n payment_period_start date, -- start date of the period this payment covers\n payment_period_end date, -- end date of the period this payment covers\n status character varying(30) NOT NULL DEFAULT 'Completed', -- e.g., Completed, Pending, Failed, Refunded\n PRIMARY KEY (payment_id)\n)\nCREATE TABLE insurance.claim_documents ( document_id character varying(64) NOT NULL, claim_id character varying(64) NOT NULL, document_type character varying(50) NOT NULL, file_name character varying(255) NOT NULL, file_path character varying(512) NOT NULL, file_size_bytes integer, mime_type character varying(100), uploaded_by character varying(64), uploaded_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text, PRIMARY KEY (document_id) )\n", "conversations": [{"role": "user", "content": "Can you retrieve the document_id, file_name, file_size_bytes, uploaded_at, and the full name of the agent (first and last name concatenated) for all documents uploaded in 2024 by active agents licensed in CA?"}, {"role": "assistant", "content": "SELECT cd.document_id, cd.file_name, cd.file_size_bytes, cd.uploaded_at, a.first_name || ' ' || a.last_name AS agent_full_name FROM insurance.claim_documents cd JOIN insurance.agents a ON cd.uploaded_by = a.agent_id WHERE a.license_state = 'CA' AND a.status = 'Active' AND cd.uploaded_at BETWEEN '2024-01-01' AND '2024-12-31';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\n", "conversations": [{"role": "user", "content": "List all pairs of law firms founded in the same year, showing both firm names and their shared founding year."}, {"role": "assistant", "content": "SELECT lf1.firm_name AS firm1, lf2.firm_name AS firm2, EXTRACT(YEAR FROM lf1.founded_date) AS founded_year\nFROM legal_services.law_firms lf1\nJOIN legal_services.law_firms lf2\n ON EXTRACT(YEAR FROM lf1.founded_date) = EXTRACT(YEAR FROM lf2.founded_date)\n AND lf1.firm_id < lf2.firm_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types ( room_type_id.text, property_id.text, type_name.text, description.text, base_rate.numeric, max_occupancy.integer, bed_type.text, area_sqft.numeric, amenities.text )\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )\nCREATE TABLE hospitality_technology.payments ( payment_id.text, reservation_id.text, guest_id.text, bill_id.text, amount.numeric, currency_code.text, payment_method.text, card_type.text, card_last_four.text, transaction_ref.text, payment_timestamp.timestamp, status.text, staff_id_processed.text, notes.text )\nCREATE TABLE hospitality_technology.reviews ( review_id text PRIMARY KEY, property_id text, reservation_id text, guest_id text, rating_overall int, rating_cleanliness int, rating_service int, rating_location int, rating_value int, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "Get each property's name, manager_staff_id, and the number of rooms with status 'OutOfOrder', including properties with zero OutOfOrder rooms."}, {"role": "assistant", "content": "SELECT p.property_name, p.manager_staff_id, COUNT(r.room_id) AS out_of_order_count\nFROM hospitality_technology.properties p\nLEFT JOIN hospitality_technology.rooms r\n ON p.property_id = r.property_id AND r.status = 'OutOfOrder'\nGROUP BY p.property_name, p.manager_staff_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE project_fundraising_record ( id character varying(32) NOT NULL, project_id character varying(32) NOT NULL, project_name character varying(128) NOT NULL, rounds_name character varying(32), investment_value numeric(38,14), investment_date character varying(128), introduction character varying(128), valuation numeric(38,14) )\nCREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, token_name character varying(100) NOT NULL, token_symbol character varying(100) NOT NULL, token_address character varying(100) NOT NULL, chain text, price double precision, price_change_percentage_1h double precision, price_change_percentage_24h double precision, price_change_percentage_7d double precision, highest_price_24h double precision, lowest_price_24h double precision, market_cap double precision, market_cap_rank bigint, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank bigint )\nCREATE TABLE narrative_info ( narrative character varying(512) NOT NULL, top_3_coins text, price_change_percentage_1h double precision, price_change_percentage_24h double precision, price_change_percentage_7d double precision, market_cap double precision, volume_24h double precision, trend_rank bigint, token_num bigint )\nCREATE TABLE cex_token_balance ( snapshot_time character varying(32) NOT NULL, chain character varying(128) NOT NULL, address character varying(128) NOT NULL, exchange character varying(512) NOT NULL, token_address character varying(128) NOT NULL, token_symbol character varying(512), balance numeric(38,10), usd_value numeric(38,14), price double precision )\nCREATE TABLE smart_money_profit ( address character varying(100) NOT NULL, rank INT, profit numeric(38,6), roi numeric(38,2), realized_ratio numeric(38,2), most_profit_token character varying(100), last_trade_time character varying(100), chain character varying(100) )\nCREATE TABLE smart_money_token_performance ( token_address character varying(100) NOT NULL, token_symbol character varying(100), pnl numeric(38,2), net_flow numeric(38,2), avg_cost numeric(38,16), price double precision, realized_ratio numeric(10,2), roi numeric(10,2), chain character varying(100) )\nCREATE TABLE smart_money_token_inflow ( token_address character varying(100) NOT NULL, token_symbol character varying(100), token_amount numeric(38,2), usd_value numeric(38,2), avg_price numeric(38,6), type int, address_amount integer, narrative character varying(100), chain character varying(100) )\n", "conversations": [{"role": "user", "content": "List projects that raised funds in 2023 and have an associated token in token_basic_info. Show project_name, rounds_name, investment_value, token_symbol, and chain."}, {"role": "assistant", "content": "SELECT p.project_name, p.rounds_name, p.investment_value, t.token_symbol, t.chain FROM project_fundraising_record p JOIN token_basic_info t ON LOWER(p.project_name) = LOWER(t.token_name) WHERE p.investment_date LIKE '2023%';"}, {"role": "user", "content": "The results are empty. Please modify the join to match where the token_name contains project_name or project_name contains token_name, case-insensitive."}, {"role": "assistant", "content": "SELECT p.project_name, p.rounds_name, p.investment_value, t.token_symbol, t.chain FROM project_fundraising_record p JOIN token_basic_info t ON LOWER(t.token_name) LIKE '%'||LOWER(p.project_name)||'%' OR LOWER(p.project_name) LIKE '%'||LOWER(t.token_name)||'%' WHERE p.investment_date LIKE '2023%';"}, {"role": "user", "content": "Now only include records where investment_value > 1000000 and token price > 10, and order by price descending."}, {"role": "assistant", "content": "SELECT p.project_name, p.rounds_name, p.investment_value, t.token_symbol, t.chain FROM project_fundraising_record p JOIN token_basic_info t ON (LOWER(t.token_name) LIKE '%'||LOWER(p.project_name)||'%' OR LOWER(p.project_name) LIKE '%'||LOWER(t.token_name)||'%') WHERE p.investment_date LIKE '2023%' AND p.investment_value > 1000000 AND t.price > 10 ORDER BY t.price DESC;"}, {"role": "user", "content": "Finally, include the token's narrative and market_cap, and limit the results to the top 5."}, {"role": "assistant", "content": "SELECT p.project_name, p.rounds_name, p.investment_value, t.token_symbol, t.chain, t.narrative, t.market_cap FROM project_fundraising_record p JOIN token_basic_info t ON (LOWER(t.token_name) LIKE '%'||LOWER(p.project_name)||'%' OR LOWER(p.project_name) LIKE '%'||LOWER(t.token_name)||'%') WHERE p.investment_date LIKE '2023%' AND p.investment_value > 1000000 AND t.price > 10 ORDER BY t.price DESC LIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.games ( game_id uuid NOT NULL DEFAULT gen_random_uuid(), title character varying(200) NOT NULL, developer_id uuid NOT NULL, publisher_id uuid, genre character varying(100), release_date date, description text, platform character varying(50) NOT NULL, engine character varying(100), website character varying(255), PRIMARY KEY (game_id) )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, achievement_id uuid NOT NULL, unlocked_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (player_achievement_id), UNIQUE (player_id, achievement_id) )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, item_id uuid NOT NULL, quantity integer NOT NULL DEFAULT 1, acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, instance_data jsonb, PRIMARY KEY (inventory_id) )\n", "conversations": [{"role": "user", "content": "Can you list each server along with its game title and how many players it can still accommodate (max_players - current_players)?"}, {"role": "assistant", "content": "SELECT s.server_id,\n s.server_name,\n g.title AS game_title,\n (s.max_players - s.current_players) AS available_slots\nFROM gaming_technology.servers s\nJOIN gaming_technology.games g ON s.game_id = g.game_id;"}, {"role": "user", "content": "Only include servers that are currently 'online' or 'idle'."}, {"role": "assistant", "content": "SELECT s.server_id,\n s.server_name,\n g.title AS game_title,\n (s.max_players - s.current_players) AS available_slots\nFROM gaming_technology.servers s\nJOIN gaming_technology.games g ON s.game_id = g.game_id\nWHERE s.status IN ('online', 'idle');"}, {"role": "user", "content": "Now show only those with available_slots greater than 10, sorted by available_slots descending."}, {"role": "assistant", "content": "SELECT s.server_id,\n s.server_name,\n g.title AS game_title,\n (s.max_players - s.current_players) AS available_slots\nFROM gaming_technology.servers s\nJOIN gaming_technology.games g ON s.game_id = g.game_id\nWHERE s.status IN ('online', 'idle')\n AND (s.max_players - s.current_players) > 10\nORDER BY available_slots DESC;"}, {"role": "user", "content": "Finally, include the game's release_date and only for games released after 2022-01-01."}, {"role": "assistant", "content": "SELECT s.server_id,\n s.server_name,\n g.title AS game_title,\n g.release_date,\n (s.max_players - s.current_players) AS available_slots\nFROM gaming_technology.servers s\nJOIN gaming_technology.games g ON s.game_id = g.game_id\nWHERE s.status IN ('online', 'idle')\n AND (s.max_players - s.current_players) > 10\n AND g.release_date > '2022-01-01'\nORDER BY available_slots DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.transactions ( transaction_id.text, from_address.text, to_address.text, value.numeric, gas_used.integer, gas_price.numeric, block_number.integer, timestamp.timestamp, input_data.text, status.text, nonce.integer )\n", "conversations": [{"role": "user", "content": "List the total value and count of transactions for each status, ordered by total value descending."}, {"role": "assistant", "content": "SELECT status, COUNT(*) AS transaction_count, SUM(value) AS total_value\nFROM web3.transactions\nGROUP BY status\nORDER BY total_value DESC;"}, {"role": "user", "content": "Actually, can you also include the average value per transaction for each status?"}, {"role": "assistant", "content": "SELECT status, COUNT(*) AS transaction_count, SUM(value) AS total_value, AVG(value) AS avg_value\nFROM web3.transactions\nGROUP BY status\nORDER BY total_value DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text )\n", "conversations": [{"role": "user", "content": "Show me all policies that have at least two premium payments associated with them, along with the total amount paid for each policy."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nGROUP BY p.policy_id, p.policy_number\nHAVING COUNT(pp.payment_id) >= 2;"}, {"role": "user", "content": "Actually, also include the start_date and status of each policy in the result."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, p.start_date, p.status, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nGROUP BY p.policy_id, p.policy_number, p.start_date, p.status\nHAVING COUNT(pp.payment_id) >= 2;"}, {"role": "user", "content": "Now restrict the result to only policies with status 'active'."}, {"role": "assistant", "content": "SELECT p.policy_id, p.policy_number, p.start_date, p.status, COUNT(pp.payment_id) AS payment_count, SUM(pp.amount_paid) AS total_amount_paid\nFROM insurance.policies p\nJOIN insurance.premium_payments pp ON p.policy_id = pp.policy_id\nWHERE p.status = 'active'\nGROUP BY p.policy_id, p.policy_number, p.start_date, p.status\nHAVING COUNT(pp.payment_id) >= 2;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.wallets (\n wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet\n user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet\n address character varying(128) NOT NULL, -- address of the wallet\n private_key text NOT NULL, -- private key of the wallet\n created_at timestamp NOT NULL, -- time when the wallet was created\n PRIMARY KEY (wallet_id)\n)\n", "conversations": [{"role": "user", "content": "Find all wallets that were created by users with IDs starting with 'user_' and show their addresses along with creation timestamps."}, {"role": "assistant", "content": "SELECT address, created_at FROM web3.wallets WHERE user_id LIKE 'user_%';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id text, post_id text, hashtag_id text )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, recipient_user_id character varying(64) NOT NULL, sender_user_id character varying(64), notification_type character varying(30) NOT NULL, target_entity_id character varying(64), target_entity_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (notification_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the number of followers for each user who is following others, listing their user_id and follower count."}, {"role": "assistant", "content": "SELECT following_user_id AS user_id, COUNT(follower_user_id) AS follower_count\nFROM social_media.follows\nGROUP BY following_user_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n// db.createCollection('passengers')\n// Optional: db.passengers.createIndex({ passenger_id: 1 }, { unique: true })\n// Optional: db.passengers.createIndex({ email: 1 }, { unique: true, sparse: true })\n// Optional: db.passengers.createIndex({ phone_number: 1 }, { unique: true, sparse: true })\n{\n _id: ObjectId(),\n passenger_id: \"pass_pqr\", // String (unique)\n first_name: \"Alice\", // String\n last_name: \"Smith\", // String\n email: \"alice.smith@example.com\", // String (unique, sparse)\n phone_number: \"+15551234567\", // String (unique, sparse)\n date_of_birth: ISODate(\"1990-03-20\"), // Date\n loyalty_program_id: \"LOYALTY123\", // String\n created_at: ISODate(\"2023-02-01T11:00:00Z\") // Date\n}\n", "conversations": [{"role": "user", "content": "I need to find passengers who have a specific phone number prefix '+1555'. Can you help with that?"}, {"role": "assistant", "content": "db.passengers.find({ phone_number: { $regex: '^\\+1555' } }, { first_name: 1, last_name: 1, phone_number: 1, email: 1, _id: 0 })"}, {"role": "user", "content": "Can you also filter these results to include only passengers born before 1995?"}, {"role": "assistant", "content": "db.passengers.find({ phone_number: { $regex: '^\\+1555' }, date_of_birth: { $lt: ISODate('1995-01-01T00:00:00Z') } }, { first_name: 1, last_name: 1, phone_number: 1, email: 1, _id: 0 })"}, {"role": "user", "content": "Can you limit the results to the first 5 passengers?"}, {"role": "assistant", "content": "db.passengers.find({ phone_number: { $regex: '^\\+1555' }, date_of_birth: { $lt: ISODate('1995-01-01T00:00:00Z') } }, { first_name: 1, last_name: 1, phone_number: 1, email: 1, _id: 0 }).limit(5)"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "What is the average overall rating for each property?"}, {"role": "assistant", "content": "SELECT property_id, AVG(rating_overall) AS avg_rating\nFROM hospitality_technology.reviews\nGROUP BY property_id;"}, {"role": "user", "content": "Filter to properties with an average overall rating above 4.5 and sort by that average descending."}, {"role": "assistant", "content": "SELECT property_id, AVG(rating_overall) AS avg_rating\nFROM hospitality_technology.reviews\nGROUP BY property_id\nHAVING AVG(rating_overall) > 4.5\nORDER BY avg_rating DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid, player_id uuid, achievement_id uuid, unlocked_at timestamp with time zone )\n", "conversations": [{"role": "user", "content": "List each achievement with the very next achievement unlocked by the same player using a self-join. Show player_id, current_ach, current_unlocked_at, next_ach, and next_unlocked_at."}, {"role": "assistant", "content": "SELECT pa1.player_id,\n pa1.achievement_id AS current_ach,\n pa1.unlocked_at AS current_unlocked_at,\n pa2.achievement_id AS next_ach,\n pa2.unlocked_at AS next_unlocked_at\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.player_id = pa2.player_id\n AND pa2.unlocked_at = (\n SELECT MIN(pa3.unlocked_at)\n FROM gaming_technology.player_achievements pa3\n WHERE pa3.player_id = pa1.player_id\n AND pa3.unlocked_at > pa1.unlocked_at\n );"}, {"role": "user", "content": "Now restrict to pairs where the time difference between current_unlocked_at and next_unlocked_at is less than 48 hours."}, {"role": "assistant", "content": "SELECT pa1.player_id,\n pa1.achievement_id AS current_ach,\n pa1.unlocked_at AS current_unlocked_at,\n pa2.achievement_id AS next_ach,\n pa2.unlocked_at AS next_unlocked_at\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.player_id = pa2.player_id\n AND pa2.unlocked_at = (\n SELECT MIN(pa3.unlocked_at)\n FROM gaming_technology.player_achievements pa3\n WHERE pa3.player_id = pa1.player_id\n AND pa3.unlocked_at > pa1.unlocked_at\n )\nWHERE pa2.unlocked_at - pa1.unlocked_at < INTERVAL '48 hours';"}, {"role": "user", "content": "Order the results by player_id and current_unlocked_at ascending."}, {"role": "assistant", "content": "SELECT pa1.player_id,\n pa1.achievement_id AS current_ach,\n pa1.unlocked_at AS current_unlocked_at,\n pa2.achievement_id AS next_ach,\n pa2.unlocked_at AS next_unlocked_at\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.player_id = pa2.player_id\n AND pa2.unlocked_at = (\n SELECT MIN(pa3.unlocked_at)\n FROM gaming_technology.player_achievements pa3\n WHERE pa3.player_id = pa1.player_id\n AND pa3.unlocked_at > pa1.unlocked_at\n )\nWHERE pa2.unlocked_at - pa1.unlocked_at < INTERVAL '48 hours'\nORDER BY pa1.player_id ASC, pa1.unlocked_at ASC;"}, {"role": "user", "content": "Finally, limit to 20 rows."}, {"role": "assistant", "content": "SELECT pa1.player_id,\n pa1.achievement_id AS current_ach,\n pa1.unlocked_at AS current_unlocked_at,\n pa2.achievement_id AS next_ach,\n pa2.unlocked_at AS next_unlocked_at\nFROM gaming_technology.player_achievements pa1\nJOIN gaming_technology.player_achievements pa2\n ON pa1.player_id = pa2.player_id\n AND pa2.unlocked_at = (\n SELECT MIN(pa3.unlocked_at)\n FROM gaming_technology.player_achievements pa3\n WHERE pa3.player_id = pa1.player_id\n AND pa3.unlocked_at > pa1.unlocked_at\n )\nWHERE pa2.unlocked_at - pa1.unlocked_at < INTERVAL '48 hours'\nORDER BY pa1.player_id ASC, pa1.unlocked_at ASC\nLIMIT 20;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.players (\n player_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the player\n username character varying(100) NOT NULL UNIQUE, -- player's chosen display name\n email character varying(255) NOT NULL UNIQUE, -- player's email address for login/recovery\n password_hash text NOT NULL, -- securely hashed password\n registration_date timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the player account was created\n last_login timestamp with time zone, -- timestamp of the last successful login\n country_code character(2), -- player's country (ISO 3166-1 alpha-2)\n status character varying(20) NOT NULL DEFAULT 'active', -- account status (e.g., active, banned, suspended)\n profile_data jsonb, -- flexible field for avatar url, bio, preferences etc.\n PRIMARY KEY (player_id)\n)\nCREATE TABLE gaming_technology.developers ( developer_id uuid PRIMARY KEY, name text, country text, founded_year int, website text, created_at timestamptz )\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid PRIMARY KEY, player_id uuid, game_id uuid, server_id uuid, start_time timestamptz, end_time timestamptz, duration_seconds int, score int, session_data jsonb )\nCREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz )\nCREATE TABLE gaming_technology.achievements ( achievement_id.uuid, game_id.uuid, name.text, description.text, icon_url.text, points.integer, hidden.boolean )\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\n", "conversations": [{"role": "user", "content": "Can you write a SQL statement that returns each server\u2019s name, its region, and the average duration in seconds of all game sessions that took place on that server? Only include servers that have handled at least 5 sessions."}, {"role": "assistant", "content": "SELECT s.server_name,\n s.region,\n AVG(gs.duration_seconds) AS avg_duration_seconds\nFROM gaming_technology.servers s\nJOIN gaming_technology.game_sessions gs\n ON s.server_id = gs.server_id\nGROUP BY s.server_name, s.region\nHAVING COUNT(gs.session_id) >= 5;"}, {"role": "user", "content": "Actually, I want to see only servers whose average session duration exceeds 1800 seconds."}, {"role": "assistant", "content": "SELECT s.server_name,\n s.region,\n AVG(gs.duration_seconds) AS avg_duration_seconds\nFROM gaming_technology.servers s\nJOIN gaming_technology.game_sessions gs\n ON s.server_id = gs.server_id\nGROUP BY s.server_name, s.region\nHAVING COUNT(gs.session_id) >= 5\n AND AVG(gs.duration_seconds) > 1800;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.services (\n service_id character varying(64) NOT NULL, -- unique identifier for a chargeable service\n property_id character varying(64) NOT NULL, -- FK to properties table\n service_name character varying(150) NOT NULL, -- e.g., Room Service - Burger, Spa - Massage 60min, Laundry - Shirt\n description text,\n category character varying(100), -- e.g., Food & Beverage, Wellness, Business Center, Activities\n price numeric(10, 2) NOT NULL, -- price per unit/instance\n unit character varying(30), -- e.g., Per Item, Per Hour, Per Day\n is_available boolean NOT NULL DEFAULT true, -- is the service currently offered?\n department character varying(100), -- department responsible (e.g., F&B, Spa, Housekeeping)\n PRIMARY KEY (service_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\nCREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )\n", "conversations": [{"role": "user", "content": "List all public reviews with a rating_overall of at least 4, including review_id, guest_id, property_id, reservation_id, and review_date."}, {"role": "assistant", "content": "SELECT review_id, guest_id, property_id, reservation_id, review_date\nFROM hospitality_technology.reviews\nWHERE is_public = true AND rating_overall >= 4;"}, {"role": "user", "content": "Only include reviews in the last 30 days and order by review_date descending."}, {"role": "assistant", "content": "SELECT review_id, guest_id, property_id, reservation_id, review_date\nFROM hospitality_technology.reviews\nWHERE is_public = true\n AND rating_overall >= 4\n AND review_date >= NOW() - INTERVAL '30 days'\nORDER BY review_date DESC;"}, {"role": "user", "content": "Also include the type_name and base_rate of the room type associated with each review's reservation."}, {"role": "assistant", "content": "SELECT rv.review_id,\n rv.guest_id,\n rv.property_id,\n rv.reservation_id,\n rv.review_date,\n rt.type_name,\n rt.base_rate\nFROM hospitality_technology.reviews rv\nJOIN hospitality_technology.reservations r ON rv.reservation_id = r.reservation_id\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id\nWHERE rv.is_public = true\n AND rv.rating_overall >= 4\n AND rv.review_date >= NOW() - INTERVAL '30 days'\nORDER BY rv.review_date DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List all pairs of insurance products that share the same product_type but have differing active statuses. Return both product_ids, the product_type, and each is_active flag."}, {"role": "assistant", "content": "SELECT p1.product_id AS product_id_1, p2.product_id AS product_id_2, p1.product_type, p1.is_active AS is_active_1, p2.is_active AS is_active_2\nFROM insurance.insurance_products p1\nJOIN insurance.insurance_products p2\n ON p1.product_type = p2.product_type\n AND p1.is_active <> p2.is_active\nWHERE p1.product_id < p2.product_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\n", "conversations": [{"role": "user", "content": "For each prescription, find the next prescription for the same patient. Return current prescription_id, next_prescription_id, patient_id, and days between start dates."}, {"role": "assistant", "content": "SELECT p1.patient_id,\n p1.prescription_id AS current_id,\n p2.prescription_id AS next_id,\n (p2.start_date - p1.start_date) AS days_between\nFROM healthcare.prescriptions p1\nJOIN healthcare.prescriptions p2\n ON p1.patient_id = p2.patient_id\n AND p2.start_date = (\n SELECT MIN(start_date)\n FROM healthcare.prescriptions p3\n WHERE p3.patient_id = p1.patient_id\n AND p3.start_date > p1.start_date\n );"}, {"role": "user", "content": "Only include pairs where days_between is less than 30 days."}, {"role": "assistant", "content": "SELECT p1.patient_id,\n p1.prescription_id AS current_id,\n p2.prescription_id AS next_id,\n (p2.start_date - p1.start_date) AS days_between\nFROM healthcare.prescriptions p1\nJOIN healthcare.prescriptions p2\n ON p1.patient_id = p2.patient_id\n AND p2.start_date = (\n SELECT MIN(start_date)\n FROM healthcare.prescriptions p3\n WHERE p3.patient_id = p1.patient_id\n AND p3.start_date > p1.start_date\n )\nWHERE (p2.start_date - p1.start_date) < 30;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.appointments ( appointment_id text PRIMARY KEY, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes int, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text PRIMARY KEY, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\n", "conversations": [{"role": "user", "content": "I want to list the appointment_id, patient_id, appointment_time, and plan_name for all appointments where the status is 'scheduled'. Show me which insurance plans apply."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.patient_id, a.appointment_time, p.plan_name FROM healthcare.appointments a CROSS JOIN healthcare.insurance_plans p WHERE a.status = 'scheduled';"}, {"role": "user", "content": "Actually, I only want to see plans provided by 'HealthCorp'."}, {"role": "assistant", "content": "SELECT a.appointment_id, a.patient_id, a.appointment_time, p.plan_name FROM healthcare.appointments a CROSS JOIN healthcare.insurance_plans p WHERE a.status = 'scheduled' AND p.insurance_provider = 'HealthCorp';"}, {"role": "user", "content": "I got an error about ambiguous column names. Can you alias the tables as ap and ip?"}, {"role": "assistant", "content": "SELECT ap.appointment_id, ap.patient_id, ap.appointment_time, ip.plan_name FROM healthcare.appointments ap CROSS JOIN healthcare.insurance_plans ip WHERE ap.status = 'scheduled' AND ip.insurance_provider = 'HealthCorp';"}, {"role": "user", "content": "Now can you sort the results by appointment_time in descending order?"}, {"role": "assistant", "content": "SELECT ap.appointment_id, ap.patient_id, ap.appointment_time, ip.plan_name FROM healthcare.appointments ap CROSS JOIN healthcare.insurance_plans ip WHERE ap.status = 'scheduled' AND ip.insurance_provider = 'HealthCorp' ORDER BY ap.appointment_time DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.accounts (\n account_id character varying(64) NOT NULL, -- unique identifier for the account\n customer_id character varying(64) NOT NULL, -- foreign key linking to the customer\n account_number character varying(128) NOT NULL UNIQUE, -- unique account number visible to customer\n account_type character varying(50) NOT NULL, -- e.g., Checking, Savings, Investment, Loan, Credit Card\n balance numeric(19, 4) NOT NULL DEFAULT 0.00, -- current account balance\n currency character varying(3) NOT NULL, -- currency code (e.g., USD, EUR)\n opened_date date NOT NULL, -- date the account was opened\n status character varying(32) NOT NULL, -- e.g., Open, Closed, Frozen\n interest_rate numeric(5, 4), -- annual interest rate, if applicable\n last_updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last account update\n PRIMARY KEY (account_id),\n FOREIGN KEY (customer_id) REFERENCES financial_services.customers(customer_id)\n)\n", "conversations": [{"role": "user", "content": "Can you provide a breakdown of total and average account balance by account_type and currency for each account status?"}, {"role": "assistant", "content": "SELECT account_type, currency, status, COUNT(*) AS total_accounts, SUM(balance) AS total_balance, AVG(balance) AS average_balance\nFROM financial_services.accounts\nGROUP BY account_type, currency, status;"}, {"role": "user", "content": "Could you include the minimum and maximum interest rate for each group as well?"}, {"role": "assistant", "content": "SELECT account_type, currency, status, COUNT(*) AS total_accounts, SUM(balance) AS total_balance, AVG(balance) AS average_balance, MIN(interest_rate) AS min_interest_rate, MAX(interest_rate) AS max_interest_rate\nFROM financial_services.accounts\nGROUP BY account_type, currency, status;"}, {"role": "user", "content": "Only show groups where the total_accounts is greater than 20."}, {"role": "assistant", "content": "SELECT account_type, currency, status, COUNT(*) AS total_accounts, SUM(balance) AS total_balance, AVG(balance) AS average_balance, MIN(interest_rate) AS min_interest_rate, MAX(interest_rate) AS max_interest_rate\nFROM financial_services.accounts\nGROUP BY account_type, currency, status\nHAVING COUNT(*) > 20;"}, {"role": "user", "content": "Please sort the results by average_balance in descending order."}, {"role": "assistant", "content": "SELECT account_type, currency, status, COUNT(*) AS total_accounts, SUM(balance) AS total_balance, AVG(balance) AS average_balance, MIN(interest_rate) AS min_interest_rate, MAX(interest_rate) AS max_interest_rate\nFROM financial_services.accounts\nGROUP BY account_type, currency, status\nHAVING COUNT(*) > 20\nORDER BY average_balance DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients (\n client_id character varying(64) NOT NULL, -- unique identifier for the client\n first_name character varying(100) NOT NULL, -- client's first name\n last_name character varying(100) NOT NULL, -- client's last name\n company_name character varying(200), -- company name if applicable\n email character varying(128) UNIQUE NOT NULL, -- client's primary email\n phone character varying(32), -- client's contact phone number\n address text, -- client's full address\n date_registered timestamp NOT NULL, -- when the client was first registered\n status character varying(32) NOT NULL, -- client status (e.g., active, inactive, prospect)\n PRIMARY KEY (client_id)\n)\nCREATE TABLE legal_services.law_firms (\n firm_id character varying(64) NOT NULL, -- unique identifier for the law firm\n firm_name character varying(200) NOT NULL, -- official name of the law firm\n address text NOT NULL, -- primary address of the firm\n phone character varying(32), -- firm's main phone number\n website character varying(255), -- firm's website URL\n founded_date date, -- date the firm was established\n managing_partner_id character varying(64), -- FK to lawyers table (optional)\n PRIMARY KEY (firm_id)\n)\nCREATE TABLE legal_services.time_entries (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the total billable hours per lawyer from the time_entries table."}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours\nFROM legal_services.time_entries\nWHERE is_billable = TRUE\nGROUP BY lawyer_id;"}, {"role": "user", "content": "Refine it to include only entries worked in 2024."}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours\nFROM legal_services.time_entries\nWHERE is_billable = TRUE\n AND date_worked >= '2024-01-01'\n AND date_worked < '2025-01-01'\nGROUP BY lawyer_id;"}, {"role": "user", "content": "Exclude any entries that have already been billed."}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours\nFROM legal_services.time_entries\nWHERE is_billable = TRUE\n AND is_billed = FALSE\n AND date_worked >= '2024-01-01'\n AND date_worked < '2025-01-01'\nGROUP BY lawyer_id;"}, {"role": "user", "content": "Finally, order by total_hours descending and return only the top 5 lawyers."}, {"role": "assistant", "content": "SELECT lawyer_id, SUM(hours_spent) AS total_hours\nFROM legal_services.time_entries\nWHERE is_billable = TRUE\n AND is_billed = FALSE\n AND date_worked >= '2024-01-01'\n AND date_worked < '2025-01-01'\nGROUP BY lawyer_id\nORDER BY total_hours DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.agencies ( agency_id text, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )\nCREATE TABLE government_services.services ( service_id text, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days integer, is_active boolean, online_application_url text )\nCREATE TABLE government_services.payments ( payment_id text, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )\nCREATE TABLE government_services.notifications ( notification_id text, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "Which agencies offer services in the 'Social Assistance' category? Show the agency name and the service name."}, {"role": "assistant", "content": "SELECT a.agency_name, s.service_name\nFROM government_services.services s\nJOIN government_services.agencies a ON s.agency_id = a.agency_id\nWHERE s.category = 'Social Assistance';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date )\nCREATE TABLE transportation.trips ( trip_id text PRIMARY KEY, route_id text, vehicle_id text, driver_id text, scheduled_departure timestamp, actual_departure timestamp, scheduled_arrival timestamp, actual_arrival timestamp, origin_location_id text, destination_location_id text, status text, passenger_count int, cargo_manifest_id text )\nCREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date )\n", "conversations": [{"role": "user", "content": "What is the average maintenance cost per service_type for maintenance performed in 2023?"}, {"role": "assistant", "content": "SELECT service_type, AVG(cost) AS avg_cost\nFROM transportation.maintenance_logs\nWHERE service_date BETWEEN '2023-01-01' AND '2023-12-31'\nGROUP BY service_type;"}, {"role": "user", "content": "Now include only those service types where the average cost exceeds 500 and sort by avg_cost desc."}, {"role": "assistant", "content": "SELECT service_type, AVG(cost) AS avg_cost\nFROM transportation.maintenance_logs\nWHERE service_date BETWEEN '2023-01-01' AND '2023-12-31'\nGROUP BY service_type\nHAVING AVG(cost) > 500\nORDER BY avg_cost DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens (\n citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen\n national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n date_of_birth date NOT NULL,\n gender character varying(20),\n primary_address text NOT NULL, -- full primary residential address\n contact_email character varying(128) UNIQUE,\n contact_phone character varying(32),\n registration_date timestamp NOT NULL, -- when the citizen profile was created\n is_verified boolean DEFAULT false, -- whether identity has been officially verified\n PRIMARY KEY (citizen_id)\n)\nCREATE TABLE government_services.agencies ( agency_id.text, agency_name.text, jurisdiction_level.text, primary_contact_email.text, main_phone_number.text, website_url.text, established_date.date, parent_agency_id.text )\nCREATE TABLE government_services.services ( service_id text 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 )\nCREATE TABLE government_services.documents ( document_id.text, application_id.text, citizen_id.text, document_type.text, file_reference.text, upload_timestamp.timestamp, expiry_date.date, verification_status.text, verified_by_employee_id.text, verification_timestamp.timestamp )\nCREATE TABLE government_services.payments ( payment_id text, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.service_locations (\n location_id character varying(64) NOT NULL, -- unique identifier for the physical location\n agency_id character varying(64) NOT NULL, -- FK to agencies table\n location_name character varying(200), -- e.g., Downtown DMV Office\n address text NOT NULL,\n city character varying(100),\n state character varying(50),\n postal_code character varying(20),\n latitude numeric(9, 6),\n longitude numeric(9, 6),\n operating_hours text, -- description of opening times\n contact_phone character varying(32),\n is_accessible boolean, -- accessibility information (e.g., wheelchair access)\n PRIMARY KEY (location_id)\n)\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "List the first name and last name of citizens who have scheduled appointments, along with the scheduled start time and purpose of their appointments."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.scheduled_start_time, T2.purpose FROM government_services.citizens AS T1 JOIN government_services.appointments AS T2 ON T1.citizen_id = T2.citizen_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id text PRIMARY KEY, user_id text, post_id text, comment_id text, created_at timestamp )\nCREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id text, post_id text, hashtag_id text )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, recipient_user_id character varying(64) NOT NULL, sender_user_id character varying(64), notification_type character varying(30) NOT NULL, target_entity_id character varying(64), target_entity_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (notification_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "List all hashtags and for each, show how many different users have created posts using that hashtag."}, {"role": "assistant", "content": "SELECT ph.hashtag_id, COUNT(DISTINCT p.user_id) AS unique_user_count\nFROM social_media.post_hashtags ph\nJOIN social_media.posts p ON ph.post_id = p.post_id\nGROUP BY ph.hashtag_id;"}, {"role": "user", "content": "Only include hashtags used by at least 3 users."}, {"role": "assistant", "content": "SELECT ph.hashtag_id, COUNT(DISTINCT p.user_id) AS unique_user_count\nFROM social_media.post_hashtags ph\nJOIN social_media.posts p ON ph.post_id = p.post_id\nGROUP BY ph.hashtag_id\nHAVING COUNT(DISTINCT p.user_id) >= 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.properties (\n property_id character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.)\n property_name character varying(255) NOT NULL, -- name of the property\n address_line1 character varying(255) NOT NULL, -- primary address line\n address_line2 character varying(255), -- secondary address line\n city character varying(100) NOT NULL, -- city\n state_province character varying(100), -- state or province\n postal_code character varying(20) NOT NULL, -- zip or postal code\n country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN)\n phone_number character varying(30), -- main contact phone\n email_address character varying(255), -- main contact email\n property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel\n star_rating numeric(2,1), -- star rating (e.g., 4.5)\n timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York)\n manager_staff_id character varying(64), -- FK to staff table for the general manager\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (property_id)\n)\nCREATE TABLE hospitality_technology.rooms ( room_id.text, property_id.text, room_number.text, room_type_id.text, floor.integer, status.text, is_smoking.boolean, features.text, current_condition.text, last_cleaned_at.timestamp )\nCREATE TABLE hospitality_technology.room_types ( room_type_id text PRIMARY KEY, property_id text, type_name text, description text, base_rate numeric, max_occupancy int, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.services ( service_id.text, property_id.text, service_name.text, description.text, category.text, price.numeric, unit.text, is_available.boolean, department.text )\nCREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )\n", "conversations": [{"role": "user", "content": "List all properties that have at least one room with 'Ocean View' in its features, showing the property name and the total count of such rooms."}, {"role": "assistant", "content": "SELECT T1.property_name, COUNT(T2.room_id) FROM hospitality_technology.properties AS T1 JOIN hospitality_technology.rooms AS T2 ON T1.property_id = T2.property_id WHERE T2.features LIKE '%Ocean View%' GROUP BY T1.property_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients (\n client_id character varying(64) NOT NULL, -- unique identifier for the client\n first_name character varying(100) NOT NULL, -- client's first name\n last_name character varying(100) NOT NULL, -- client's last name\n company_name character varying(200), -- company name if applicable\n email character varying(128) UNIQUE NOT NULL, -- client's primary email\n phone character varying(32), -- client's contact phone number\n address text, -- client's full address\n date_registered timestamp NOT NULL, -- when the client was first registered\n status character varying(32) NOT NULL, -- client status (e.g., active, inactive, prospect)\n PRIMARY KEY (client_id)\n)\nCREATE TABLE legal_services.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text )\nCREATE TABLE legal_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document\n case_id character varying(64) NOT NULL, -- FK to cases table\n document_name character varying(255) NOT NULL, -- name of the document file\n document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence\n storage_path text NOT NULL, -- path or reference to the document storage location\n uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it)\n upload_timestamp timestamp NOT NULL, -- time the document was uploaded\n version integer DEFAULT 1, -- document version number\n description text, -- brief description or notes about the document\n PRIMARY KEY (document_id)\n)\nCREATE TABLE legal_services.time_entries ( entry_id.text, case_id.text, lawyer_id.text, date_worked.date, hours_spent.numeric, billing_rate.numeric, description.text, is_billable.boolean, is_billed.boolean, invoice_id.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the total number of time entries marked as billable in the system."}, {"role": "assistant", "content": "SELECT COUNT(*) AS total_billable_time_entries\nFROM legal_services.time_entries\nWHERE is_billable = TRUE;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\n", "conversations": [{"role": "user", "content": "List the first name, last name, and email of all customers who live in New York or California."}, {"role": "assistant", "content": "SELECT first_name, last_name, email FROM insurance.customers WHERE state IN ('NY', 'CA');"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.trades (\n trade_id character varying(64) NOT NULL, -- unique identifier for the trade\n account_id character varying(64) NOT NULL, -- investment account executing the trade\n security_id character varying(64) NOT NULL, -- security being traded\n order_id character varying(64), -- related order ID if applicable\n trade_type character varying(10) NOT NULL, -- 'Buy' or 'Sell'\n quantity numeric(19, 8) NOT NULL, -- number of units traded\n price_per_unit numeric(19, 8) NOT NULL, -- price per unit of the security\n total_amount numeric(19, 4) NOT NULL, -- total value of the trade (quantity * price)\n commission numeric(10, 4), -- commission fee charged for the trade\n trade_timestamp timestamp NOT NULL, -- exact time the trade was executed\n settlement_date date, -- date the trade settles\n status character varying(32) NOT NULL, -- e.g., Executed, Settled, Cancelled\n execution_venue character varying(100), -- where the trade was executed\n PRIMARY KEY (trade_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id),\n FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all trades for account 'ACC654321' executed after January 1, 2024."}, {"role": "assistant", "content": "SELECT *\nFROM financial_services.trades\nWHERE account_id = 'ACC654321' AND trade_timestamp > '2024-01-01';"}, {"role": "user", "content": "Actually, I only want the buy trades."}, {"role": "assistant", "content": "SELECT *\nFROM financial_services.trades\nWHERE account_id = 'ACC654321' AND trade_timestamp > '2024-01-01' AND trade_type = 'Buy';"}, {"role": "user", "content": "Include the security names in the result."}, {"role": "assistant", "content": "SELECT t.*, s.security_name\nFROM financial_services.trades t\nJOIN financial_services.securities s ON t.security_id = s.security_id\nWHERE t.account_id = 'ACC654321' AND t.trade_timestamp > '2024-01-01' AND t.trade_type = 'Buy';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\n", "conversations": [{"role": "user", "content": "List all rooms, showing their room number, type name, and the name of the property they are in."}, {"role": "assistant", "content": "SELECT T1.room_number, T2.type_name, T3.property_name FROM hospitality_technology.rooms AS T1 JOIN hospitality_technology.room_types AS T2 ON T1.room_type_id = T2.room_type_id JOIN hospitality_technology.properties AS T3 ON T1.property_id = T3.property_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims ( claim_id text, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "List all claim documents where the file name contains 'invoice' (case insensitive), showing the document ID, claim ID, file name, and uploaded_at."}, {"role": "assistant", "content": "SELECT document_id, claim_id, file_name, uploaded_at\nFROM insurance.claim_documents\nWHERE LOWER(file_name) LIKE '%invoice%';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_read_at timestamp, PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) )\n", "conversations": [{"role": "user", "content": "List the usernames and the IDs of conversations they have joined."}, {"role": "assistant", "content": "SELECT T1.username, T2.conversation_id FROM social_media.users AS T1 JOIN social_media.conversation_participants AS T2 ON T1.user_id = T2.user_id;"}, {"role": "user", "content": "Can you filter this to only show users who joined after '2024-06-15'?"}, {"role": "assistant", "content": "SELECT T1.username, T2.conversation_id FROM social_media.users AS T1 JOIN social_media.conversation_participants AS T2 ON T1.user_id = T2.user_id WHERE T2.joined_at > '2024-06-15';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text PRIMARY KEY, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "List the policy ID, beneficiary first name, beneficiary last name, relationship, and the product name for all policy beneficiaries."}, {"role": "assistant", "content": "SELECT T1.policy_id, T1.first_name, T1.last_name, T1.relationship, T2.product_name FROM insurance.policy_beneficiaries AS T1 JOIN insurance.insurance_products AS T2 ON T1.policy_id = T2.product_id;"}, {"role": "user", "content": "Only include beneficiaries with a percentage share greater than 5% and products that are active."}, {"role": "assistant", "content": "SELECT T1.policy_id, T1.first_name, T1.last_name, T1.relationship, T2.product_name FROM insurance.policy_beneficiaries AS T1 JOIN insurance.insurance_products AS T2 ON T1.policy_id = T2.product_id WHERE T1.percentage_share > 5 AND T2.is_active = TRUE;"}, {"role": "user", "content": "From those results, just show the policy ID, the product name, and the count of beneficiaries for each policy."}, {"role": "assistant", "content": "SELECT T1.policy_id, T2.product_name, COUNT(T1.beneficiary_id) AS beneficiary_count FROM insurance.policy_beneficiaries AS T1 JOIN insurance.insurance_products AS T2 ON T1.policy_id = T2.product_id WHERE T1.percentage_share > 5 AND T2.is_active = TRUE GROUP BY T1.policy_id, T2.product_name;"}, {"role": "user", "content": "Order these results by the beneficiary count in descending order and limit to the top 10."}, {"role": "assistant", "content": "SELECT T1.policy_id, T2.product_name, COUNT(T1.beneficiary_id) AS beneficiary_count FROM insurance.policy_beneficiaries AS T1 JOIN insurance.insurance_products AS T2 ON T1.policy_id = T2.product_id WHERE T1.percentage_share > 5 AND T2.is_active = TRUE GROUP BY T1.policy_id, T2.product_name ORDER BY beneficiary_count DESC LIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE blockchain.addresses ( address_id character varying(128) NOT NULL, public_key text NOT NULL, balance numeric(38,14) NOT NULL, PRIMARY KEY (address_id) )\n", "conversations": [{"role": "user", "content": "List all address IDs and their corresponding public keys from the addresses table."}, {"role": "assistant", "content": "SELECT address_id, public_key FROM blockchain.addresses;"}, {"role": "user", "content": "Now, filter these results to only include addresses where the balance is greater than 5000."}, {"role": "assistant", "content": "SELECT address_id, public_key, balance FROM blockchain.addresses WHERE balance > 5000;"}, {"role": "user", "content": "Can you tell me how many addresses satisfy this condition?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM blockchain.addresses WHERE balance > 5000;"}, {"role": "user", "content": "What is the average balance for these addresses that have a balance greater than 5000?"}, {"role": "assistant", "content": "SELECT AVG(balance) FROM blockchain.addresses WHERE balance > 5000;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\nCREATE TABLE financial_services.transactions ( transaction_id text, account_id text, related_account_id text, transaction_type text, amount numeric, currency text, transaction_date timestamp, effective_date date, description text, status text, reference_number text )\nCREATE TABLE financial_services.securities ( security_id.text, ticker_symbol.text, isin_code.text, cusip_code.text, security_name.text, security_type.text, exchange.text, currency.text, issuer_name.text, sector.text, last_updated.timestamp )\nCREATE TABLE financial_services.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )\nCREATE TABLE financial_services.employees (\n employee_id character varying(64) NOT NULL, -- unique identifier for the employee\n first_name character varying(100) NOT NULL,\n last_name character varying(100) NOT NULL,\n job_title character varying(100) NOT NULL, -- e.g., Teller, Branch Manager, Financial Advisor, Analyst\n department character varying(100), -- e.g., Retail Banking, Wealth Management, IT\n branch_id character varying(64), -- Identifier for the branch they work at (if applicable)\n email character varying(128) NOT NULL UNIQUE,\n phone_extension character varying(20),\n hire_date date NOT NULL,\n termination_date date, -- Date of termination, null if currently employed\n manager_id character varying(64), -- Self-referencing key for manager relationship\n status character varying(32) NOT NULL, -- e.g., Active, Terminated, On Leave\n PRIMARY KEY (employee_id),\n FOREIGN KEY (branch_id) REFERENCES financial_services.branches(branch_id), -- Assuming a branches table exists\n FOREIGN KEY (manager_id) REFERENCES financial_services.employees(employee_id)\n)\n", "conversations": [{"role": "user", "content": "Show all transactions over 10,000 USD that are not marked as 'REVERSED'."}, {"role": "assistant", "content": "SELECT transaction_id, account_id, amount, currency, status, transaction_date\nFROM financial_services.transactions\nWHERE amount > 10000 AND currency = 'USD' AND status != 'REVERSED';"}, {"role": "user", "content": "Include the related_account_id and the transaction_type in the result, and order by amount descending."}, {"role": "assistant", "content": "SELECT transaction_id, account_id, related_account_id, transaction_type, amount, currency, status, transaction_date\nFROM financial_services.transactions\nWHERE amount > 10000 AND currency = 'USD' AND status != 'REVERSED'\nORDER BY amount DESC;"}, {"role": "user", "content": "Add a filter to only include transactions that happened in the last 60 days."}, {"role": "assistant", "content": "SELECT transaction_id, account_id, related_account_id, transaction_type, amount, currency, status, transaction_date\nFROM financial_services.transactions\nWHERE amount > 10000 AND currency = 'USD' AND status != 'REVERSED' AND transaction_date >= NOW() - INTERVAL '60 days'\nORDER BY amount DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.appointments ( appointment_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, appointment_time timestamp with time zone NOT NULL, duration_minutes integer NOT NULL, reason text, status character varying(32) NOT NULL, location_id character varying(64), notes text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (appointment_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.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) )\n", "conversations": [{"role": "user", "content": "Show all prescriptions with prescription_id, patient_id, medication_id, quantity_dispensed, and refills_allowed."}, {"role": "assistant", "content": "SELECT prescription_id, patient_id, medication_id, quantity_dispensed, refills_allowed FROM healthcare.prescriptions;"}, {"role": "user", "content": "Filter this list to include only prescriptions where the quantity dispensed is greater than 20 and refills allowed is 0."}, {"role": "assistant", "content": "SELECT prescription_id, patient_id, medication_id, quantity_dispensed, refills_allowed FROM healthcare.prescriptions WHERE quantity_dispensed > 20 AND refills_allowed = 0;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "Retrieve all pairs of medications that share the same generic_name but have different NDC codes. Show the first medication's ID, name, the second medication's ID, name, and the shared generic_name."}, {"role": "assistant", "content": "SELECT m1.medication_id AS med1_id, m1.medication_name AS med1_name, m2.medication_id AS med2_id, m2.medication_name AS med2_name, m1.generic_name FROM healthcare.medications m1 JOIN healthcare.medications m2 ON m1.generic_name = m2.generic_name AND m1.ndc_code <> m2.ndc_code WHERE m1.medication_id < m2.medication_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.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) )\n", "conversations": [{"role": "user", "content": "How many agents were hired in the current year and what is their average commission rate?"}, {"role": "assistant", "content": "SELECT COUNT(*) AS hired_this_year, AVG(commission_rate) AS average_commission_rate FROM insurance.agents WHERE EXTRACT(YEAR FROM hire_date) = EXTRACT(YEAR FROM CURRENT_DATE);"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.agencies ( agency_id text PRIMARY KEY, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )\nCREATE TABLE government_services.documents ( document_id text PRIMARY KEY, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\n", "conversations": [{"role": "user", "content": "List the appointment ID, the scheduled start time, and the name of the service location for all appointments scheduled between '2024-01-01' and '2024-12-31'."}, {"role": "assistant", "content": "SELECT T1.appointment_id, T1.scheduled_start_time, T2.location_name FROM government_services.appointments AS T1 INNER JOIN government_services.service_locations AS T2 ON T1.location_id = T2.location_id WHERE T1.scheduled_start_time >= '2024-01-01' AND T1.scheduled_start_time < '2025-01-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles (\n vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle\n license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate\n vin character varying(17) UNIQUE, -- vehicle identification number\n make character varying(64) NOT NULL, -- manufacturer of the vehicle\n model character varying(64) NOT NULL, -- model of the vehicle\n year integer NOT NULL, -- manufacturing year\n type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)\n capacity integer, -- passenger or cargo capacity\n fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen\n status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned\n depot_id character varying(64), -- identifier of the home depot/base\n acquisition_date date, -- date the vehicle was acquired\n PRIMARY KEY (vehicle_id)\n)\nCREATE TABLE transportation.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) )\nCREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text )\nCREATE TABLE transportation.trips (\n trip_id character varying(64) NOT NULL, -- unique identifier for a specific trip instance\n route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips)\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used\n driver_id character varying(64) NOT NULL, -- identifier of the driver operating\n scheduled_departure timestamp with time zone NOT NULL, -- planned departure time\n actual_departure timestamp with time zone, -- actual departure time\n scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time\n actual_arrival timestamp with time zone, -- actual arrival time\n origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin)\n destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination)\n status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled\n passenger_count integer, -- number of passengers (if applicable)\n cargo_manifest_id character varying(64), -- link to cargo details (if applicable)\n PRIMARY KEY (trip_id)\n)\nCREATE TABLE transportation.locations ( location_id.text, name.text, type.text, address_line1.text, city.text, state_province.text, postal_code.text, country.text, latitude.numeric, longitude.numeric, timezone.text )\nCREATE TABLE transportation.passengers ( passenger_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )\nCREATE TABLE transportation.bookings (\n booking_id character varying(64) NOT NULL, -- unique identifier for the booking\n passenger_id character varying(64) NOT NULL, -- identifier of the passenger making the booking\n trip_id character varying(64) NOT NULL, -- identifier of the trip being booked\n seat_number character varying(16), -- assigned seat number (if applicable)\n booking_time timestamp with time zone NOT NULL, -- time when the booking was made\n status character varying(32) NOT NULL, -- e.g., Confirmed, Cancelled, Pending Payment\n fare numeric(10, 2) NOT NULL, -- price paid for the booking\n payment_transaction_id character varying(128), -- reference to the payment transaction\n special_requests text, -- any special requests from the passenger\n PRIMARY KEY (booking_id)\n)\n", "conversations": [{"role": "user", "content": "Show me the top 3 vehicles with the highest average passenger count on completed trips, and include each vehicle's license plate, make, and the average passenger count."}, {"role": "assistant", "content": "SELECT v.vehicle_id,\n v.license_plate,\n v.make,\n AVG(t.passenger_count) AS avg_passengers\nFROM transportation.vehicles v\nJOIN transportation.trips t\n ON v.vehicle_id = t.vehicle_id\nWHERE t.status = 'Completed'\nGROUP BY v.vehicle_id, v.license_plate, v.make\nORDER BY avg_passengers DESC\nLIMIT 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\nCREATE TABLE insurance.policies ( policy_id.text, customer_id.text, product_id.text, agent_id.text, policy_number.text, start_date.date, end_date.date, premium_amount.numeric, coverage_limit.numeric, deductible.numeric, status.text, issued_at.timestamp, cancellation_date.date, cancellation_reason.text )\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE insurance.agents ( agent_id.text, first_name.text, last_name.text, agency_name.text, license_number.text, license_state.text, contact_email.text, contact_phone.text, hire_date.date, termination_date.date, status.text, commission_rate.numeric, manager_id.text )\nCREATE TABLE insurance.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 )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id.text, policy_id.text, customer_id.text, first_name.text, last_name.text, relationship.text, percentage_share.numeric, contact_info.text, added_at.timestamp )\n", "conversations": [{"role": "user", "content": "List the policy number, start date, product name, and base premium for policies where the base premium of the associated product is greater than 1000."}, {"role": "assistant", "content": "SELECT T1.policy_number, T1.start_date, T2.product_name, T2.base_premium FROM insurance.policies AS T1 JOIN insurance.insurance_products AS T2 ON T1.product_id = T2.product_id WHERE T2.base_premium > 1000;"}]} +{"system": "You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE manufacturing.employees ( employee_id.text, first_name.text, last_name.text, job_title.text, skill_certifications.text, hire_date.date, assigned_line_id.text, employment_status.text, supervisor_employee_id.text )\n", "conversations": [{"role": "user", "content": "What is the current address of the employee with ID 'EMP234'?"}, {"role": "assistant", "content": "I'm sorry, but I can't provide the current address of an employee as this information is not stored in the database table."}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\n", "conversations": [{"role": "user", "content": "Find all customers whose email address ends with '@gmail.com'. Please show the customer_id, first name, and email."}, {"role": "assistant", "content": "SELECT customer_id, first_name, email FROM insurance.customers WHERE email LIKE '%@gmail.com';"}, {"role": "user", "content": "Also, restrict this to only customers who are currently 'inactive'."}, {"role": "assistant", "content": "SELECT customer_id, first_name, email FROM insurance.customers WHERE email LIKE '%@gmail.com' AND status = 'inactive';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id character varying(64) NOT NULL, national_id_number character varying(128) NOT NULL UNIQUE, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(20), primary_address text NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(32), registration_date timestamp NOT NULL, is_verified boolean DEFAULT false, PRIMARY KEY (citizen_id) )\nCREATE TABLE government_services.agencies ( agency_id character varying(64) NOT NULL, agency_name character varying(255) NOT NULL, jurisdiction_level character varying(50) NOT NULL, primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), PRIMARY KEY (agency_id) )\nCREATE TABLE government_services.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_id) )\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.payments ( payment_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, service_id character varying(64), amount numeric(12, 2) NOT NULL, currency character varying(3) NOT NULL DEFAULT 'USD', payment_method character varying(50), payment_provider_reference character varying(128), payment_timestamp timestamp NOT NULL, status character varying(30) NOT NULL, notes text, PRIMARY KEY (payment_id) )\nCREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\nCREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, employee_id character varying(64), location_id character varying(64), service_id character varying(64), scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, status character varying(30) NOT NULL, booking_method character varying(50), created_at timestamp NOT NULL, notes text, PRIMARY KEY (appointment_id) )\nCREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )\n", "conversations": [{"role": "user", "content": "How many employees are currently not terminated?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM government_services.employees WHERE termination_date IS NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.locations ( location_id.text, name.text, type.text, address_line1.text, city.text, state_province.text, postal_code.text, country.text, latitude.numeric, longitude.numeric, timezone.text )\nCREATE TABLE transportation.bookings ( booking_id.text, passenger_id.text, trip_id.text, seat_number.text, booking_time.timestamp, status.text, fare.numeric, payment_transaction_id.text, special_requests.text )\n", "conversations": [{"role": "user", "content": "Show me the booking ID, fare, and the city of the destination location for all bookings with 'Confirmed' status."}, {"role": "assistant", "content": "SELECT b.booking_id, b.fare, dl.city AS destination_city FROM transportation.bookings AS b JOIN transportation.trips AS t ON b.trip_id = t.trip_id JOIN transportation.locations AS dl ON t.destination_location_id = dl.location_id WHERE b.status = 'Confirmed';"}, {"role": "user", "content": "Instead of 'Confirmed', list 'Completed' bookings from locations in 'California', and order by fare descending."}, {"role": "assistant", "content": "SELECT b.booking_id, b.fare, dl.city AS destination_city FROM transportation.bookings AS b JOIN transportation.trips AS t ON b.trip_id = t.trip_id JOIN transportation.locations AS dl ON t.destination_location_id = dl.location_id WHERE b.status = 'Completed' AND dl.state_province = 'CA' ORDER BY b.fare DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\nCREATE TABLE financial_services.accounts ( account_id text, customer_id text, account_number text, account_type text, balance numeric, currency text, opened_date date, status text, interest_rate numeric, last_updated_at timestamp )\nCREATE TABLE financial_services.transactions (\n transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction\n account_id character varying(64) NOT NULL, -- account involved in the transaction\n related_account_id character varying(64), -- counterpart account for transfers\n transaction_type character varying(50) NOT NULL, -- e.g., Deposit, Withdrawal, Transfer, Payment, Fee, Interest\n amount numeric(19, 4) NOT NULL, -- transaction amount\n currency character varying(3) NOT NULL, -- transaction currency\n transaction_date timestamp NOT NULL, -- exact time of the transaction\n effective_date date NOT NULL, -- date the transaction affects the balance\n description text, -- description or memo of the transaction\n status character varying(32) NOT NULL, -- e.g., Pending, Completed, Failed, Reversed\n reference_number character varying(128), -- external reference if applicable (e.g., check number)\n PRIMARY KEY (transaction_id),\n FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id),\n FOREIGN KEY (related_account_id) REFERENCES financial_services.accounts(account_id)\n)\nCREATE TABLE financial_services.trades ( trade_id text PRIMARY KEY, account_id text, security_id text, order_id text, trade_type text, quantity numeric, price_per_unit numeric, total_amount numeric, commission numeric, trade_timestamp timestamp, settlement_date date, status text, execution_venue text )\nCREATE TABLE financial_services.market_data ( data_point_id.bigint, security_id.text, data_timestamp.timestamp, open_price.numeric, high_price.numeric, low_price.numeric, close_price.numeric, adjusted_close_price.numeric, volume.bigint, source.text )\nCREATE TABLE financial_services.loans ( loan_id character varying(64) NOT NULL, account_id character varying(64) NOT NULL UNIQUE, loan_type character varying(50) NOT NULL, principal_amount numeric(19, 4) NOT NULL, current_principal_balance numeric(19, 4) NOT NULL, interest_rate numeric(6, 4) NOT NULL, term_months integer NOT NULL, origination_date date NOT NULL, maturity_date date NOT NULL, monthly_payment numeric(12, 4), collateral_description text, status character varying(32) NOT NULL, PRIMARY KEY (loan_id), FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id) )\n", "conversations": [{"role": "user", "content": "I\u2019d like to see, for each customer, the total balance of their accounts by currency."}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_name,\n a.currency,\n SUM(a.balance) AS total_balance\nFROM financial_services.customers c\nJOIN financial_services.accounts a\n ON c.customer_id = a.customer_id\nGROUP BY c.customer_id, customer_name, a.currency;"}, {"role": "user", "content": "Actually, include only customers who were created in the current calendar year."}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_name,\n a.currency,\n SUM(a.balance) AS total_balance\nFROM financial_services.customers c\nJOIN financial_services.accounts a\n ON c.customer_id = a.customer_id\nWHERE c.created_at >= date_trunc('year', CURRENT_DATE)\nGROUP BY c.customer_id, customer_name, a.currency;"}, {"role": "user", "content": "Also exclude any customers who don\u2019t have a phone number on file."}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_name,\n a.currency,\n SUM(a.balance) AS total_balance\nFROM financial_services.customers c\nJOIN financial_services.accounts a\n ON c.customer_id = a.customer_id\nWHERE c.created_at >= date_trunc('year', CURRENT_DATE)\n AND c.phone_number IS NOT NULL\nGROUP BY c.customer_id, customer_name, a.currency;"}, {"role": "user", "content": "Finally, only show currencies where the total_balance exceeds 10000 and order by total_balance descending."}, {"role": "assistant", "content": "SELECT c.customer_id,\n c.first_name || ' ' || c.last_name AS customer_name,\n a.currency,\n SUM(a.balance) AS total_balance\nFROM financial_services.customers c\nJOIN financial_services.accounts a\n ON c.customer_id = a.customer_id\nWHERE c.created_at >= date_trunc('year', CURRENT_DATE)\n AND c.phone_number IS NOT NULL\nGROUP BY c.customer_id, customer_name, a.currency\nHAVING SUM(a.balance) > 10000\nORDER BY total_balance DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE blockchain.blocks ( block_id text, previous_block_id text, timestamp timestamp, nonce integer, merkle_root text, difficulty integer )\nCREATE TABLE blockchain.transactions ( transaction_id text, block_id text, sender_address text, receiver_address text, amount numeric, timestamp timestamp, signature text )\nCREATE TABLE blockchain.addresses ( address_id text, public_key text, balance numeric )\nCREATE TABLE blockchain.wallets ( wallet_id text, user_id text, address_id text, private_key text )\n", "conversations": [{"role": "user", "content": "List the block_id, timestamp, and the total amount of transactions for each block, along with the sender and receiver addresses for each transaction that occurred on April 10th, 2023."}, {"role": "assistant", "content": "SELECT b.block_id, b.timestamp, t.sender_address, t.receiver_address, SUM(t.amount) as total_amount_in_block\nFROM blockchain.blocks b\nJOIN blockchain.transactions t ON b.block_id = t.block_id\nWHERE DATE(t.timestamp) = '2023-04-10'\nGROUP BY b.block_id, b.timestamp, t.sender_address, t.receiver_address;"}, {"role": "user", "content": "Can you also include the balance of both sender and receiver addresses at the time of the transaction?"}, {"role": "assistant", "content": "SELECT b.block_id, b.timestamp, t.sender_address, sa.balance AS sender_balance, t.receiver_address, ra.balance AS receiver_balance, SUM(t.amount) as total_amount_in_block\nFROM blockchain.blocks b\nJOIN blockchain.transactions t ON b.block_id = t.block_id\nLEFT JOIN blockchain.addresses sa ON t.sender_address = sa.address_id\nLEFT JOIN blockchain.addresses ra ON t.receiver_address = ra.address_id\nWHERE DATE(t.timestamp) = '2023-04-10'\nGROUP BY b.block_id, b.timestamp, t.sender_address, sa.balance, t.receiver_address, ra.balance;"}, {"role": "user", "content": "Now only show those transactions where the sender's balance was greater than 5000 at that time."}, {"role": "assistant", "content": "SELECT b.block_id, b.timestamp, t.sender_address, sa.balance AS sender_balance, t.receiver_address, ra.balance AS receiver_balance, SUM(t.amount) as total_amount_in_block\nFROM blockchain.blocks b\nJOIN blockchain.transactions t ON b.block_id = t.block_id\nLEFT JOIN blockchain.addresses sa ON t.sender_address = sa.address_id\nLEFT JOIN blockchain.addresses ra ON t.receiver_address = ra.address_id\nWHERE DATE(t.timestamp) = '2023-04-10' AND sa.balance > 5000\nGROUP BY b.block_id, b.timestamp, t.sender_address, sa.balance, t.receiver_address, ra.balance;"}, {"role": "user", "content": "Sorry, the sender_address seems incorrect. Use sender_address from transactions table instead of addresses."}, {"role": "assistant", "content": "SELECT b.block_id, b.timestamp, t.sender_address, sa.balance AS sender_balance, t.receiver_address, ra.balance AS receiver_balance, SUM(t.amount) as total_amount_in_block\nFROM blockchain.blocks b\nJOIN blockchain.transactions t ON b.block_id = t.block_id\nLEFT JOIN blockchain.addresses sa ON t.sender_address = sa.address_id\nLEFT JOIN blockchain.addresses ra ON t.receiver_address = ra.address_id\nWHERE DATE(t.timestamp) = '2023-04-10' AND sa.balance > 5000\nGROUP BY b.block_id, b.timestamp, t.sender_address, sa.balance, t.receiver_address, ra.balance;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.fuel_logs (\n fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled\n trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred\n log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred\n fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type)\n quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh)\n unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh)\n cost_per_unit numeric(8, 4), -- price per unit of fuel\n total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase\n odometer_reading integer, -- vehicle mileage at time of fueling\n location_id character varying(64), -- identifier of the fueling station/location\n PRIMARY KEY (fuel_log_id)\n)\n", "conversations": [{"role": "user", "content": "I need the total fuel cost per vehicle for each fuel type."}, {"role": "assistant", "content": "SELECT vehicle_id, fuel_type, SUM(total_cost) AS total_cost_per_type\nFROM transportation.fuel_logs\nGROUP BY vehicle_id, fuel_type;"}, {"role": "user", "content": "Filter this to only include records where the cost_per_unit is greater than 1.50."}, {"role": "assistant", "content": "SELECT vehicle_id, fuel_type, SUM(total_cost) AS total_cost_per_type\nFROM transportation.fuel_logs\nWHERE cost_per_unit > 1.50\nGROUP BY vehicle_id, fuel_type;"}, {"role": "user", "content": "Also, sort the result by the total cost in descending order."}, {"role": "assistant", "content": "SELECT vehicle_id, fuel_type, SUM(total_cost) AS total_cost_per_type\nFROM transportation.fuel_logs\nWHERE cost_per_unit > 1.50\nGROUP BY vehicle_id, fuel_type\nORDER BY total_cost_per_type DESC;"}, {"role": "user", "content": "Finally, limit the output to the top 5 entries."}, {"role": "assistant", "content": "SELECT vehicle_id, fuel_type, SUM(total_cost) AS total_cost_per_type\nFROM transportation.fuel_logs\nWHERE cost_per_unit > 1.50\nGROUP BY vehicle_id, fuel_type\nORDER BY total_cost_per_type DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean )\nCREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )\nCREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )\nCREATE TABLE social_media.post_hashtags ( post_hashtag_id.text, post_id.text, hashtag_id.text )\nCREATE TABLE social_media.messages ( message_id.text, conversation_id.text, sender_user_id.text, content.text, media_url.text, media_type.text, sent_at.timestamp, read_at.timestamp )\nCREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text )\nCREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp )\nCREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )\n", "conversations": [{"role": "user", "content": "For each group conversation, I need its ID, name, and the count of participants whose last_read_at is earlier than the conversation's last_message_at (i.e., participants with unread messages)."}, {"role": "assistant", "content": "SELECT\n c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS unread_participants\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp\n ON c.conversation_id = cp.conversation_id\nWHERE c.is_group_chat = TRUE\n AND (cp.last_read_at < c.last_message_at OR cp.last_read_at IS NULL)\nGROUP BY c.conversation_id, c.group_name;"}, {"role": "user", "content": "Actually, only include group conversations where the unread participant count is greater than 5."}, {"role": "assistant", "content": "SELECT\n c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS unread_participants\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp\n ON c.conversation_id = cp.conversation_id\nWHERE c.is_group_chat = TRUE\n AND (cp.last_read_at < c.last_message_at OR cp.last_read_at IS NULL)\nGROUP BY c.conversation_id, c.group_name\nHAVING COUNT(cp.participant_id) > 5;"}, {"role": "user", "content": "Also, sort the results by unread_participants descending."}, {"role": "assistant", "content": "SELECT\n c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS unread_participants\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp\n ON c.conversation_id = cp.conversation_id\nWHERE c.is_group_chat = TRUE\n AND (cp.last_read_at < c.last_message_at OR cp.last_read_at IS NULL)\nGROUP BY c.conversation_id, c.group_name\nHAVING COUNT(cp.participant_id) > 5\nORDER BY unread_participants DESC;"}, {"role": "user", "content": "Finally, limit the output to the top 10 conversations."}, {"role": "assistant", "content": "SELECT\n c.conversation_id,\n c.group_name,\n COUNT(cp.participant_id) AS unread_participants\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp\n ON c.conversation_id = cp.conversation_id\nWHERE c.is_group_chat = TRUE\n AND (cp.last_read_at < c.last_message_at OR cp.last_read_at IS NULL)\nGROUP BY c.conversation_id, c.group_name\nHAVING COUNT(cp.participant_id) > 5\nORDER BY unread_participants DESC\nLIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, ssn_hash character varying(128), address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state character varying(50) NOT NULL, zip_code character varying(20) NOT NULL, country character varying(50) NOT NULL DEFAULT 'USA', phone_number character varying(30), email character varying(128) UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, status character varying(20) NOT NULL DEFAULT 'Active', PRIMARY KEY (customer_id) )\nCREATE TABLE insurance.policies ( policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, product_id character varying(64) NOT NULL, agent_id character varying(64), policy_number character varying(100) NOT NULL UNIQUE, start_date date NOT NULL, end_date date NOT NULL, premium_amount numeric(12, 2) NOT NULL, coverage_limit numeric(15, 2) NOT NULL, deductible numeric(10, 2) NOT NULL, status character varying(30) NOT NULL, issued_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, cancellation_date date, cancellation_reason text, PRIMARY KEY (policy_id) )\nCREATE TABLE insurance.claims ( claim_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, incident_date timestamp NOT NULL, reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text NOT NULL, estimated_loss numeric(15, 2), status character varying(30) NOT NULL, settlement_amount numeric(15, 2), settlement_date date, claim_handler_id character varying(64), police_report_number character varying(100), PRIMARY KEY (claim_id) )\nCREATE TABLE insurance.insurance_products ( product_id character varying(64) NOT NULL, product_name character varying(150) NOT NULL, product_type character varying(50) NOT NULL, description text, base_premium numeric(10, 2) NOT NULL, coverage_details text, underwriting_rules text, is_active boolean NOT NULL DEFAULT true, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp, PRIMARY KEY (product_id) )\nCREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, amount_paid numeric(12, 2) NOT NULL, payment_method character varying(50), transaction_reference character varying(128) UNIQUE, due_date date, payment_period_start date, payment_period_end date, status character varying(30) NOT NULL DEFAULT 'Completed', PRIMARY KEY (payment_id) )\nCREATE TABLE insurance.claim_documents ( document_id character varying(64) NOT NULL, claim_id character varying(64) NOT NULL, document_type character varying(50) NOT NULL, file_name character varying(255) NOT NULL, file_path character varying(512) NOT NULL, file_size_bytes integer, mime_type character varying(100), uploaded_by character varying(64), uploaded_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text, PRIMARY KEY (document_id) )\n", "conversations": [{"role": "user", "content": "Count the number of premium payments that have a null payment method."}, {"role": "assistant", "content": "SELECT COUNT(*) AS null_payment_method_count\nFROM insurance.premium_payments\nWHERE payment_method IS NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims (\n claim_id character varying(64) NOT NULL, -- unique identifier for the claim\n policy_id character varying(64) NOT NULL, -- identifier of the policy under which the claim is made (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the customer making the claim (FK to customers)\n incident_date timestamp NOT NULL, -- date and time of the incident leading to the claim\n reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the claim was reported\n description text NOT NULL, -- detailed description of the incident and claim\n estimated_loss numeric(15, 2), -- initial estimated cost of the loss\n status character varying(30) NOT NULL, -- e.g., Filed, Processing, Under Review, Approved, Denied, Settled\n settlement_amount numeric(15, 2), -- final amount paid out\n settlement_date date,\n claim_handler_id character varying(64), -- identifier for the employee handling the claim (FK to employees/adjusters)\n police_report_number character varying(100),\n PRIMARY KEY (claim_id)\n)\nCREATE TABLE insurance.policy_beneficiaries (\n beneficiary_id character varying(64) NOT NULL, -- unique identifier for the beneficiary entry\n policy_id character varying(64) NOT NULL, -- identifier of the life/relevant policy (FK to policies)\n customer_id character varying(64) NOT NULL, -- identifier of the beneficiary (could be FK to customers or store info directly)\n first_name character varying(100) NOT NULL, -- beneficiary first name (if not linking to customers table)\n last_name character varying(100) NOT NULL, -- beneficiary last name\n relationship character varying(50) NOT NULL, -- relationship to the policyholder (e.g., Spouse, Child, Parent)\n percentage_share numeric(5, 2) NOT NULL CHECK (percentage_share > 0 AND percentage_share <= 100), -- percentage of payout\n contact_info text, -- contact details for the beneficiary\n added_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (beneficiary_id),\n UNIQUE (policy_id, customer_id) -- Ensure a person is listed only once per policy\n)\n", "conversations": [{"role": "user", "content": "What is the average estimated_loss for each claim status?"}, {"role": "assistant", "content": "SELECT status, AVG(estimated_loss) AS avg_estimated_loss\nFROM insurance.claims\nGROUP BY status;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\nCREATE TABLE financial_services.securities ( security_id text, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )\nCREATE TABLE financial_services.loans ( loan_id text, account_id text, loan_type text, principal_amount numeric, current_principal_balance numeric, interest_rate numeric, term_months integer, origination_date date, maturity_date date, monthly_payment numeric, collateral_description text, status text )\n", "conversations": [{"role": "user", "content": "List all securities (security_id, ticker_symbol, security_name) that are traded on the NASDAQ exchange (exchange = 'NASDAQ') and belong to the 'Technology' sector."}, {"role": "assistant", "content": "SELECT security_id, ticker_symbol, security_name FROM financial_services.securities WHERE exchange = 'NASDAQ' AND sector = 'Technology';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.room_types ( room_type_id text PRIMARY KEY, property_id text, type_name text, description text, base_rate numeric, max_occupancy int, bed_type text, area_sqft numeric, amenities text )\n", "conversations": [{"role": "user", "content": "Which bed types are offered in each property and how many different room types are associated with each bed type?"}, {"role": "assistant", "content": "SELECT property_id, bed_type, COUNT(DISTINCT room_type_id) AS room_type_count FROM hospitality_technology.room_types GROUP BY property_id, bed_type;"}, {"role": "user", "content": "Now, show only bed types that are available for at least 3 different room types within the same property."}, {"role": "assistant", "content": "SELECT property_id, bed_type, COUNT(DISTINCT room_type_id) AS room_type_count FROM hospitality_technology.room_types GROUP BY property_id, bed_type HAVING COUNT(DISTINCT room_type_id) >= 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE project_fundraising_record ( id.text, project_id.text, project_name.text, rounds_name.text, investment_value.numeric, investment_date.text, introduction.text, valuation.numeric )\nCREATE TABLE token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )\nCREATE TABLE narrative_info ( narrative.text, top_3_coins.text, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, market_cap.numeric, volume_24h.numeric, trend_rank.numeric, token_num.numeric )\nCREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )\nCREATE TABLE smart_money_profit ( address.text, rank.numeric, profit.numeric, roi.numeric, realized_ratio.numeric, most_profit_token.text, last_trade_time.text, chain.text )\nCREATE TABLE smart_money_token_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, chain.text )\nCREATE TABLE smart_money_token_inflow ( token_address.text, token_symbol.text, token_amount.numeric, usd_value.numeric, avg_price.numeric, type.numeric, address_amount.numeric, narrative.text, chain.text )\n", "conversations": [{"role": "user", "content": "For each token listed in token_dexpool_info, can you show the total net_flow and average ROI from smart_money_token_performance, along with the token's symbol and chain?"}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, SUM(sm.net_flow) AS total_net_flow, AVG(sm.roi) AS average_roi\nFROM token_dexpool_info tdi\nJOIN smart_money_token_performance sm\n ON tdi.token_symbol = sm.token_symbol AND tdi.chain = sm.chain\nGROUP BY tdi.token_symbol, tdi.chain;"}, {"role": "user", "content": "I'd like to see only those tokens where the average ROI is greater than 0.5 and the total net_flow is above 10,000. Can you update the query for me?"}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, SUM(sm.net_flow) AS total_net_flow, AVG(sm.roi) AS average_roi\nFROM token_dexpool_info tdi\nJOIN smart_money_token_performance sm\n ON tdi.token_symbol = sm.token_symbol AND tdi.chain = sm.chain\nGROUP BY tdi.token_symbol, tdi.chain\nHAVING AVG(sm.roi) > 0.5 AND SUM(sm.net_flow) > 10000;"}, {"role": "user", "content": "Please also include the current price from token_dexpool_info and order the results by average ROI descending, showing only the top 10."}, {"role": "assistant", "content": "SELECT tdi.token_symbol, tdi.chain, tdi.price, SUM(sm.net_flow) AS total_net_flow, AVG(sm.roi) AS average_roi\nFROM token_dexpool_info tdi\nJOIN smart_money_token_performance sm\n ON tdi.token_symbol = sm.token_symbol AND tdi.chain = sm.chain\nGROUP BY tdi.token_symbol, tdi.chain, tdi.price\nHAVING AVG(sm.roi) > 0.5 AND SUM(sm.net_flow) > 10000\nORDER BY average_roi DESC\nLIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts ( contract_id character varying(64) NOT NULL, address character varying(128) NOT NULL, abi text NOT NULL, bytecode text NOT NULL, deployer_address character varying(128) NOT NULL, deployed_at timestamp NOT NULL, network_id character varying(64) NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (contract_id) )\nCREATE TABLE web3.events ( event_id character varying(64) NOT NULL, contract_id character varying(64) NOT NULL, event_name character varying(128) NOT NULL, data text NOT NULL, emitted_at timestamp NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (event_id) )\nCREATE TABLE web3.tokens ( token_id character varying(64) NOT NULL, contract_address character varying(128) NOT NULL, token_name character varying(128) NOT NULL, token_symbol character varying(32) NOT NULL, decimals integer NOT NULL, total_supply numeric(38,14) NOT NULL, PRIMARY KEY (token_id) )\nCREATE TABLE web3.token_transfers ( transfer_id character varying(64) NOT NULL, token_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128) NOT NULL, value numeric(38,14) NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (transfer_id) )\nCREATE TABLE web3.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )\n", "conversations": [{"role": "user", "content": "For each contract, how many tokens are deployed at the contract address? Show contract_id, address, and token_count."}, {"role": "assistant", "content": "SELECT c.contract_id, c.address, COUNT(t.token_id) AS token_count\nFROM web3.contracts c\nLEFT JOIN web3.tokens t ON c.address = t.contract_address\nGROUP BY c.contract_id, c.address;"}, {"role": "user", "content": "Can you modify the query to only show contracts where at least 3 tokens are deployed?"}, {"role": "assistant", "content": "SELECT c.contract_id, c.address, COUNT(t.token_id) AS token_count\nFROM web3.contracts c\nLEFT JOIN web3.tokens t ON c.address = t.contract_address\nGROUP BY c.contract_id, c.address\nHAVING COUNT(t.token_id) >= 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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) )\nCREATE TABLE transportation.routes ( route_id character varying(64) NOT NULL, route_number character varying(32) NOT NULL UNIQUE, description text, origin_location_id character varying(64) NOT NULL, destination_location_id character varying(64) NOT NULL, distance_km numeric(10, 2), estimated_duration_minutes integer, type character varying(32) NOT NULL, PRIMARY KEY (route_id) )\nCREATE 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) )\nCREATE 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) )\n", "conversations": [{"role": "user", "content": "List all routes where the origin and destination are in the same state, showing the route_number, state, origin city, destination city, distance_km, and type."}, {"role": "assistant", "content": "SELECT r.route_number, o.state_province AS state, o.city AS origin_city, d.city AS destination_city, r.distance_km, r.type FROM transportation.routes r JOIN transportation.locations o ON r.origin_location_id = o.location_id JOIN transportation.locations d ON r.destination_location_id = d.location_id WHERE o.state_province = d.state_province;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.trips (\n trip_id character varying(64) NOT NULL, -- unique identifier for a specific trip instance\n route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips)\n vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used\n driver_id character varying(64) NOT NULL, -- identifier of the driver operating\n scheduled_departure timestamp with time zone NOT NULL, -- planned departure time\n actual_departure timestamp with time zone, -- actual departure time\n scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time\n actual_arrival timestamp with time zone, -- actual arrival time\n origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin)\n destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination)\n status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled\n passenger_count integer, -- number of passengers (if applicable)\n cargo_manifest_id character varying(64), -- link to cargo details (if applicable)\n PRIMARY KEY (trip_id)\n)\n", "conversations": [{"role": "user", "content": "List all unique pairs of origin and destination location IDs that have been used in trips, and count how many trips have occurred for each pair."}, {"role": "assistant", "content": "SELECT origin_location_id, destination_location_id, COUNT(*) AS trip_count FROM transportation.trips GROUP BY origin_location_id, destination_location_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me all appointments where the lawyer_id matches the client_id, and display the appointment_id, start_time, and status."}, {"role": "assistant", "content": "SELECT appointment_id, start_time, status FROM legal_services.appointments WHERE lawyer_id = client_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.utxos (\n utxo_id character varying(64) NOT NULL, -- unique identifier for the UTXO\n transaction_id character varying(64) NOT NULL, -- identifier of the transaction that created the UTXO\n output_index integer NOT NULL, -- index of the output in the transaction\n address character varying(128) NOT NULL, -- address that can spend the UTXO\n amount numeric(38,14) NOT NULL, -- amount of the asset in the UTXO\n spent boolean NOT NULL, -- whether the UTXO has been spent\n PRIMARY KEY (utxo_id)\n)\nCREATE TABLE trading_platform.dapps (\n dapp_id character varying(64) NOT NULL, -- unique identifier for the DApp\n name character varying(128) NOT NULL, -- name of the DApp\n description text NOT NULL, -- description of the DApp\n url character varying(256) NOT NULL, -- URL of the DApp\n PRIMARY KEY (dapp_id)\n)\n", "conversations": [{"role": "user", "content": "List all assets mentioned in DApp descriptions along with the DApp name and URL."}, {"role": "assistant", "content": "SELECT a.name AS asset_name,\n a.symbol AS asset_symbol,\n d.name AS dapp_name,\n d.url\nFROM trading_platform.assets a\nJOIN trading_platform.dapps d\n ON d.description ILIKE '%' || a.symbol || '%';"}, {"role": "user", "content": "Actually, only include assets of type 'cryptocurrency'."}, {"role": "assistant", "content": "SELECT a.name AS asset_name,\n a.symbol AS asset_symbol,\n d.name AS dapp_name,\n d.url\nFROM trading_platform.assets a\nJOIN trading_platform.dapps d\n ON d.description ILIKE '%' || a.symbol || '%'\nWHERE a.type = 'cryptocurrency';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )\nCREATE TABLE legal_services.lawyers ( lawyer_id text PRIMARY KEY, first_name text, last_name text, bar_number text UNIQUE, firm_id text, email text UNIQUE, phone text, specialization text, hire_date timestamp, is_partner bool )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.cases ( case_id character varying(64) NOT NULL, case_number character varying(100) UNIQUE, case_name text NOT NULL, client_id character varying(64) NOT NULL, lead_lawyer_id character varying(64) NOT NULL, case_type character varying(100) NOT NULL, status character varying(50) NOT NULL, date_opened timestamp NOT NULL, date_closed timestamp, description text, court_jurisdiction character varying(128), PRIMARY KEY (case_id) )\nCREATE TABLE legal_services.time_entries (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\nCREATE TABLE legal_services.invoices ( invoice_id text PRIMARY KEY, invoice_number text UNIQUE, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text PRIMARY KEY, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show me all clients together with the names of the lawyers who have handled cases for them and the case names."}, {"role": "assistant", "content": "SELECT c.client_id, c.first_name || ' ' || c.last_name AS client_full_name, l.first_name || ' ' || l.last_name AS lawyer_full_name, cs.case_name\nFROM legal_services.clients c\nJOIN legal_services.cases cs ON c.client_id = cs.client_id\nJOIN legal_services.lawyers l ON cs.lead_lawyer_id = l.lawyer_id;"}, {"role": "user", "content": "Can you add the lawyer's specialization to the result?"}, {"role": "assistant", "content": "SELECT c.client_id, c.first_name || ' ' || c.last_name AS client_full_name, l.first_name || ' ' || l.last_name AS lawyer_full_name, l.specialization, cs.case_name\nFROM legal_services.clients c\nJOIN legal_services.cases cs ON c.client_id = cs.client_id\nJOIN legal_services.lawyers l ON cs.lead_lawyer_id = l.lawyer_id;"}, {"role": "user", "content": "Only show cases where the lawyer's specialization is not null and the client has a phone number."}, {"role": "assistant", "content": "SELECT c.client_id, c.first_name || ' ' || c.last_name AS client_full_name, l.first_name || ' ' || l.last_name AS lawyer_full_name, l.specialization, cs.case_name\nFROM legal_services.clients c\nJOIN legal_services.cases cs ON c.client_id = cs.client_id\nJOIN legal_services.lawyers l ON cs.lead_lawyer_id = l.lawyer_id\nWHERE l.specialization IS NOT NULL AND c.phone IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "List each unique plan_id and the total number of patients enrolled in that plan."}, {"role": "assistant", "content": "SELECT plan_id, COUNT(DISTINCT patient_id) AS patient_count FROM healthcare.patient_insurance GROUP BY plan_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\nCREATE TABLE insurance.claims ( claim_id text, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\n", "conversations": [{"role": "user", "content": "List the claim ID, customer full name, and claim status for all claims with a settlement amount less than 1000."}, {"role": "assistant", "content": "SELECT cl.claim_id, c.first_name || ' ' || c.last_name AS customer_full_name, cl.status\nFROM insurance.claims cl\nJOIN insurance.customers c ON cl.customer_id = c.customer_id\nWHERE cl.settlement_amount < 1000;"}, {"role": "user", "content": "Actually, only show those claims where the status is 'Pending'."}, {"role": "assistant", "content": "SELECT cl.claim_id, c.first_name || ' ' || c.last_name AS customer_full_name, cl.status\nFROM insurance.claims cl\nJOIN insurance.customers c ON cl.customer_id = c.customer_id\nWHERE cl.settlement_amount < 1000 AND cl.status = 'Pending';"}, {"role": "user", "content": "Also, include the incident date and order the results by incident date descending."}, {"role": "assistant", "content": "SELECT cl.claim_id, c.first_name || ' ' || c.last_name AS customer_full_name, cl.status, cl.incident_date\nFROM insurance.claims cl\nJOIN insurance.customers c ON cl.customer_id = c.customer_id\nWHERE cl.settlement_amount < 1000 AND cl.status = 'Pending'\nORDER BY cl.incident_date DESC;"}, {"role": "user", "content": "Please limit the results to the 5 most recent such claims."}, {"role": "assistant", "content": "SELECT cl.claim_id, c.first_name || ' ' || c.last_name AS customer_full_name, cl.status, cl.incident_date\nFROM insurance.claims cl\nJOIN insurance.customers c ON cl.customer_id = c.customer_id\nWHERE cl.settlement_amount < 1000 AND cl.status = 'Pending'\nORDER BY cl.incident_date DESC\nLIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.contracts ( contract_id.text, address.text, abi.text, bytecode.text, deployer_address.text, deployed_at.timestamp, network_id.text, status.text )\nCREATE TABLE web3.transactions ( transaction_id text PRIMARY KEY, from_address text, to_address text, value numeric, gas_used int, gas_price numeric, block_number int, timestamp timestamp, input_data text, status text, nonce int )\nCREATE TABLE web3.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\n", "conversations": [{"role": "user", "content": "Show me all contracts deployed on the 'ethereum' network along with their deployer addresses and the count of transactions they've been involved in, sorted by transaction count in descending order."}, {"role": "assistant", "content": "SELECT c.address, c.deployer_address, COUNT(t.transaction_id) AS transaction_count FROM web3.contracts c LEFT JOIN web3.transactions t ON c.address = t.to_address WHERE c.network_id = 'ethereum' GROUP BY c.address, c.deployer_address ORDER BY transaction_count DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb )\n", "conversations": [{"role": "user", "content": "List each item_type along with the average cost_amount."}, {"role": "assistant", "content": "SELECT item_type, AVG(cost_amount) AS avg_cost\nFROM gaming_technology.in_game_items\nGROUP BY item_type;"}, {"role": "user", "content": "Now only include types where the average cost_amount is greater than 1000."}, {"role": "assistant", "content": "SELECT item_type, AVG(cost_amount) AS avg_cost\nFROM gaming_technology.in_game_items\nGROUP BY item_type\nHAVING AVG(cost_amount) > 1000;"}, {"role": "user", "content": "Also sort the results by avg_cost in ascending order."}, {"role": "assistant", "content": "SELECT item_type, AVG(cost_amount) AS avg_cost\nFROM gaming_technology.in_game_items\nGROUP BY item_type\nHAVING AVG(cost_amount) > 1000\nORDER BY avg_cost ASC;"}, {"role": "user", "content": "Finally, limit the output to the top 3 item_types."}, {"role": "assistant", "content": "SELECT item_type, AVG(cost_amount) AS avg_cost\nFROM gaming_technology.in_game_items\nGROUP BY item_type\nHAVING AVG(cost_amount) > 1000\nORDER BY avg_cost ASC\nLIMIT 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users ( user_id text, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified boolean )\nCREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Give me a list of users who follow more than one other user, including their username and the count of people they follow."}, {"role": "assistant", "content": "SELECT u.username, COUNT(f.following_user_id) AS following_count\nFROM social_media.follows f\nJOIN social_media.users u ON f.follower_user_id = u.user_id\nGROUP BY u.username\nHAVING COUNT(f.following_user_id) > 1;"}, {"role": "user", "content": "Also, show only users who have selected the 'light' theme."}, {"role": "assistant", "content": "SELECT u.username, COUNT(f.following_user_id) AS following_count\nFROM social_media.follows f\nJOIN social_media.users u ON f.follower_user_id = u.user_id\nJOIN social_media.user_settings s ON u.user_id = s.user_id\nWHERE s.theme = 'light'\nGROUP BY u.username\nHAVING COUNT(f.following_user_id) > 1;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE smart_money_token_performance ( token_address text, token_symbol text, pnl numeric, net_flow numeric, avg_cost numeric, price numeric, realized_ratio numeric, roi numeric, chain text )\n \"CREATE TABLE smart_money_token_inflow (\",\n \"token_address character varying(100) NOT NULL, -- the token's address\",\n \"token_symbol character varying(100), -- the tokens's symbol\",\n \"token_amount numeric(38,2), -- the absolute value of the amount if user bought minus the amount user sold of this token\",\n \"usd_value numeric(38,2), -- the absolute usd value of the bought token minus sold token\",\n \"avg_price numeric(38,6), -- the average cost price of user spent on this token\",\n \"type int, -- the direction of the trade on this token. 1 means buying, 2 means selling\",\n \"address_amount integer, -- the amount of the user bought this token\",\n \"narrative character varying(100), -- the category or narrative of the token\",\n \"chain character varying(100), -- the chain that the token resides\",\n \",PRIMARY KEY (token_address, chain)\",\n\n", "conversations": [{"role": "user", "content": "Find tokens with positive ROI and a positive net flow from smart money addresses. For these tokens, show their symbol, chain, ROI, net flow, and the total USD value from buy transactions."}, {"role": "assistant", "content": "SELECT T1.token_symbol, T1.chain, T1.roi, T1.net_flow, SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) AS total_buy_value FROM smart_money_token_performance AS T1 JOIN smart_money_token_inflow AS T2 ON T1.token_address = T2.token_address AND T1.chain = T2.chain WHERE T1.roi > 0 AND T1.net_flow > 0 AND T2.type = 1 GROUP BY T1.token_symbol, T1.chain, T1.roi, T1.net_flow ORDER BY T1.roi DESC;"}, {"role": "user", "content": "Refine this by only including tokens where the total buy USD value is greater than $50,000. Order the results by ROI descending and show the top 10."}, {"role": "assistant", "content": "SELECT T1.token_symbol, T1.chain, T1.roi, T1.net_flow, SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) AS total_buy_value FROM smart_money_token_performance AS T1 JOIN smart_money_token_inflow AS T2 ON T1.token_address = T2.token_address AND T1.chain = T2.chain WHERE T1.roi > 0 AND T1.net_flow > 0 AND T2.type = 1 GROUP BY T1.token_symbol, T1.chain, T1.roi, T1.net_flow HAVING SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) > 50000 ORDER BY T1.roi DESC LIMIT 10;"}, {"role": "user", "content": "Okay, now include the token's narrative and filter the results to only include tokens on the 'Arbitrum' chain."}, {"role": "assistant", "content": "SELECT T1.token_symbol, T1.chain, T2.narrative, T1.roi, T1.net_flow, SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) AS total_buy_value FROM smart_money_token_performance AS T1 JOIN smart_money_token_inflow AS T2 ON T1.token_address = T2.token_address AND T1.chain = T2.chain WHERE T1.roi > 0 AND T1.net_flow > 0 AND T2.type = 1 AND T1.chain = 'Arbitrum' GROUP BY T1.token_symbol, T1.chain, T2.narrative, T1.roi, T1.net_flow HAVING SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) > 50000 ORDER BY T1.roi DESC LIMIT 10;"}, {"role": "user", "content": "Adjust the ROI filter to be greater than 1 (100%) and also require the realized ratio from the performance table to be greater than 0.2. Display the realized ratio in the output."}, {"role": "assistant", "content": "SELECT T1.token_symbol, T1.chain, T2.narrative, T1.roi, T1.realized_ratio, T1.net_flow, SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) AS total_buy_value FROM smart_money_token_performance AS T1 JOIN smart_money_token_inflow AS T2 ON T1.token_address = T2.token_address AND T1.chain = T2.chain WHERE T1.roi > 1 AND T1.net_flow > 0 AND T1.realized_ratio > 0.2 AND T2.type = 1 AND T1.chain = 'Arbitrum' GROUP BY T1.token_symbol, T1.chain, T2.narrative, T1.roi, T1.realized_ratio, T1.net_flow HAVING SUM(CASE WHEN T2.type = 1 THEN T2.usd_value ELSE 0 END) > 50000 ORDER BY T1.roi DESC LIMIT 10;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\n", "conversations": [{"role": "user", "content": "How many customers have a non-null phone number in your system?"}, {"role": "assistant", "content": "SELECT COUNT(*) FROM insurance.customers WHERE phone_number IS NOT NULL;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.tokens ( token_id text PRIMARY KEY, contract_address text, token_name text, token_symbol text, decimals int, total_supply numeric )\n", "conversations": [{"role": "user", "content": "Find all pairs of tokens that have the same contract_address but different token_symbols. Show both token_ids, each token's symbol, and the shared contract_address."}, {"role": "assistant", "content": "SELECT t1.token_id AS token_id_1, t2.token_id AS token_id_2, t1.token_symbol AS symbol_1, t2.token_symbol AS symbol_2, t1.contract_address FROM web3.tokens t1 JOIN web3.tokens t2 ON t1.contract_address = t2.contract_address AND t1.token_id < t2.token_id AND t1.token_symbol <> t2.token_symbol;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "How many beneficiaries are there for each relationship type in the policy_beneficiaries table?"}, {"role": "assistant", "content": "SELECT relationship, COUNT(*) AS beneficiary_count\nFROM insurance.policy_beneficiaries\nGROUP BY relationship;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text )\n", "conversations": [{"role": "user", "content": "List each claim_handler_id and the number of claims they handled that were reported in 2023."}, {"role": "assistant", "content": "SELECT claim_handler_id,\n COUNT(*) AS claims_count\nFROM insurance.claims\nWHERE reported_date::date BETWEEN '2023-01-01' AND '2023-12-31'\nGROUP BY claim_handler_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text PRIMARY KEY, first_name text, last_name text, company_name text, email text UNIQUE, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\nCREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents (\n document_id character varying(64) NOT NULL, -- unique identifier for the document\n case_id character varying(64) NOT NULL, -- FK to cases table\n document_name character varying(255) NOT NULL, -- name of the document file\n document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence\n storage_path text NOT NULL, -- path or reference to the document storage location\n uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it)\n upload_timestamp timestamp NOT NULL, -- time the document was uploaded\n version integer DEFAULT 1, -- document version number\n description text, -- brief description or notes about the document\n PRIMARY KEY (document_id)\n)\nCREATE TABLE legal_services.time_entries (\n entry_id character varying(64) NOT NULL, -- unique identifier for the time entry\n case_id character varying(64) NOT NULL, -- FK to cases table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)\n date_worked date NOT NULL, -- date the work was performed\n hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)\n billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry\n description text NOT NULL, -- detailed description of the work performed\n is_billable boolean DEFAULT true, -- whether this time entry is billable to the client\n is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice\n invoice_id character varying(64), -- FK to invoices table (once billed)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded\n PRIMARY KEY (entry_id)\n)\nCREATE TABLE legal_services.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n client_id character varying(64) NOT NULL, -- FK to clients table\n lawyer_id character varying(64) NOT NULL, -- FK to lawyers table\n case_id character varying(64), -- FK to cases table (optional, if related to a specific case)\n start_time timestamp NOT NULL, -- scheduled start date and time\n end_time timestamp NOT NULL, -- scheduled end date and time\n location text, -- location of the meeting (address or virtual link)\n subject character varying(255), -- subject or purpose of the appointment\n notes text, -- additional notes for the appointment\n status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (appointment_id)\n)\n", "conversations": [{"role": "user", "content": "Please show the names and bar numbers of all lawyers who have led appointments with more than 3 different clients."}, {"role": "assistant", "content": "SELECT l.first_name, l.last_name, l.bar_number\nFROM legal_services.lawyers l\nJOIN legal_services.appointments a ON l.lawyer_id = a.lawyer_id\nGROUP BY l.lawyer_id, l.first_name, l.last_name, l.bar_number\nHAVING COUNT(DISTINCT a.client_id) > 3;"}, {"role": "user", "content": "Can you add the total number of appointments each of these lawyers has handled?"}, {"role": "assistant", "content": "SELECT l.first_name, l.last_name, l.bar_number, COUNT(a.appointment_id) AS appointment_count\nFROM legal_services.lawyers l\nJOIN legal_services.appointments a ON l.lawyer_id = a.lawyer_id\nGROUP BY l.lawyer_id, l.first_name, l.last_name, l.bar_number\nHAVING COUNT(DISTINCT a.client_id) > 3;"}, {"role": "user", "content": "Actually, I also want to see the name of the law firm each lawyer belongs to."}, {"role": "assistant", "content": "SELECT l.first_name, l.last_name, l.bar_number, f.firm_name, COUNT(a.appointment_id) AS appointment_count\nFROM legal_services.lawyers l\nJOIN legal_services.appointments a ON l.lawyer_id = a.lawyer_id\nLEFT JOIN legal_services.law_firms f ON l.firm_id = f.firm_id\nGROUP BY l.lawyer_id, l.first_name, l.last_name, l.bar_number, f.firm_name\nHAVING COUNT(DISTINCT a.client_id) > 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text )\nCREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.agents ( agent_id.text, first_name.text, last_name.text, agency_name.text, license_number.text, license_state.text, contact_email.text, contact_phone.text, hire_date.date, termination_date.date, status.text, commission_rate.numeric, manager_id.text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp )\n", "conversations": [{"role": "user", "content": "What is the average commission rate for active agents?"}, {"role": "assistant", "content": "SELECT AVG(commission_rate) FROM insurance.agents WHERE status = 'Active';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp )\nCREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_read_at timestamp, PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) )\nCREATE TABLE social_media.user_settings ( setting_id text PRIMARY KEY, user_id text, theme text, email_notifications_enabled bool, push_notifications_enabled bool, private_profile bool, updated_at timestamp )\n", "conversations": [{"role": "user", "content": "Get the total number of participants per conversation along with the number of participants who have private profiles."}, {"role": "assistant", "content": "SELECT cp.conversation_id, COUNT(cp.user_id) AS total_participants, SUM(CASE WHEN us.private_profile THEN 1 ELSE 0 END) AS private_profile_count FROM social_media.conversation_participants cp LEFT JOIN social_media.user_settings us ON cp.user_id = us.user_id GROUP BY cp.conversation_id;"}, {"role": "user", "content": "Exclude conversations with fewer than 3 private profile participants."}, {"role": "assistant", "content": "SELECT cp.conversation_id, COUNT(cp.user_id) AS total_participants, SUM(CASE WHEN us.private_profile THEN 1 ELSE 0 END) AS private_profile_count FROM social_media.conversation_participants cp LEFT JOIN social_media.user_settings us ON cp.user_id = us.user_id GROUP BY cp.conversation_id HAVING SUM(CASE WHEN us.private_profile THEN 1 ELSE 0 END) >= 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )\nCREATE TABLE trading_platform.assets (\n asset_id character varying(64) NOT NULL, -- unique identifier for the asset\n name character varying(128) NOT NULL, -- name of the asset\n symbol character varying(32) NOT NULL, -- symbol of the asset\n type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)\n PRIMARY KEY (asset_id)\n)\nCREATE TABLE trading_platform.dapps ( dapp_id.text, name.text, description.text, url.text )\nCREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (peer_id) )\nCREATE TABLE trading_platform.metadata (\n metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata\n asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with\n key character varying(128) NOT NULL, -- key of the metadata\n value text NOT NULL, -- value of the metadata\n PRIMARY KEY (metadata_id)\n)\nCREATE TABLE trading_platform.kyc_audit ( kyc_audit_id.text, user_id.text, status.text, reviewed_at.timestamp )\nCREATE TABLE trading_platform.logs (\n log_id character varying(64) NOT NULL, -- unique identifier for the log entry\n user_id character varying(64), -- identifier of the user associated with the log entry\n action character varying(128) NOT NULL, -- action performed\n details text NOT NULL, -- details of the action\n logged_at timestamp NOT NULL, -- time when the log entry was created\n PRIMARY KEY (log_id)\n)\nCREATE TABLE trading_platform.notifications ( notification_id.text, user_id.text, message.text, sent_at.timestamp, read_at.timestamp )\n", "conversations": [{"role": "user", "content": "List the names and URLs of all available decentralized applications (DApps)."}, {"role": "assistant", "content": "SELECT name, url FROM dapps;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "Show all users who registered before 2023-01-01, along with their usernames and registration dates."}, {"role": "assistant", "content": "SELECT user_id, username, created_at\nFROM web3.users\nWHERE created_at < '2023-01-01';"}, {"role": "user", "content": "Can you additionally include their email addresses in the result?"}, {"role": "assistant", "content": "SELECT user_id, username, email, created_at\nFROM web3.users\nWHERE created_at < '2023-01-01';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE social_media.users (\n user_id character varying(64) NOT NULL, -- unique identifier for the user\n username character varying(50) NOT NULL UNIQUE, -- user's unique handle\n email character varying(128) NOT NULL UNIQUE, -- user's email address\n password_hash text NOT NULL, -- hashed password\n full_name character varying(100), -- user's full name\n profile_picture_url text, -- URL to the profile picture\n bio text, -- short user biography\n location character varying(100), -- user's location\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update\n is_verified boolean NOT NULL DEFAULT false, -- verification status\n PRIMARY KEY (user_id)\n)\nCREATE TABLE social_media.posts (\n post_id character varying(64) NOT NULL, -- unique identifier for the post\n user_id character varying(64) NOT NULL, -- identifier of the user who created the post (FK to users.user_id)\n content text, -- textual content of the post\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of post creation\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last post edit\n visibility character varying(20) NOT NULL DEFAULT 'public', -- visibility ('public', 'friends', 'private')\n location_lat numeric(9,6), -- latitude of post location\n location_lon numeric(9,6), -- longitude of post location\n PRIMARY KEY (post_id)\n)\nCREATE TABLE social_media.likes (\n like_id character varying(64) NOT NULL, -- unique identifier for the like\n user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id)\n post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable)\n comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred\n PRIMARY KEY (like_id),\n CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes\n CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something\n)\nCREATE TABLE social_media.follows (\n follow_id character varying(64) NOT NULL, -- unique identifier for the follow relationship\n follower_user_id character varying(64) NOT NULL, -- identifier of the user who is following (FK to users.user_id)\n following_user_id character varying(64) NOT NULL, -- identifier of the user being followed (FK to users.user_id)\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the follow started\n PRIMARY KEY (follow_id),\n CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) -- prevent duplicate follows\n)\nCREATE TABLE social_media.post_hashtags (\n post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link\n post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id)\n hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id)\n PRIMARY KEY (post_hashtag_id),\n CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post\n)\nCREATE TABLE social_media.messages (\n message_id character varying(64) NOT NULL, -- unique identifier for the message\n conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id)\n sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id)\n content text, -- textual content of the message\n media_url text, -- URL to attached media (image/video)\n media_type character varying(20), -- type of media ('image', 'video', null)\n sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent\n read_at timestamp, -- timestamp when message was read by recipient(s)\n PRIMARY KEY (message_id)\n)\nCREATE TABLE social_media.conversations (\n conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated\n last_message_at timestamp, -- timestamp of the last message in the conversation\n is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message\n group_name character varying(100), -- name of the group chat (if applicable)\n PRIMARY KEY (conversation_id)\n)\nCREATE TABLE social_media.conversation_participants (\n participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry\n conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id)\n user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id)\n joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation\n last_read_at timestamp, -- timestamp indicating up to when the user has read messages\n PRIMARY KEY (participant_id),\n CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times\n)\nCREATE TABLE social_media.notifications (\n notification_id character varying(64) NOT NULL, -- unique identifier for the notification\n recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)\n sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)\n notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')\n target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)\n target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')\n created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created\n read_at timestamp, -- timestamp notification was marked as read\n PRIMARY KEY (notification_id)\n)\nCREATE TABLE social_media.user_settings (\n setting_id character varying(64) NOT NULL, -- unique identifier for the setting entry\n user_id character varying(64) NOT NULL UNIQUE, -- user the settings belong to (FK to users.user_id)\n theme character varying(20) DEFAULT 'light', -- UI theme ('light', 'dark')\n email_notifications_enabled boolean DEFAULT true, -- enable/disable email notifications\n push_notifications_enabled boolean DEFAULT true, -- enable/disable push notifications\n private_profile boolean DEFAULT false, -- is the user profile private\n updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last setting change\n PRIMARY KEY (setting_id)\n)\n", "conversations": [{"role": "user", "content": "List each user and their total number of followers, including username, ordered by follower count descending."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(f.follower_user_id) AS follower_count FROM social_media.users u LEFT JOIN social_media.follows f ON u.user_id = f.following_user_id GROUP BY u.user_id, u.username ORDER BY follower_count DESC;"}, {"role": "user", "content": "Filter to only include users who have email_notifications_enabled = true."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(f.follower_user_id) AS follower_count FROM social_media.users u JOIN social_media.user_settings s ON u.user_id = s.user_id AND s.email_notifications_enabled = true LEFT JOIN social_media.follows f ON u.user_id = f.following_user_id GROUP BY u.user_id, u.username ORDER BY follower_count DESC;"}, {"role": "user", "content": "Also include only those users who are verified."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(f.follower_user_id) AS follower_count FROM social_media.users u JOIN social_media.user_settings s ON u.user_id = s.user_id AND s.email_notifications_enabled = true LEFT JOIN social_media.follows f ON u.user_id = f.following_user_id WHERE u.is_verified = true GROUP BY u.user_id, u.username ORDER BY follower_count DESC;"}, {"role": "user", "content": "Limit the results to the top 5 users."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, COUNT(f.follower_user_id) AS follower_count FROM social_media.users u JOIN social_media.user_settings s ON u.user_id = s.user_id AND s.email_notifications_enabled = true LEFT JOIN social_media.follows f ON u.user_id = f.following_user_id WHERE u.is_verified = true GROUP BY u.user_id, u.username ORDER BY follower_count DESC LIMIT 5;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients (\n patient_id character varying(64) NOT NULL, -- unique identifier for the patient\n first_name character varying(100) NOT NULL, -- patient's first name\n last_name character varying(100) NOT NULL, -- patient's last name\n date_of_birth date NOT NULL, -- patient's date of birth\n gender character varying(10), -- patient's gender (e.g., Male, Female, Other)\n address text, -- patient's home address\n phone_number character varying(20), -- patient's phone number\n email character varying(128) UNIQUE, -- patient's email address\n emergency_contact_name character varying(200), -- name of emergency contact\n emergency_contact_phone character varying(20), -- phone number of emergency contact\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time\n PRIMARY KEY (patient_id)\n)\nCREATE TABLE healthcare.doctors (\n doctor_id character varying(64) NOT NULL, -- unique identifier for the doctor\n first_name character varying(100) NOT NULL, -- doctor's first name\n last_name character varying(100) NOT NULL, -- doctor's last name\n specialty character varying(100) NOT NULL, -- doctor's medical specialty\n license_number character varying(50) UNIQUE NOT NULL, -- doctor's medical license number\n phone_number character varying(20), -- doctor's contact phone\n email character varying(128) UNIQUE, -- doctor's contact email\n hospital_affiliation_id character varying(64), -- FK to hospitals table (optional)\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (doctor_id)\n)\nCREATE TABLE healthcare.appointments (\n appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment\n patient_id character varying(64) NOT NULL, -- FK to patients table\n doctor_id character varying(64) NOT NULL, -- FK to doctors table\n appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment\n duration_minutes integer NOT NULL, -- expected duration in minutes\n reason text, -- reason for the visit\n status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show\n location_id character varying(64), -- FK to a potential locations/clinics table\n notes text, -- notes related to scheduling\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (appointment_id)\n)\nCREATE TABLE healthcare.medical_records (\n record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry\n patient_id character varying(64) NOT NULL, -- FK to patients table\n appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)\n doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)\n record_date timestamp with time zone NOT NULL, -- date the record/observation was made\n chief_complaint text, -- patient's primary reason for visit\n present_illness_history text, -- detailed history of the current issue\n past_medical_history text, -- relevant past conditions/surgeries\n physical_examination_notes text, -- findings from the physical exam\n assessment text, -- doctor's assessment/diagnosis summary\n treatment_plan text, -- planned course of action\n vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON\n created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,\n PRIMARY KEY (record_id)\n)\nCREATE TABLE healthcare.medications (\n medication_id character varying(64) NOT NULL, -- unique identifier for the medication type\n medication_name character varying(255) NOT NULL, -- common or brand name\n generic_name character varying(255), -- generic chemical name\n manufacturer character varying(100), -- drug manufacturer\n ndc_code character varying(20) UNIQUE, -- National Drug Code (optional but useful)\n description text, -- description of the medication\n PRIMARY KEY (medication_id)\n)\nCREATE TABLE healthcare.insurance_plans (\n plan_id character varying(64) NOT NULL, -- unique identifier for the insurance plan\n plan_name character varying(200) NOT NULL, -- name of the insurance plan\n insurance_provider character varying(100) NOT NULL, -- name of the insurance company\n plan_type character varying(50), -- e.g., PPO, HMO, EPO\n contact_phone character varying(20), -- provider contact number\n website character varying(255), -- provider website\n PRIMARY KEY (plan_id)\n)\nCREATE TABLE healthcare.patient_insurance (\n patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link\n patient_id character varying(64) NOT NULL, -- FK to patients table\n plan_id character varying(64) NOT NULL, -- FK to insurance_plans table\n policy_number character varying(100) NOT NULL, -- patient's policy number\n group_number character varying(100), -- group number, if applicable\n subscriber_name character varying(200), -- name of the primary policy holder\n effective_date date NOT NULL, -- date the coverage begins\n expiration_date date, -- date the coverage ends (if known)\n is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance\n PRIMARY KEY (patient_insurance_id),\n UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice\n)\n", "conversations": [{"role": "user", "content": "Provide each patient's most recent medical-record doctor's full name along with their primary insurance plan name. Return patient_id, first_name, last_name, primary_plan_name, doctor_first_name, doctor_last_name."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name AS primary_plan_name,\n d.first_name AS doctor_first_name,\n d.last_name AS doctor_last_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id\n AND pi.is_primary = TRUE\nJOIN healthcare.insurance_plans AS ip\n ON pi.plan_id = ip.plan_id\nJOIN (\n SELECT DISTINCT ON (patient_id)\n patient_id,\n doctor_id,\n record_date\n FROM healthcare.medical_records\n ORDER BY patient_id, record_date DESC\n) AS mr\n ON p.patient_id = mr.patient_id\nJOIN healthcare.doctors AS d\n ON mr.doctor_id = d.doctor_id;"}, {"role": "user", "content": "Actually, restrict to only those whose primary plan_type is 'PPO'."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name AS primary_plan_name,\n d.first_name AS doctor_first_name,\n d.last_name AS doctor_last_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id\n AND pi.is_primary = TRUE\nJOIN healthcare.insurance_plans AS ip\n ON pi.plan_id = ip.plan_id\nJOIN (\n SELECT DISTINCT ON (patient_id)\n patient_id,\n doctor_id,\n record_date\n FROM healthcare.medical_records\n ORDER BY patient_id, record_date DESC\n) AS mr\n ON p.patient_id = mr.patient_id\nJOIN healthcare.doctors AS d\n ON mr.doctor_id = d.doctor_id\nWHERE ip.plan_type = 'PPO';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE gaming_technology.game_sessions ( session_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, game_id uuid NOT NULL, server_id uuid, start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, end_time timestamp with time zone, duration_seconds integer, score integer, session_data jsonb, PRIMARY KEY (session_id) )\nCREATE TABLE gaming_technology.achievements ( achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), game_id uuid NOT NULL, name character varying(150) NOT NULL, description text NOT NULL, icon_url character varying(255), points integer DEFAULT 0, hidden boolean DEFAULT false, PRIMARY KEY (achievement_id) )\nCREATE TABLE gaming_technology.player_inventory ( inventory_id uuid NOT NULL DEFAULT gen_random_uuid(), player_id uuid NOT NULL, item_id uuid NOT NULL, quantity integer NOT NULL DEFAULT 1, acquired_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, instance_data jsonb, PRIMARY KEY (inventory_id) )\n", "conversations": [{"role": "user", "content": "Show each player's total session count and the date of their earliest acquired inventory item."}, {"role": "assistant", "content": "SELECT gs.player_id,\n COUNT(gs.session_id) AS session_count,\n MIN(pi.acquired_at) AS first_item_date\nFROM gaming_technology.game_sessions gs\nLEFT JOIN gaming_technology.player_inventory pi\n ON gs.player_id = pi.player_id\nGROUP BY gs.player_id;"}, {"role": "user", "content": "Exclude players who have no inventory items."}, {"role": "assistant", "content": "SELECT gs.player_id,\n COUNT(gs.session_id) AS session_count,\n MIN(pi.acquired_at) AS first_item_date\nFROM gaming_technology.game_sessions gs\nJOIN gaming_technology.player_inventory pi\n ON gs.player_id = pi.player_id\nGROUP BY gs.player_id;"}, {"role": "user", "content": "Now only include players with session_count of at least 5."}, {"role": "assistant", "content": "SELECT gs.player_id,\n COUNT(gs.session_id) AS session_count,\n MIN(pi.acquired_at) AS first_item_date\nFROM gaming_technology.game_sessions gs\nJOIN gaming_technology.player_inventory pi\n ON gs.player_id = pi.player_id\nGROUP BY gs.player_id\nHAVING COUNT(gs.session_id) >= 5;"}, {"role": "user", "content": "Order the results by session_count descending and first_item_date ascending."}, {"role": "assistant", "content": "SELECT gs.player_id,\n COUNT(gs.session_id) AS session_count,\n MIN(pi.acquired_at) AS first_item_date\nFROM gaming_technology.game_sessions gs\nJOIN gaming_technology.player_inventory pi\n ON gs.player_id = pi.player_id\nGROUP BY gs.player_id\nHAVING COUNT(gs.session_id) >= 5\nORDER BY session_count DESC, first_item_date ASC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n// db.createCollection('passengers')\n// Optional: db.passengers.createIndex({ passenger_id: 1 }, { unique: true })\n// Optional: db.passengers.createIndex({ email: 1 }, { unique: true, sparse: true })\n// Optional: db.passengers.createIndex({ phone_number: 1 }, { unique: true, sparse: true })\n{\n _id: ObjectId(),\n passenger_id: \"pass_pqr\", // String (unique)\n first_name: \"Alice\", // String\n last_name: \"Smith\", // String\n email: \"alice.smith@example.com\", // String (unique, sparse)\n phone_number: \"+15551234567\", // String (unique, sparse)\n date_of_birth: ISODate(\"1990-03-20\"), // Date\n loyalty_program_id: \"LOYALTY123\", // String\n created_at: ISODate(\"2023-02-01T11:00:00Z\") // Date\n}\n", "conversations": [{"role": "user", "content": "Can you help me retrieve the details of passengers who are part of a specific loyalty program with ID 'LOYALTY123'?"}, {"role": "assistant", "content": "db.passengers.find({ loyalty_program_id: 'LOYALTY123' }, { first_name: 1, last_name: 1, email: 1, phone_number: 1, date_of_birth: 1, loyalty_program_id: 1, _id: 0 })"}, {"role": "user", "content": "Can you modify the query to include only passengers who were registered after January 1, 2023?"}, {"role": "assistant", "content": "db.passengers.find({ loyalty_program_id: 'LOYALTY123', created_at: { $gt: ISODate('2023-01-01T00:00:00Z') } }, { first_name: 1, last_name: 1, email: 1, phone_number: 1, date_of_birth: 1, loyalty_program_id: 1, _id: 0 })"}, {"role": "user", "content": "Can you sort the results by the registration date in descending order?"}, {"role": "assistant", "content": "db.passengers.find({ loyalty_program_id: 'LOYALTY123', created_at: { $gt: ISODate('2023-01-01T00:00:00Z') } }, { first_name: 1, last_name: 1, email: 1, phone_number: 1, date_of_birth: 1, loyalty_program_id: 1, _id: 0 }).sort({ created_at: -1 })"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE 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 )\n", "conversations": [{"role": "user", "content": "Show me all pairs of patients who share the same emergency contact phone, including both patient IDs, their names, and the shared emergency contact phone."}, {"role": "assistant", "content": "SELECT p1.patient_id,\n p1.first_name,\n p1.last_name,\n p2.patient_id AS other_patient_id,\n p2.first_name AS other_first_name,\n p2.last_name AS other_last_name,\n p1.emergency_contact_phone\nFROM healthcare.patients p1\nJOIN healthcare.patients p2\n ON p1.emergency_contact_phone = p2.emergency_contact_phone\n AND p1.patient_id < p2.patient_id;"}, {"role": "user", "content": "Only include those pairs where both emergency_contact_name values are not null."}, {"role": "assistant", "content": "SELECT p1.patient_id,\n p1.first_name,\n p1.last_name,\n p2.patient_id AS other_patient_id,\n p2.first_name AS other_first_name,\n p2.last_name AS other_last_name,\n p1.emergency_contact_phone\nFROM healthcare.patients p1\nJOIN healthcare.patients p2\n ON p1.emergency_contact_phone = p2.emergency_contact_phone\n AND p1.patient_id < p2.patient_id\nWHERE p1.emergency_contact_name IS NOT NULL\n AND p2.emergency_contact_name IS NOT NULL;"}, {"role": "user", "content": "Also exclude any pairs where the shared emergency contact phone matches the patient's own phone_number."}, {"role": "assistant", "content": "SELECT p1.patient_id,\n p1.first_name,\n p1.last_name,\n p2.patient_id AS other_patient_id,\n p2.first_name AS other_first_name,\n p2.last_name AS other_last_name,\n p1.emergency_contact_phone\nFROM healthcare.patients p1\nJOIN healthcare.patients p2\n ON p1.emergency_contact_phone = p2.emergency_contact_phone\n AND p1.patient_id < p2.patient_id\nWHERE p1.emergency_contact_name IS NOT NULL\n AND p2.emergency_contact_name IS NOT NULL\n AND p1.emergency_contact_phone <> p1.phone_number\n AND p2.emergency_contact_phone <> p2.phone_number;"}, {"role": "user", "content": "Finally, order the results by the shared emergency contact phone ascending and limit to the first 50 pairs."}, {"role": "assistant", "content": "SELECT p1.patient_id,\n p1.first_name,\n p1.last_name,\n p2.patient_id AS other_patient_id,\n p2.first_name AS other_first_name,\n p2.last_name AS other_last_name,\n p1.emergency_contact_phone\nFROM healthcare.patients p1\nJOIN healthcare.patients p2\n ON p1.emergency_contact_phone = p2.emergency_contact_phone\n AND p1.patient_id < p2.patient_id\nWHERE p1.emergency_contact_name IS NOT NULL\n AND p2.emergency_contact_name IS NOT NULL\n AND p1.emergency_contact_phone <> p1.phone_number\n AND p2.emergency_contact_phone <> p2.phone_number\nORDER BY p1.emergency_contact_phone ASC\nLIMIT 50;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text )\n", "conversations": [{"role": "user", "content": "List pairs of customers who live in the same city. Return both customer IDs, their full names, and the city."}, {"role": "assistant", "content": "SELECT c1.customer_id AS customer1_id, c1.first_name || ' ' || c1.last_name AS customer1_name, c2.customer_id AS customer2_id, c2.first_name || ' ' || c2.last_name AS customer2_name, c1.city FROM insurance.customers c1 JOIN insurance.customers c2 ON c1.city = c2.city AND c1.customer_id < c2.customer_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp )\n", "conversations": [{"role": "user", "content": "How many wallets were created in each distinct month?"}, {"role": "assistant", "content": "SELECT DATE_TRUNC('month', created_at) AS creation_month, COUNT(*) AS wallet_count FROM web3.wallets GROUP BY DATE_TRUNC('month', created_at) ORDER BY creation_month;"}, {"role": "user", "content": "Filter that to only show months where more than 100 wallets were created."}, {"role": "assistant", "content": "SELECT DATE_TRUNC('month', created_at) AS creation_month, COUNT(*) AS wallet_count FROM web3.wallets GROUP BY DATE_TRUNC('month', created_at) HAVING COUNT(*) > 100 ORDER BY creation_month;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\n// Use Hashes for ticket details. Key format: ticket:\n// HSET ticket:tkt_1a2b ticket_id \"tkt_1a2b\" booking_id \"book_zyx\" car_id \"car_abc\" seat_number \"12A\" ... is_checked_in 0 ...\n\n// To link tickets to bookings (optional):\n// SADD booking:book_zyx:tickets ticket:tkt_1a2b\n// Use Hashes for maintenance record details. Key format: maintenance_record:\n// HSET maintenance_record:maint_rec_001 record_id \"maint_rec_001\" asset_id \"train_789\" asset_type \"Train\" ... status \"Completed\"\n\n// To link records to assets (optional):\n// SADD train:train_789:maintenance maintenance_record:maint_rec_001\n// SADD platform:plat_123:maintenance maintenance_record:maint_rec_002\n", "conversations": [{"role": "user", "content": "\u7279\u5b9a\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0ID 'plat_123' \u306b\u95a2\u9023\u3059\u308b\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u8a18\u9332\u3092\u53d6\u5f97\u3059\u308b\u306e\u3092\u624b\u4f1d\u3063\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f\u307e\u305f\u3001\u8a18\u9332\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3082\u542b\u3081\u3066\u304f\u3060\u3055\u3044\u3002"}, {"role": "assistant", "content": "SMEMBERS platform:plat_123:maintenance\nHGETALL maintenance_record:"}, {"role": "user", "content": "\u30b9\u30c6\u30fc\u30bf\u30b9\u304c 'Completed' \u306e\u8a18\u9332\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS platform:plat_123:maintenance\nHGET maintenance_record: status\nHGETALL maintenance_record: (only if status = 'Completed')"}, {"role": "user", "content": "\u95a2\u9023\u3059\u308b\u8cc7\u7523\u30bf\u30a4\u30d7\u3082\u7d50\u679c\u306b\u542b\u3081\u3066\u3044\u305f\u3060\u3051\u307e\u3059\u304b\uff1f"}, {"role": "assistant", "content": "SMEMBERS platform:plat_123:maintenance\nHGET maintenance_record: status\nHGETALL maintenance_record: (only if status = 'Completed')"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE hospitality_technology.rooms (\n room_id character varying(64) NOT NULL, -- unique identifier for the room\n property_id character varying(64) NOT NULL, -- FK to properties table\n room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B')\n room_type_id character varying(64) NOT NULL, -- FK to room_types table\n floor integer, -- floor number the room is on\n status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance\n is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag\n features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi)\n current_condition text, -- notes on room condition\n last_cleaned_at timestamp with time zone, -- timestamp of last cleaning\n PRIMARY KEY (room_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id),\n FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id)\n)\nCREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )\nCREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )\nCREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )\nCREATE TABLE hospitality_technology.services (\n service_id character varying(64) NOT NULL, -- unique identifier for a chargeable service\n property_id character varying(64) NOT NULL, -- FK to properties table\n service_name character varying(150) NOT NULL, -- e.g., Room Service - Burger, Spa - Massage 60min, Laundry - Shirt\n description text,\n category character varying(100), -- e.g., Food & Beverage, Wellness, Business Center, Activities\n price numeric(10, 2) NOT NULL, -- price per unit/instance\n unit character varying(30), -- e.g., Per Item, Per Hour, Per Day\n is_available boolean NOT NULL DEFAULT true, -- is the service currently offered?\n department character varying(100), -- department responsible (e.g., F&B, Spa, Housekeeping)\n PRIMARY KEY (service_id),\n FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id)\n)\n", "conversations": [{"role": "user", "content": "Show me all rooms with their room number, the type name, and the maximum occupancy for each room."}, {"role": "assistant", "content": "SELECT r.room_id, r.room_number, rt.type_name, rt.max_occupancy\nFROM hospitality_technology.rooms r\nJOIN hospitality_technology.room_types rt ON r.room_type_id = rt.room_type_id;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) )\nCREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), address text NOT NULL, city character varying(100), state character varying(50), postal_code character varying(20), latitude numeric(9, 6), longitude numeric(9, 6), operating_hours text, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) )\n", "conversations": [{"role": "user", "content": "Find all document types uploaded by citizens whose documents have an expiry date in 2024 and were uploaded at locations located in the state of 'Nevada'. List the document_id, document_type, and location_name."}, {"role": "assistant", "content": "SELECT d.document_id, d.document_type, sl.location_name\nFROM government_services.documents d\nJOIN government_services.service_locations sl\n ON d.application_id = sl.location_id\nWHERE d.expiry_date BETWEEN '2024-01-01' AND '2024-12-31'\n AND sl.state = 'Nevada';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.lawyers (\n lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer\n first_name character varying(100) NOT NULL, -- lawyer's first name\n last_name character varying(100) NOT NULL, -- lawyer's last name\n bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number\n firm_id character varying(64), -- FK to law_firms table\n email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email\n phone character varying(32), -- lawyer's contact phone number\n specialization text, -- areas of legal expertise\n hire_date timestamp NOT NULL, -- date the lawyer was hired or joined\n is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner\n PRIMARY KEY (lawyer_id)\n)\n", "conversations": [{"role": "user", "content": "Show me a list of all partners who were hired in 2021."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31';"}, {"role": "user", "content": "Include their professional email addresses as well."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n email,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31';"}, {"role": "user", "content": "Exclude any partners who haven't provided a phone number."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n email,\n phone,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31'\n AND phone IS NOT NULL;"}, {"role": "user", "content": "Finally, order the result by hire_date in descending order."}, {"role": "assistant", "content": "SELECT lawyer_id,\n first_name,\n last_name,\n email,\n phone,\n hire_date\nFROM legal_services.lawyers\nWHERE is_partner = true\n AND hire_date BETWEEN '2021-01-01' AND '2021-12-31'\n AND phone IS NOT NULL\nORDER BY hire_date DESC;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE trading_platform.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (user_id) )\nCREATE TABLE trading_platform.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )\nCREATE TABLE trading_platform.orders ( order_id text, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )\nCREATE TABLE trading_platform.trades ( trade_id text, order_id text, buyer_id text, seller_id text, asset_id text, quantity numeric, price numeric, traded_at timestamp )\nCREATE TABLE trading_platform.dapps ( dapp_id text PRIMARY KEY, name text, description text, url text )\nCREATE TABLE trading_platform.peers ( peer_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )\nCREATE TABLE trading_platform.notifications ( notification_id.text, user_id.text, message.text, sent_at.timestamp, read_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show me all users who have wallets but have never placed any orders, along with their wallet addresses."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, u.email, w.address FROM trading_platform.users u JOIN trading_platform.wallets w ON u.user_id = w.user_id LEFT JOIN trading_platform.orders o ON u.user_id = o.user_id WHERE o.order_id IS NULL;"}, {"role": "user", "content": "Now modify the query to only include users who created their wallets in the last 6 months."}, {"role": "assistant", "content": "SELECT u.user_id, u.username, u.email, w.address FROM trading_platform.users u JOIN trading_platform.wallets w ON u.user_id = w.user_id LEFT JOIN trading_platform.orders o ON u.user_id = o.user_id WHERE o.order_id IS NULL AND w.created_at >= NOW() - INTERVAL '6 months';"}, {"role": "user", "content": "Actually, I want to see the count of such users grouped by the month they created their wallets."}, {"role": "assistant", "content": "SELECT DATE_TRUNC('month', w.created_at) AS month_created, COUNT(DISTINCT u.user_id) AS user_count FROM trading_platform.users u JOIN trading_platform.wallets w ON u.user_id = w.user_id LEFT JOIN trading_platform.orders o ON u.user_id = o.user_id WHERE o.order_id IS NULL GROUP BY month_created ORDER BY month_created;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text )\nCREATE TABLE insurance.insurance_products ( product_id text, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )\nCREATE TABLE insurance.claim_documents ( document_id text, claim_id text, document_type text, file_name text, file_path text, file_size_bytes integer, mime_type text, uploaded_by text, uploaded_at timestamp, description text )\n", "conversations": [{"role": "user", "content": "Show the total file size in bytes for all documents uploaded with a MIME type of 'application/pdf'."}, {"role": "assistant", "content": "SELECT SUM(file_size_bytes) FROM insurance.claim_documents WHERE mime_type = 'application/pdf'"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE transportation.vehicles ( vehicle_id character varying(64) NOT NULL, license_plate character varying(32) NOT NULL UNIQUE, vin character varying(17) UNIQUE, make character varying(64) NOT NULL, model character varying(64) NOT NULL, year integer NOT NULL, type character varying(32) NOT NULL, capacity integer, fuel_type character varying(32) NOT NULL, status character varying(32) NOT NULL, depot_id character varying(64), acquisition_date date, PRIMARY KEY (vehicle_id) )\n", "conversations": [{"role": "user", "content": "List all pairs of vehicles with the same make and model but different manufacture years. Include each vehicle's ID, make, model, and both years."}, {"role": "assistant", "content": "SELECT v1.vehicle_id AS vehicle1_id, v2.vehicle_id AS vehicle2_id, v1.make, v1.model, v1.year AS year1, v2.year AS year2\nFROM transportation.vehicles v1\nJOIN transportation.vehicles v2\n ON v1.make = v2.make\n AND v1.model = v2.model\n AND v1.year <> v2.year\n AND v1.vehicle_id < v2.vehicle_id\nORDER BY v1.make, v1.model, v1.year;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE insurance.customers ( customer_id.text, first_name.text, last_name.text, date_of_birth.date, ssn_hash.text, address_line1.text, address_line2.text, city.text, state.text, zip_code.text, country.text, phone_number.text, email.text, created_at.timestamp, updated_at.timestamp, status.text )\nCREATE TABLE insurance.policies ( policy_id.text, customer_id.text, product_id.text, agent_id.text, policy_number.text, start_date.date, end_date.date, premium_amount.numeric, coverage_limit.numeric, deductible.numeric, status.text, issued_at.timestamp, cancellation_date.date, cancellation_reason.text )\nCREATE TABLE insurance.insurance_products ( product_id.text, product_name.text, product_type.text, description.text, base_premium.numeric, coverage_details.text, underwriting_rules.text, is_active.boolean, created_at.timestamp, updated_at.timestamp )\nCREATE TABLE insurance.agents ( agent_id.text, first_name.text, last_name.text, agency_name.text, license_number.text, license_state.text, contact_email.text, contact_phone.text, hire_date.date, termination_date.date, status.text, commission_rate.numeric, manager_id.text )\nCREATE TABLE insurance.policy_beneficiaries ( beneficiary_id.text, policy_id.text, customer_id.text, first_name.text, last_name.text, relationship.text, percentage_share.numeric, contact_info.text, added_at.timestamp )\n", "conversations": [{"role": "user", "content": "Show the name of beneficiaries and the policy number for policies that are of product type 'life'."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T2.policy_number FROM insurance.policy_beneficiaries AS T1 JOIN insurance.policies AS T2 ON T1.policy_id = T2.policy_id JOIN insurance.insurance_products AS T3 ON T2.product_id = T3.product_id WHERE T3.product_type = 'life';"}, {"role": "user", "content": "Can you also include the beneficiary's percentage share and only show results for active policies?"}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, T1.percentage_share, T2.policy_number FROM insurance.policy_beneficiaries AS T1 JOIN insurance.policies AS T2 ON T1.policy_id = T2.policy_id JOIN insurance.insurance_products AS T3 ON T2.product_id = T3.product_id WHERE T3.product_type = 'life' AND T2.status = 'active';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean )\nCREATE TABLE government_services.applications ( application_id text PRIMARY KEY, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text )\nCREATE TABLE government_services.payments ( payment_id text PRIMARY KEY, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )\nCREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )\nCREATE TABLE government_services.appointments ( appointment_id text PRIMARY KEY, citizen_id text, employee_id text, location_id text, service_id text, scheduled_start_time timestamp, scheduled_end_time timestamp, purpose text, status text, booking_method text, created_at timestamp, notes text )\nCREATE TABLE government_services.notifications ( notification_id text PRIMARY KEY, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )\n", "conversations": [{"role": "user", "content": "Show the full names and contact emails of all citizens who have made a payment for an application that is currently in 'Pending' status."}, {"role": "assistant", "content": "SELECT DISTINCT c.first_name || ' ' || c.last_name AS full_name, c.contact_email\nFROM government_services.citizens c\nJOIN government_services.payments p ON c.citizen_id = p.citizen_id\nJOIN government_services.applications a ON p.application_id = a.application_id\nWHERE a.status = 'Pending';"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE token_dexpool_info ( pair_address character varying(512) NOT NULL, -- the id of dexpool token_name character varying(100) NOT NULL, -- the name of the token in the dexpool token_symbol character varying(100) NOT NULL, -- the token's symbol chain text, -- the chain that the dexpool resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_6h double precision, -- change in value divided by the absolute price value of the original token price in 6 hours price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours makers_24h double precision, -- the makers of the dex pool in 24 hours volume_24h double precision, -- the trade volume of the dex pool in 24 hours liquidity double precision, -- the liquidity of the dex pool market_cap double precision, -- the market cap of the token trend_rank bigint, -- the rank of token in the dex pool of recent trending, value 1 expresses the most popular token. ,PRIMARY KEY (pair_address, chain) )\n", "conversations": [{"role": "user", "content": "Which three tokens on the Arbitrum chain have the lowest 6-hour price change percentage?"}, {"role": "assistant", "content": "SELECT token_symbol, price_change_percentage_6h FROM token_dexpool_info WHERE chain = 'Arbitrum' ORDER BY price_change_percentage_6h ASC LIMIT 3;"}, {"role": "user", "content": "Please also show their current price and trading volume."}, {"role": "assistant", "content": "SELECT token_symbol, price_change_percentage_6h, price, volume_24h FROM token_dexpool_info WHERE chain = 'Arbitrum' ORDER BY price_change_percentage_6h ASC LIMIT 3;"}, {"role": "user", "content": "Now include their liquidity and market cap in the result."}, {"role": "assistant", "content": "SELECT token_symbol, price_change_percentage_6h, price, volume_24h, liquidity, market_cap FROM token_dexpool_info WHERE chain = 'Arbitrum' ORDER BY price_change_percentage_6h ASC LIMIT 3;"}, {"role": "user", "content": "Restrict to only those tokens where market cap is above 10 million."}, {"role": "assistant", "content": "SELECT token_symbol, price_change_percentage_6h, price, volume_24h, liquidity, market_cap FROM token_dexpool_info WHERE chain = 'Arbitrum' AND market_cap > 10000000 ORDER BY price_change_percentage_6h ASC LIMIT 3;"}]} +{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE web3.transactions (\n transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction\n from_address character varying(128) NOT NULL, -- address of the sender\n to_address character varying(128), -- address of the receiver (can be null for contract deployment)\n value numeric(38,14) NOT NULL, -- value transferred\n gas_used integer NOT NULL, -- amount of gas used by the transaction\n gas_price numeric(38,14) NOT NULL, -- price of gas at the time of the transaction\n block_number integer NOT NULL, -- block number containing the transaction\n timestamp timestamp NOT NULL, -- time when the transaction was mined\n input_data text, -- input data of the transaction (can be null)\n status character varying(32) NOT NULL, -- status of the transaction (e.g., success, failed)\n nonce integer NOT NULL, -- nonce of the sender at the time of the transaction\n PRIMARY KEY (transaction_id)\n)\n", "conversations": [{"role": "user", "content": "Find all pairs of transactions where both transactions have the same nonce and from_address, but different transaction_id. Show both transaction IDs, the shared from_address, shared nonce, and their block numbers."}, {"role": "assistant", "content": "SELECT t1.transaction_id AS transaction_id_1, t2.transaction_id AS transaction_id_2, t1.from_address, t1.nonce, t1.block_number AS block_number_1, t2.block_number AS block_number_2\nFROM web3.transactions t1\nJOIN web3.transactions t2\n ON t1.from_address = t2.from_address\n AND t1.nonce = t2.nonce\n AND t1.transaction_id < t2.transaction_id;"}]}