Winboy commited on
Commit
24f1327
·
verified ·
1 Parent(s): 3db0ed8

Upload data.jsonl with huggingface_hub

Browse files
Files changed (1) hide show
  1. data.jsonl +2 -2
data.jsonl CHANGED
@@ -2,7 +2,6 @@
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 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 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 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.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id text PRIMARY KEY, tag_name text, created_at timestamp )\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.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 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": "List the usernames of users who liked the post with ID 'P123'."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id WHERE T2.post_id = 'P123';"}, {"role": "user", "content": "Also, only include those users who have enabled email notifications."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id JOIN social_media.user_settings AS T3 ON T1.user_id = T3.user_id WHERE T2.post_id = 'P123' AND T3.email_notifications_enabled = TRUE;"}, {"role": "user", "content": "Further filter the list to only show users with a public profile."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id JOIN social_media.user_settings AS T3 ON T1.user_id = T3.user_id WHERE T2.post_id = 'P123' AND T3.email_notifications_enabled = TRUE AND T3.private_profile = FALSE;"}, {"role": "user", "content": "Please order the results by username alphabetically."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id JOIN social_media.user_settings AS T3 ON T1.user_id = T3.user_id WHERE T2.post_id = 'P123' AND T3.email_notifications_enabled = TRUE AND T3.private_profile = FALSE ORDER BY T1.username ASC;"}]}
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 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.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 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.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\n", "conversations": [{"role": "user", "content": "List all users who have participated in group conversations created in April 2024, showing their username, conversation ID, and the group name."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, c.conversation_id, c.group_name\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nJOIN social_media.users u ON cp.user_id = u.user_id\nWHERE c.is_group_chat = true\n AND c.created_at >= '2024-04-01' AND c.created_at < '2024-05-01';"}, {"role": "user", "content": "Instead of all users, show only those who joined the group conversation after it was created."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, c.conversation_id, c.group_name\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nJOIN social_media.users u ON cp.user_id = u.user_id\nWHERE c.is_group_chat = true\n AND c.created_at >= '2024-04-01' AND c.created_at < '2024-05-01'\n AND cp.joined_at > c.created_at;"}, {"role": "user", "content": "I only care about group conversations where the group name contains the word 'Study'."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, c.conversation_id, c.group_name\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nJOIN social_media.users u ON cp.user_id = u.user_id\nWHERE c.is_group_chat = true\n AND c.created_at >= '2024-04-01' AND c.created_at < '2024-05-01'\n AND cp.joined_at > c.created_at\n AND c.group_name ILIKE '%Study%';"}]}
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 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": "I want to get the list of users and their total number of public posts made in the last month, including user_id and post_count."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS post_count\nFROM social_media.posts\nWHERE visibility = 'public'\n AND created_at >= CURRENT_DATE - INTERVAL '1 month'\nGROUP BY user_id;"}, {"role": "user", "content": "Actually, include only users whose email_notifications_enabled is true."}, {"role": "assistant", "content": "SELECT p.user_id, COUNT(*) AS post_count\nFROM social_media.posts p\nJOIN social_media.user_settings u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.created_at >= CURRENT_DATE - INTERVAL '1 month'\n AND u.email_notifications_enabled = true\nGROUP BY p.user_id;"}, {"role": "user", "content": "Also only consider posts that have media_type 'image'."}, {"role": "assistant", "content": "SELECT p.user_id, COUNT(*) AS post_count\nFROM social_media.posts p\nJOIN social_media.user_settings u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.created_at >= CURRENT_DATE - INTERVAL '1 month'\n AND u.email_notifications_enabled = true\n AND p.media_type = 'image'\nGROUP BY p.user_id;"}, {"role": "user", "content": "Order the results by post_count descending and limit to the top 10."}, {"role": "assistant", "content": "SELECT p.user_id, COUNT(*) AS post_count\nFROM social_media.posts p\nJOIN social_media.user_settings u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.created_at >= CURRENT_DATE - INTERVAL '1 month'\n AND u.email_notifications_enabled = true\n AND p.media_type = 'image'\nGROUP BY p.user_id\nORDER BY post_count DESC\nLIMIT 10;"}]}
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.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.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": "List all messages that haven’t triggered any notification; show message_id, sender_user_id, and sent_at."}, {"role": "assistant", "content": "SELECT m.message_id, m.sender_user_id, m.sent_at\nFROM social_media.messages AS m\nLEFT JOIN social_media.notifications AS n\n ON n.target_entity_type = 'message'\n AND n.target_entity_id = m.message_id\nWHERE n.notification_id IS NULL;"}, {"role": "user", "content": "Actually, only include those sent before '2024-06-01'."}, {"role": "assistant", "content": "SELECT m.message_id, m.sender_user_id, m.sent_at\nFROM social_media.messages AS m\nLEFT JOIN social_media.notifications AS n\n ON n.target_entity_type = 'message'\n AND n.target_entity_id = m.message_id\nWHERE n.notification_id IS NULL\n AND m.sent_at < '2024-06-01';"}]}
6
  {"system": "You are an expert in writing database language. You can write a corresponding database 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.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 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.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the post ID and hashtags for all posts containing the word 'conference' in their content."}, {"role": "assistant", "content": "SELECT p.post_id, h.hashtag_id, h.tag_name\nFROM social_media.posts p\nJOIN social_media.post_hashtags ph ON p.post_id = ph.post_id\nJOIN social_media.hashtags h ON ph.hashtag_id = h.hashtag_id\nWHERE p.content ILIKE '%conference%';"}]}
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 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 )\n", "conversations": [{"role": "user", "content": "Count how many follow relationships were created in June 2024."}, {"role": "assistant", "content": "SELECT COUNT(follow_id) FROM social_media.follows WHERE created_at >= '2024-06-01' AND created_at < '2024-07-01';"}]}
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 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 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.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": "I want to know the usernames of users who have followed more than three different people, along with the date they created their accounts."}, {"role": "assistant", "content": "SELECT u.username, u.created_at, COUNT(DISTINCT f.following_user_id) AS following_count\nFROM social_media.users u\nJOIN social_media.follows f ON u.user_id = f.follower_user_id\nGROUP BY u.user_id, u.username, u.created_at\nHAVING COUNT(DISTINCT f.following_user_id) > 3;"}, {"role": "user", "content": "Also include the usernames of up to two users they are following for each user in the result."}, {"role": "assistant", "content": "SELECT u.username AS follower_username, u.created_at, uf.username AS following_username\nFROM social_media.users u\nJOIN social_media.follows f ON u.user_id = f.follower_user_id\nJOIN social_media.users uf ON f.following_user_id = uf.user_id\nWHERE u.user_id IN (\n SELECT f1.follower_user_id\n FROM social_media.follows f1\n GROUP BY f1.follower_user_id\n HAVING COUNT(DISTINCT f1.following_user_id) > 3\n)\nORDER BY u.username, f.created_at\nLIMIT 2;"}, {"role": "user", "content": "Can you instead provide all usernames they follow, not just two, and include the follow creation date as well?"}, {"role": "assistant", "content": "SELECT u.username AS follower_username, u.created_at AS follower_created_at, uf.username AS following_username, f.created_at AS follow_created_at\nFROM social_media.users u\nJOIN social_media.follows f ON u.user_id = f.follower_user_id\nJOIN social_media.users uf ON f.following_user_id = uf.user_id\nWHERE u.user_id IN (\n SELECT f1.follower_user_id\n FROM social_media.follows f1\n GROUP BY f1.follower_user_id\n HAVING COUNT(DISTINCT f1.following_user_id) > 3\n)\nORDER BY u.username, f.created_at;"}]}
@@ -64,6 +63,7 @@
64
  {"system": "You are an expert in writing database language. You can write a corresponding database 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;"}]}
65
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 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 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 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 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 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 (\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_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, 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 (\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_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 varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\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": "List the ERC20 tokens (from token_metas) with exactly 6 decimals. Show their symbol, contract_address, and name."}, {"role": "assistant", "content": "SELECT symbol, contract_address, name FROM token_metas WHERE is_erc20 = 1 AND decimals = 6;"}, {"role": "user", "content": "Can you also include the total current supply for each token?"}, {"role": "assistant", "content": "SELECT symbol, contract_address, name, total_supply FROM token_metas WHERE is_erc20 = 1 AND decimals = 6;"}, {"role": "user", "content": "Now, join with token_prices_latest to also include the latest price for each token."}, {"role": "assistant", "content": "SELECT tm.symbol, tm.contract_address, tm.name, tm.total_supply, tpl.price AS latest_price\nFROM token_metas tm\nJOIN token_prices_latest tpl ON tm.contract_address = tpl.address AND tpl.blockchain = 'Ethereum'\nWHERE tm.is_erc20 = 1 AND tm.decimals = 6;"}, {"role": "user", "content": "Only include tokens where the latest price is between 0.5 and 2.0 USD, and limit the result to the top 5 tokens by price descending."}, {"role": "assistant", "content": "SELECT tm.symbol, tm.contract_address, tm.name, tm.total_supply, tpl.price AS latest_price\nFROM token_metas tm\nJOIN token_prices_latest tpl ON tm.contract_address = tpl.address AND tpl.blockchain = 'Ethereum'\nWHERE tm.is_erc20 = 1 AND tm.decimals = 6 AND tpl.price BETWEEN 0.5 AND 2.0\nORDER BY tpl.price DESC\nLIMIT 5;"}]}
66
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 (\n session_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game session\n player_id uuid NOT NULL, -- FK linking to the players table\n game_id uuid NOT NULL, -- FK linking to the games table\n server_id uuid, -- FK linking to the servers table (nullable for single-player)\n start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the session began\n end_time timestamp with time zone, -- when the session ended (null if ongoing)\n duration_seconds integer, -- calculated duration of the session in seconds\n score integer, -- player's score for the session, if applicable\n session_data jsonb, -- flexible field for session-specific info (e.g., map played, character used)\n PRIMARY KEY (session_id)\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id),\n -- FOREIGN KEY (server_id) REFERENCES gaming_technology.servers(server_id)\n)\n", "conversations": [{"role": "user", "content": "Find the date (calendar day) with the highest total number of game sessions. Show the date and the total session count."}, {"role": "assistant", "content": "SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions\nFROM gaming_technology.game_sessions\nGROUP BY session_date\nORDER BY total_sessions DESC\nLIMIT 1;"}, {"role": "user", "content": "Also include the day with the second highest session count."}, {"role": "assistant", "content": "SELECT session_date, total_sessions FROM (\n SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY session_date\n) ranked\nWHERE rn <= 2\nORDER BY total_sessions DESC;"}, {"role": "user", "content": "Can you also add the total score across all sessions for each of those days?"}, {"role": "assistant", "content": "SELECT session_date, total_sessions, total_score FROM (\n SELECT CAST(start_time AS DATE) AS session_date,\n COUNT(*) AS total_sessions,\n SUM(score) AS total_score,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY session_date\n) ranked\nWHERE rn <= 2\nORDER BY total_sessions DESC;"}, {"role": "user", "content": "I got an error that session_date is not found, can you fix this SQL?"}, {"role": "assistant", "content": "SELECT sub.session_date, sub.total_sessions, sub.total_score FROM (\n SELECT CAST(start_time AS DATE) AS session_date,\n COUNT(*) AS total_sessions,\n SUM(score) AS total_score,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY CAST(start_time AS DATE)\n) AS sub\nWHERE sub.rn <= 2\nORDER BY sub.total_sessions DESC;"}]}
 
67
  {"system": "You are an expert in writing database language. You can write a corresponding database 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, 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, name.text, country.text, founded_year.integer, website.text, created_at.timestamptz )\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.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, 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 usernames and registration dates for all players from 'Canada'."}, {"role": "assistant", "content": "SELECT username, registration_date FROM gaming_technology.players WHERE country_code = 'Canada';"}, {"role": "user", "content": "Now, only show players from Canada who registered after January 1st, 2023."}, {"role": "assistant", "content": "SELECT username, registration_date FROM gaming_technology.players WHERE country_code = 'Canada' AND registration_date > '2023-01-01';"}]}
68
  {"system": "You are an expert in writing database language. You can write a corresponding database 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.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) )\n", "conversations": [{"role": "user", "content": "Retrieve the title and release_date of all games on the 'PC' platform."}, {"role": "assistant", "content": "SELECT title, release_date\nFROM gaming_technology.games\nWHERE platform = 'PC';"}, {"role": "user", "content": "Now exclude any games released before 2018."}, {"role": "assistant", "content": "SELECT title, release_date\nFROM gaming_technology.games\nWHERE platform = 'PC'\n AND release_date >= '2018-01-01';"}, {"role": "user", "content": "Also sort the results by release_date in ascending order."}, {"role": "assistant", "content": "SELECT title, release_date\nFROM gaming_technology.games\nWHERE platform = 'PC'\n AND release_date >= '2018-01-01'\nORDER BY release_date ASC;"}]}
69
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 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) )\n", "conversations": [{"role": "user", "content": "I need to list all pairs of in-game items in the same game where one item is Epic and the other is Legendary, showing game_id, epic_item, and legendary_item."}, {"role": "assistant", "content": "SELECT a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary';"}, {"role": "user", "content": "Actually, only include pairs where both items have cost_amount greater than 100."}, {"role": "assistant", "content": "SELECT a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary'\n AND a.cost_amount > 100\n AND b.cost_amount > 100;"}, {"role": "user", "content": "Also, ensure each pair appears only once and avoid reversed duplicates."}, {"role": "assistant", "content": "SELECT DISTINCT\n LEAST(a.item_id::text, b.item_id::text) AS item1_id,\n GREATEST(a.item_id::text, b.item_id::text) AS item2_id,\n a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary'\n AND a.cost_amount > 100\n AND b.cost_amount > 100;"}, {"role": "user", "content": "Finally, order the results by game_id ascending."}, {"role": "assistant", "content": "SELECT DISTINCT\n LEAST(a.item_id::text, b.item_id::text) AS item1_id,\n GREATEST(a.item_id::text, b.item_id::text) AS item2_id,\n a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary'\n AND a.cost_amount > 100\n AND b.cost_amount > 100\nORDER BY a.game_id ASC;"}]}
@@ -247,4 +247,4 @@
247
  {"system": "You are an expert in writing database language. You can write a corresponding database 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.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.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.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.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 ( 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": "Which patients have a primary insurance policy and are subscribed to a plan provided by 'Cigna'? List patient ID, full name, policy number, plan ID, and insurance provider."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna';"}, {"role": "user", "content": "Additionally, only show results where the policy has not expired yet."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna' AND (pi.expiration_date IS NULL OR pi.expiration_date >= CURRENT_DATE);"}]}
248
  {"system": "You are an expert in writing database language. You can write a corresponding database 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": "I need a list showing the name of each law firm and the full name of every lawyer employed by that firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.firm_id = T2.firm_id;"}]}
249
  {"system": "You are an expert in writing database language. You can write a corresponding database 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": "Show me all customers (customer_id, first_name, last_name, email) who were born after 1985 (date_of_birth > '1985-12-31') and have an email address ending with '@yahoo.com', along with their city and state information."}, {"role": "assistant", "content": "SELECT customer_id, first_name, last_name, email, city, state FROM financial_services.customers WHERE date_of_birth > '1985-12-31' AND email LIKE '%@yahoo.com';"}]}
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 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 )\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.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": "For each insurance product, can you list its product name, the number of unique agents who have sold policies for that product, and the total premium paid across those policies?"}, {"role": "assistant", "content": "SELECT ip.product_name, COUNT(DISTINCT a.agent_id) AS agent_count, SUM(pp.amount_paid) AS total_premium_paid\nFROM insurance.insurance_products ip\nJOIN insurance.claims c ON c.policy_id IN (\n SELECT policy_id FROM insurance.premium_payments WHERE policy_id IS NOT NULL\n)\nJOIN insurance.premium_payments pp ON pp.policy_id = c.policy_id\nJOIN insurance.agents a ON a.agent_id = (\n SELECT agent_id FROM insurance.agents WHERE agent_id = a.agent_id\n)\nWHERE ip.product_id = (\n SELECT policy_id FROM insurance.claims WHERE policy_id = c.policy_id\n)\nGROUP BY ip.product_name"}, {"role": "user", "content": "Actually, can you also include only insurance products that are currently active?"}, {"role": "assistant", "content": "SELECT ip.product_name, COUNT(DISTINCT a.agent_id) AS agent_count, SUM(pp.amount_paid) AS total_premium_paid\nFROM insurance.insurance_products ip\nJOIN insurance.claims c ON c.policy_id IN (\n SELECT policy_id FROM insurance.premium_payments WHERE policy_id IS NOT NULL\n)\nJOIN insurance.premium_payments pp ON pp.policy_id = c.policy_id\nJOIN insurance.agents a ON a.agent_id = (\n SELECT agent_id FROM insurance.agents WHERE agent_id = a.agent_id\n)\nWHERE ip.is_active = TRUE\nAND ip.product_id = (\n SELECT policy_id FROM insurance.claims WHERE policy_id = c.policy_id\n)\nGROUP BY ip.product_name"}, {"role": "user", "content": "It seems like the SQL isn't working; there is no direct link between products and the policies. Is it possible to just list the number of agents who handled claims related to each insurance product, given these tables?"}, {"role": "assistant", "content": "SELECT ip.product_name, COUNT(DISTINCT c.claim_handler_id) AS agent_count\nFROM insurance.insurance_products ip\nJOIN insurance.claims c ON ip.product_id = c.policy_id\nGROUP BY ip.product_name"}]}
 
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 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 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 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.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp )\nCREATE TABLE social_media.hashtags ( hashtag_id text PRIMARY KEY, tag_name text, created_at timestamp )\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.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 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": "List the usernames of users who liked the post with ID 'P123'."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id WHERE T2.post_id = 'P123';"}, {"role": "user", "content": "Also, only include those users who have enabled email notifications."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id JOIN social_media.user_settings AS T3 ON T1.user_id = T3.user_id WHERE T2.post_id = 'P123' AND T3.email_notifications_enabled = TRUE;"}, {"role": "user", "content": "Further filter the list to only show users with a public profile."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id JOIN social_media.user_settings AS T3 ON T1.user_id = T3.user_id WHERE T2.post_id = 'P123' AND T3.email_notifications_enabled = TRUE AND T3.private_profile = FALSE;"}, {"role": "user", "content": "Please order the results by username alphabetically."}, {"role": "assistant", "content": "SELECT DISTINCT T1.username FROM social_media.users AS T1 JOIN social_media.likes AS T2 ON T1.user_id = T2.user_id JOIN social_media.user_settings AS T3 ON T1.user_id = T3.user_id WHERE T2.post_id = 'P123' AND T3.email_notifications_enabled = TRUE AND T3.private_profile = FALSE ORDER BY T1.username ASC;"}]}
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 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.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 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.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\n", "conversations": [{"role": "user", "content": "List all users who have participated in group conversations created in April 2024, showing their username, conversation ID, and the group name."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, c.conversation_id, c.group_name\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nJOIN social_media.users u ON cp.user_id = u.user_id\nWHERE c.is_group_chat = true\n AND c.created_at >= '2024-04-01' AND c.created_at < '2024-05-01';"}, {"role": "user", "content": "Instead of all users, show only those who joined the group conversation after it was created."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, c.conversation_id, c.group_name\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nJOIN social_media.users u ON cp.user_id = u.user_id\nWHERE c.is_group_chat = true\n AND c.created_at >= '2024-04-01' AND c.created_at < '2024-05-01'\n AND cp.joined_at > c.created_at;"}, {"role": "user", "content": "I only care about group conversations where the group name contains the word 'Study'."}, {"role": "assistant", "content": "SELECT DISTINCT u.username, c.conversation_id, c.group_name\nFROM social_media.conversations c\nJOIN social_media.conversation_participants cp ON c.conversation_id = cp.conversation_id\nJOIN social_media.users u ON cp.user_id = u.user_id\nWHERE c.is_group_chat = true\n AND c.created_at >= '2024-04-01' AND c.created_at < '2024-05-01'\n AND cp.joined_at > c.created_at\n AND c.group_name ILIKE '%Study%';"}]}
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 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": "I want to get the list of users and their total number of public posts made in the last month, including user_id and post_count."}, {"role": "assistant", "content": "SELECT user_id, COUNT(*) AS post_count\nFROM social_media.posts\nWHERE visibility = 'public'\n AND created_at >= CURRENT_DATE - INTERVAL '1 month'\nGROUP BY user_id;"}, {"role": "user", "content": "Actually, include only users whose email_notifications_enabled is true."}, {"role": "assistant", "content": "SELECT p.user_id, COUNT(*) AS post_count\nFROM social_media.posts p\nJOIN social_media.user_settings u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.created_at >= CURRENT_DATE - INTERVAL '1 month'\n AND u.email_notifications_enabled = true\nGROUP BY p.user_id;"}, {"role": "user", "content": "Also only consider posts that have media_type 'image'."}, {"role": "assistant", "content": "SELECT p.user_id, COUNT(*) AS post_count\nFROM social_media.posts p\nJOIN social_media.user_settings u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.created_at >= CURRENT_DATE - INTERVAL '1 month'\n AND u.email_notifications_enabled = true\n AND p.media_type = 'image'\nGROUP BY p.user_id;"}, {"role": "user", "content": "Order the results by post_count descending and limit to the top 10."}, {"role": "assistant", "content": "SELECT p.user_id, COUNT(*) AS post_count\nFROM social_media.posts p\nJOIN social_media.user_settings u\n ON p.user_id = u.user_id\nWHERE p.visibility = 'public'\n AND p.created_at >= CURRENT_DATE - INTERVAL '1 month'\n AND u.email_notifications_enabled = true\n AND p.media_type = 'image'\nGROUP BY p.user_id\nORDER BY post_count DESC\nLIMIT 10;"}]}
 
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 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.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 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.conversations ( conversation_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_message_at timestamp, is_group_chat boolean NOT NULL DEFAULT false, group_name character varying(100), PRIMARY KEY (conversation_id) )\nCREATE TABLE social_media.conversation_participants ( participant_id text PRIMARY KEY, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )\n", "conversations": [{"role": "user", "content": "Show the post ID and hashtags for all posts containing the word 'conference' in their content."}, {"role": "assistant", "content": "SELECT p.post_id, h.hashtag_id, h.tag_name\nFROM social_media.posts p\nJOIN social_media.post_hashtags ph ON p.post_id = ph.post_id\nJOIN social_media.hashtags h ON ph.hashtag_id = h.hashtag_id\nWHERE p.content ILIKE '%conference%';"}]}
6
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 )\n", "conversations": [{"role": "user", "content": "Count how many follow relationships were created in June 2024."}, {"role": "assistant", "content": "SELECT COUNT(follow_id) FROM social_media.follows WHERE created_at >= '2024-06-01' AND created_at < '2024-07-01';"}]}
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 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 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.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": "I want to know the usernames of users who have followed more than three different people, along with the date they created their accounts."}, {"role": "assistant", "content": "SELECT u.username, u.created_at, COUNT(DISTINCT f.following_user_id) AS following_count\nFROM social_media.users u\nJOIN social_media.follows f ON u.user_id = f.follower_user_id\nGROUP BY u.user_id, u.username, u.created_at\nHAVING COUNT(DISTINCT f.following_user_id) > 3;"}, {"role": "user", "content": "Also include the usernames of up to two users they are following for each user in the result."}, {"role": "assistant", "content": "SELECT u.username AS follower_username, u.created_at, uf.username AS following_username\nFROM social_media.users u\nJOIN social_media.follows f ON u.user_id = f.follower_user_id\nJOIN social_media.users uf ON f.following_user_id = uf.user_id\nWHERE u.user_id IN (\n SELECT f1.follower_user_id\n FROM social_media.follows f1\n GROUP BY f1.follower_user_id\n HAVING COUNT(DISTINCT f1.following_user_id) > 3\n)\nORDER BY u.username, f.created_at\nLIMIT 2;"}, {"role": "user", "content": "Can you instead provide all usernames they follow, not just two, and include the follow creation date as well?"}, {"role": "assistant", "content": "SELECT u.username AS follower_username, u.created_at AS follower_created_at, uf.username AS following_username, f.created_at AS follow_created_at\nFROM social_media.users u\nJOIN social_media.follows f ON u.user_id = f.follower_user_id\nJOIN social_media.users uf ON f.following_user_id = uf.user_id\nWHERE u.user_id IN (\n SELECT f1.follower_user_id\n FROM social_media.follows f1\n GROUP BY f1.follower_user_id\n HAVING COUNT(DISTINCT f1.following_user_id) > 3\n)\nORDER BY u.username, f.created_at;"}]}
 
63
  {"system": "You are an expert in writing database language. You can write a corresponding database 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;"}]}
64
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 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 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 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 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 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 (\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_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, 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 (\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_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 varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )\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": "List the ERC20 tokens (from token_metas) with exactly 6 decimals. Show their symbol, contract_address, and name."}, {"role": "assistant", "content": "SELECT symbol, contract_address, name FROM token_metas WHERE is_erc20 = 1 AND decimals = 6;"}, {"role": "user", "content": "Can you also include the total current supply for each token?"}, {"role": "assistant", "content": "SELECT symbol, contract_address, name, total_supply FROM token_metas WHERE is_erc20 = 1 AND decimals = 6;"}, {"role": "user", "content": "Now, join with token_prices_latest to also include the latest price for each token."}, {"role": "assistant", "content": "SELECT tm.symbol, tm.contract_address, tm.name, tm.total_supply, tpl.price AS latest_price\nFROM token_metas tm\nJOIN token_prices_latest tpl ON tm.contract_address = tpl.address AND tpl.blockchain = 'Ethereum'\nWHERE tm.is_erc20 = 1 AND tm.decimals = 6;"}, {"role": "user", "content": "Only include tokens where the latest price is between 0.5 and 2.0 USD, and limit the result to the top 5 tokens by price descending."}, {"role": "assistant", "content": "SELECT tm.symbol, tm.contract_address, tm.name, tm.total_supply, tpl.price AS latest_price\nFROM token_metas tm\nJOIN token_prices_latest tpl ON tm.contract_address = tpl.address AND tpl.blockchain = 'Ethereum'\nWHERE tm.is_erc20 = 1 AND tm.decimals = 6 AND tpl.price BETWEEN 0.5 AND 2.0\nORDER BY tpl.price DESC\nLIMIT 5;"}]}
65
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 (\n session_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game session\n player_id uuid NOT NULL, -- FK linking to the players table\n game_id uuid NOT NULL, -- FK linking to the games table\n server_id uuid, -- FK linking to the servers table (nullable for single-player)\n start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the session began\n end_time timestamp with time zone, -- when the session ended (null if ongoing)\n duration_seconds integer, -- calculated duration of the session in seconds\n score integer, -- player's score for the session, if applicable\n session_data jsonb, -- flexible field for session-specific info (e.g., map played, character used)\n PRIMARY KEY (session_id)\n -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id),\n -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id),\n -- FOREIGN KEY (server_id) REFERENCES gaming_technology.servers(server_id)\n)\n", "conversations": [{"role": "user", "content": "Find the date (calendar day) with the highest total number of game sessions. Show the date and the total session count."}, {"role": "assistant", "content": "SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions\nFROM gaming_technology.game_sessions\nGROUP BY session_date\nORDER BY total_sessions DESC\nLIMIT 1;"}, {"role": "user", "content": "Also include the day with the second highest session count."}, {"role": "assistant", "content": "SELECT session_date, total_sessions FROM (\n SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY session_date\n) ranked\nWHERE rn <= 2\nORDER BY total_sessions DESC;"}, {"role": "user", "content": "Can you also add the total score across all sessions for each of those days?"}, {"role": "assistant", "content": "SELECT session_date, total_sessions, total_score FROM (\n SELECT CAST(start_time AS DATE) AS session_date,\n COUNT(*) AS total_sessions,\n SUM(score) AS total_score,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY session_date\n) ranked\nWHERE rn <= 2\nORDER BY total_sessions DESC;"}, {"role": "user", "content": "I got an error that session_date is not found, can you fix this SQL?"}, {"role": "assistant", "content": "SELECT sub.session_date, sub.total_sessions, sub.total_score FROM (\n SELECT CAST(start_time AS DATE) AS session_date,\n COUNT(*) AS total_sessions,\n SUM(score) AS total_score,\n ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS rn\n FROM gaming_technology.game_sessions\n GROUP BY CAST(start_time AS DATE)\n) AS sub\nWHERE sub.rn <= 2\nORDER BY sub.total_sessions DESC;"}]}
66
+ {"system": "You are an expert in writing database language. You can write a corresponding database 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 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 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 (\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 ( 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.timestamptz )\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": "Give me each server's name, the region, and the maximum number of players that have been connected at once."}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, MAX(s.current_players) AS max_players_seen\nFROM gaming_technology.servers s\nGROUP BY s.server_id, s.server_name, s.region;"}, {"role": "user", "content": "Could you also include the associated game title for each server?"}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, g.title AS game_title, MAX(s.current_players) AS max_players_seen\nFROM gaming_technology.servers s\nJOIN gaming_technology.games g ON s.game_id = g.game_id\nGROUP BY s.server_id, s.server_name, s.region, g.title;"}, {"role": "user", "content": "Now, can you show only servers where the max number of players ever connected exceeded 20?"}, {"role": "assistant", "content": "SELECT s.server_id, s.server_name, s.region, g.title AS game_title, MAX(s.current_players) AS max_players_seen\nFROM gaming_technology.servers s\nJOIN gaming_technology.games g ON s.game_id = g.game_id\nGROUP BY s.server_id, s.server_name, s.region, g.title\nHAVING MAX(s.current_players) > 20;"}]}
67
  {"system": "You are an expert in writing database language. You can write a corresponding database 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, 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, name.text, country.text, founded_year.integer, website.text, created_at.timestamptz )\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.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, 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 usernames and registration dates for all players from 'Canada'."}, {"role": "assistant", "content": "SELECT username, registration_date FROM gaming_technology.players WHERE country_code = 'Canada';"}, {"role": "user", "content": "Now, only show players from Canada who registered after January 1st, 2023."}, {"role": "assistant", "content": "SELECT username, registration_date FROM gaming_technology.players WHERE country_code = 'Canada' AND registration_date > '2023-01-01';"}]}
68
  {"system": "You are an expert in writing database language. You can write a corresponding database 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.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) )\n", "conversations": [{"role": "user", "content": "Retrieve the title and release_date of all games on the 'PC' platform."}, {"role": "assistant", "content": "SELECT title, release_date\nFROM gaming_technology.games\nWHERE platform = 'PC';"}, {"role": "user", "content": "Now exclude any games released before 2018."}, {"role": "assistant", "content": "SELECT title, release_date\nFROM gaming_technology.games\nWHERE platform = 'PC'\n AND release_date >= '2018-01-01';"}, {"role": "user", "content": "Also sort the results by release_date in ascending order."}, {"role": "assistant", "content": "SELECT title, release_date\nFROM gaming_technology.games\nWHERE platform = 'PC'\n AND release_date >= '2018-01-01'\nORDER BY release_date ASC;"}]}
69
  {"system": "You are an expert in writing database language. You can write a corresponding database 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 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) )\n", "conversations": [{"role": "user", "content": "I need to list all pairs of in-game items in the same game where one item is Epic and the other is Legendary, showing game_id, epic_item, and legendary_item."}, {"role": "assistant", "content": "SELECT a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary';"}, {"role": "user", "content": "Actually, only include pairs where both items have cost_amount greater than 100."}, {"role": "assistant", "content": "SELECT a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary'\n AND a.cost_amount > 100\n AND b.cost_amount > 100;"}, {"role": "user", "content": "Also, ensure each pair appears only once and avoid reversed duplicates."}, {"role": "assistant", "content": "SELECT DISTINCT\n LEAST(a.item_id::text, b.item_id::text) AS item1_id,\n GREATEST(a.item_id::text, b.item_id::text) AS item2_id,\n a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary'\n AND a.cost_amount > 100\n AND b.cost_amount > 100;"}, {"role": "user", "content": "Finally, order the results by game_id ascending."}, {"role": "assistant", "content": "SELECT DISTINCT\n LEAST(a.item_id::text, b.item_id::text) AS item1_id,\n GREATEST(a.item_id::text, b.item_id::text) AS item2_id,\n a.game_id,\n a.item_name AS epic_item,\n b.item_name AS legendary_item\nFROM gaming_technology.in_game_items a\nJOIN gaming_technology.in_game_items b\n ON a.game_id = b.game_id\nWHERE a.rarity = 'Epic'\n AND b.rarity = 'Legendary'\n AND a.cost_amount > 100\n AND b.cost_amount > 100\nORDER BY a.game_id ASC;"}]}
 
247
  {"system": "You are an expert in writing database language. You can write a corresponding database 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.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.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.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.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 ( 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": "Which patients have a primary insurance policy and are subscribed to a plan provided by 'Cigna'? List patient ID, full name, policy number, plan ID, and insurance provider."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna';"}, {"role": "user", "content": "Additionally, only show results where the policy has not expired yet."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna' AND (pi.expiration_date IS NULL OR pi.expiration_date >= CURRENT_DATE);"}]}
248
  {"system": "You are an expert in writing database language. You can write a corresponding database 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": "I need a list showing the name of each law firm and the full name of every lawyer employed by that firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.firm_id = T2.firm_id;"}]}
249
  {"system": "You are an expert in writing database language. You can write a corresponding database 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": "Show me all customers (customer_id, first_name, last_name, email) who were born after 1985 (date_of_birth > '1985-12-31') and have an email address ending with '@yahoo.com', along with their city and state information."}, {"role": "assistant", "content": "SELECT customer_id, first_name, last_name, email, city, state FROM financial_services.customers WHERE date_of_birth > '1985-12-31' AND email LIKE '%@yahoo.com';"}]}
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 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 )\n", "conversations": [{"role": "user", "content": "List all medical records created by doctor 'doctor_001' for patients who had their last medical record on or after '2024-01-01', including record_id, patient_id, record_date, chief_complaint, and doctor_id."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01';"}, {"role": "user", "content": "Please refine the results to only include records where the 'assessment' field is not null."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01' AND mr.assessment IS NOT NULL;"}, {"role": "user", "content": "I received too many results. Can you only show records where 'treatment_plan' is also not null?"}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01' AND mr.assessment IS NOT NULL AND mr.treatment_plan IS NOT NULL;"}]}