[User] Find projects that have both fundraising records and basic token information. Display the project name, fundraising round name, investment value, and the token's current price.

[Assistant] SELECT T1.project_name, T1.rounds_name, T1.investment_value, T2.price FROM project_fundraising_record AS T1 INNER JOIN token_basic_info AS T2 ON T1.project_name = T2.token_symbol;

[User] Modify the previous query to only include projects with an investment value greater than 500000 and where the token is on the 'BNB' chain.

[Assistant] SELECT T1.project_name, T1.rounds_name, T1.investment_value, T2.price FROM project_fundraising_record AS T1 INNER JOIN token_basic_info AS T2 ON T1.project_name = T2.token_symbol WHERE T1.investment_value > 500000 AND T2.chain = 'BNB';


[User] Show me the wallet ID and address for user 'user_abc'.

[Assistant] SELECT wallet_id, address FROM web3.wallets WHERE user_id = 'user_abc';

[User] Could you sort those wallets by their creation date in descending order?

[Assistant] SELECT wallet_id, address FROM web3.wallets WHERE user_id = 'user_abc' ORDER BY created_at DESC;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )


[User] For the ticker 'doge', what are the different types of activities recorded in the `token_activities_bitcoin` table?

[Assistant] SELECT DISTINCT type FROM token_activities_bitcoin WHERE tick = 'doge'

[User] Show me the amount, from address, and to address for 'mint' activities of 'doge'.

[Assistant] SELECT amt, from_address, to_address FROM token_activities_bitcoin WHERE tick = 'doge' AND type = 'mint'

[User] How many such 'mint' activities are there for 'doge'?

[Assistant] SELECT COUNT(*) FROM token_activities_bitcoin WHERE tick = 'doge' AND type = 'mint'

[User] Now, from the `token_info_bitcoin` table, what is the maximum supply for the 'doge' ticker?

[Assistant] SELECT max_supply FROM token_info_bitcoin WHERE tick = 'doge'

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE erc20_balances_historical ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.integer )
CREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )
CREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )
CREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )
CREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )
CREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )
CREATE TABLE token_info ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )
CREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )
CREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )
CREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )
CREATE TABLE token_activities_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )
CREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )


[User] Provide the contract ID, creator address, and timestamp for all smart contracts created between January 1st, 2022, and December 31st, 2024.

[Assistant] SELECT contract_id, creator_address, timestamp FROM blockchain.smart_contracts WHERE timestamp BETWEEN '2022-01-01' AND '2024-12-31';

[User] Okay, now filter that list to only show the contracts where the code contains the word 'transfer'.

[Assistant] SELECT contract_id, creator_address, timestamp FROM blockchain.smart_contracts WHERE timestamp BETWEEN '2022-01-01' AND '2024-12-31' AND code LIKE '%transfer%';

[User] Finally, from the filtered results, I only want to see the contracts created by '0xFEDCBA9876543210FEDCBA9876543210FEDCBA98'.

[Assistant] SELECT contract_id, creator_address, timestamp FROM blockchain.smart_contracts WHERE timestamp BETWEEN '2022-01-01' AND '2024-12-31' AND code LIKE '%transfer%' AND creator_address = '0xFEDCBA9876543210FEDCBA9876543210FEDCBA98';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.smart_contracts ( contract_id.text, creator_address.text, code.text, timestamp.timestamp )


[User] List smart money addresses, their chain, and profit for those who have incurred a loss. Order the results by the magnitude of the loss (smallest profit value first).

[Assistant] SELECT address, chain, profit FROM smart_money_profit WHERE profit < 0 ORDER BY profit ASC;

[User] From that list, show only the addresses that have a rank worse than 500 (rank number greater than 500).

[Assistant] SELECT address, chain, profit FROM smart_money_profit WHERE profit < 0 AND rank > 500 ORDER BY profit ASC;

[User] Further refine the list to include only addresses on the 'Arbitrum' chain.

[Assistant] SELECT address, chain, profit FROM smart_money_profit WHERE profit < 0 AND rank > 500 AND chain = 'Arbitrum' ORDER BY profit ASC;

[User] Based on the filtered list (loss, rank worse than 500, Arbitrum chain), what is the average profit?

[Assistant] SELECT AVG(profit) FROM smart_money_profit WHERE profit < 0 AND rank > 500 AND chain = 'Arbitrum';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE smart_money_profit ( address character varying(100) NOT NULL, rank INT, profit numeric(38,6), roi numeric(38,2), realized_ratio numeric(38,2), most_profit_token character varying(100), last_trade_time character varying(100), chain character varying(100) )


[User] Show me assets along with their associated 'symbol' metadata value. Assume an assets table with asset_id exists.

[Assistant] SELECT a.asset_id, m.value FROM assets a JOIN metadata m ON a.asset_id = m.asset_id WHERE m.key = 'symbol'

[User] Now, also include the 'name' metadata value for these assets in the same result.

[Assistant] SELECT a.asset_id, m_symbol.value AS symbol, m_name.value AS name FROM assets a LEFT JOIN metadata m_symbol ON a.asset_id = m_symbol.asset_id AND m_symbol.key = 'symbol' LEFT JOIN metadata m_name ON a.asset_id = m_name.asset_id AND m_name.key = 'name'

[User] For assets that have both 'symbol' and 'name' metadata, list the asset ID and the count of *all* metadata entries they have.

[Assistant] SELECT a.asset_id, COUNT(m_all.metadata_id) FROM assets a JOIN metadata m_symbol ON a.asset_id = m_symbol.asset_id AND m_symbol.key = 'symbol' JOIN metadata m_name ON a.asset_id = m_name.asset_id AND m_name.key = 'name' JOIN metadata m_all ON a.asset_id = m_all.asset_id GROUP BY a.asset_id

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.utxos ( utxo_id text PRIMARY KEY, transaction_id text, output_index int, address text, amount numeric, spent boolean )
CREATE TABLE trading_platform.dapps ( dapp_id text PRIMARY KEY, name text, description text, url text )
CREATE TABLE trading_platform.peers ( peer_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )
CREATE TABLE trading_platform.metadata ( metadata_id text PRIMARY KEY, asset_id text, key text, value text )
CREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )


[User] What is the total number of entries in the addresses table and the sum of all balances?

[Assistant] SELECT COUNT(*), SUM(balance) FROM blockchain.addresses;

[User] Instead of the sum, could you show me the average balance and the highest balance recorded?

[Assistant] SELECT AVG(balance), MAX(balance) FROM blockchain.addresses;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.addresses (
    address_id character varying(128) NOT NULL,  -- unique identifier for the address
    public_key text NOT NULL, -- public key associated with the address
    balance numeric(38,14) NOT NULL, -- current balance of the address
    PRIMARY KEY (address_id)
)


[User] List all distinct project names found in the fundraising records.

[Assistant] SELECT DISTINCT project_name FROM project_fundraising_record;

[User] For each project, count how many fundraising rounds are recorded.

[Assistant] SELECT project_name, COUNT(*) FROM project_fundraising_record GROUP BY project_name;

[User] Only show projects that have more than one fundraising round.

[Assistant] SELECT project_name, COUNT(*) FROM project_fundraising_record GROUP BY project_name HAVING COUNT(*) > 1;

[User] And show the total investment value for these projects.

[Assistant] SELECT project_name, COUNT(*), SUM(investment_value) FROM project_fundraising_record GROUP BY project_name HAVING COUNT(*) > 1;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
 "CREATE TABLE project_fundraising_record (",
    "id character varying(32) NOT NULL,  -- fundraising record id",
    "project_id character varying(32) NOT NULL, -- the invested project's id",
    "project_name character varying(128) NOT NULL, -- name of the invested project",
    "rounds_name character varying(32), -- name of the fundraising round",
    "investment_value numeric(38,14), -- amount of the fundraising in USD",
    "investment_date character varying(128), -- the date of the investment happened",
    "introduction character varying(128), -- the introduction of the invested project",
    "valuation numeric(38,14), -- the valuation of the project in USD when invested",


[User] List all users and the count of wallets they own.

[Assistant] SELECT u.username, COUNT(w.wallet_id) AS wallet_count FROM blockchain.users u JOIN blockchain.wallets w ON u.user_id = w.user_id GROUP BY u.user_id, u.username;

[User] Filter the previous list to only include users who own more than 2 wallets.

[Assistant] SELECT u.username, COUNT(w.wallet_id) AS wallet_count FROM blockchain.users u JOIN blockchain.wallets w ON u.user_id = w.user_id GROUP BY u.user_id, u.username HAVING COUNT(w.wallet_id) > 2;

[User] Now, for those users, also include the total sum of balances across all addresses associated with their wallets.

[Assistant] SELECT u.username, COUNT(DISTINCT w.wallet_id) AS wallet_count, SUM(a.balance) AS total_balance FROM blockchain.users u JOIN blockchain.wallets w ON u.user_id = w.user_id JOIN blockchain.addresses a ON w.address_id = a.address_id GROUP BY u.user_id, u.username HAVING COUNT(DISTINCT w.wallet_id) > 2;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.addresses ( address_id character varying(128) NOT NULL, public_key text NOT NULL, balance numeric(38,14) NOT NULL, PRIMARY KEY (address_id) )
CREATE TABLE blockchain.nodes ( node_id character varying(64) NOT NULL, ip_address character varying(15) NOT NULL, port integer NOT NULL, last_seen timestamp NOT NULL, PRIMARY KEY (node_id) )
CREATE TABLE blockchain.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address_id character varying(128) NOT NULL, private_key text NOT NULL, PRIMARY KEY (wallet_id) )
CREATE TABLE blockchain.users ( user_id character varying(64) NOT NULL, username character varying(128) NOT NULL, email character varying(128) NOT NULL, password_hash text NOT NULL, PRIMARY KEY (user_id) )


[User] List all assets that have 'category' metadata. Show the asset ID and the value of the 'category'.

[Assistant] SELECT asset_id, value AS category FROM trading_platform.metadata WHERE key = 'category';

[User] Refine this to only show assets where the 'category' is either 'Crypto' or 'Fiat'.

[Assistant] SELECT asset_id, value AS category FROM trading_platform.metadata WHERE key = 'category' AND value IN ('Crypto', 'Fiat');

[User] For each of these assets categorized as 'Crypto' or 'Fiat', how many total metadata entries (of any key) exist?

[Assistant] WITH FilteredAssets AS (SELECT asset_id FROM trading_platform.metadata WHERE key = 'category' AND value IN ('Crypto', 'Fiat')) SELECT fa.asset_id, COUNT(m.metadata_id) AS total_metadata_entries FROM FilteredAssets fa JOIN trading_platform.metadata m ON fa.asset_id = m.asset_id GROUP BY fa.asset_id;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.users (
    user_id character varying(64) NOT NULL,  -- unique identifier for the user
    username character varying(128) NOT NULL, -- username of the user
    email character varying(128) NOT NULL, -- email address of the user
    password_hash text NOT NULL, -- hashed password of the user
    created_at timestamp NOT NULL, -- time when the user account was created
    PRIMARY KEY (user_id)
)
CREATE TABLE trading_platform.metadata (
    metadata_id character varying(64) NOT NULL,  -- unique identifier for the metadata
    asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with
    key character varying(128) NOT NULL, -- key of the metadata
    value text NOT NULL, -- value of the metadata
    PRIMARY KEY (metadata_id)
)
CREATE TABLE trading_platform.notifications (
    notification_id character varying(64) NOT NULL,  -- unique identifier for the notification
    user_id character varying(64) NOT NULL, -- identifier of the user receiving the notification
    message text NOT NULL, -- message of the notification
    sent_at timestamp NOT NULL, -- time when the notification was sent
    read_at timestamp, -- time when the notification was read
    PRIMARY KEY (notification_id)
)


[User] Show the symbol and current balance for all ERC20 tokens held by wallet '0x...abc'.

[Assistant] SELECT T2.symbol, T1.amount FROM erc20_balances AS T1 INNER JOIN token_metas AS T2 ON T1.contract_address = T2.contract_address WHERE T1.wallet_address = '0x...abc' AND T2.is_erc20 = 1;

[User] Filter the results to only include tokens where the balance exceeds a certain amount, say '1000000000000000000'.

[Assistant] SELECT T2.symbol, T1.amount FROM erc20_balances AS T1 INNER JOIN token_metas AS T2 ON T1.contract_address = T2.contract_address WHERE T1.wallet_address = '0x...abc' AND T2.is_erc20 = 1 AND T1.amount > '1000000000000000000';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash text, transaction_index bigint, from_address text, contract_address text, symbol text, total_supply text, name text, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info text, pk integer )
CREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text )
CREATE TABLE erc20_balances ( block_number bigint, contract_address text, wallet_address text, amount text, pk text )
CREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )
CREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )
CREATE TABLE nft_holder_historical ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk integer )
CREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )
CREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer )
CREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )
CREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )
CREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )
CREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text )
CREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )
CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )
CREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )
CREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal )
CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )


[User] Show me tokens that have recorded smart money inflows. For these tokens, list the token symbol, the current price from the basic info table, and the total sum of USD values from all smart money inflows recorded for that token.

[Assistant] SELECT tbi.token_symbol, tbi.price, SUM(smti.usd_value) FROM token_basic_info tbi JOIN smart_money_token_inflow smti ON tbi.token_address = smti.token_address GROUP BY tbi.token_symbol, tbi.price;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )
CREATE TABLE cex_token_balance ( snapshot_time.text, chain.text, address.text, exchange.text, token_address.text, token_symbol.text, balance.numeric, usd_value.numeric, price.numeric )
CREATE TABLE smart_money_token_inflow ( token_address.text, token_symbol.text, token_amount.numeric, usd_value.numeric, avg_price.numeric, type.numeric, address_amount.numeric, narrative.text, chain.text )


[User] Display the details of all UTXOs with a 'spent' status of false.

[Assistant] SELECT utxo_id, transaction_id, output_index, address, amount FROM trading_platform.utxos WHERE spent = false;

[User] For the unspent UTXOs, calculate the sum of amounts for each distinct address.

[Assistant] SELECT address, SUM(amount) FROM trading_platform.utxos WHERE spent = false GROUP BY address;

[User] Filter this list to only show addresses where the total unspent amount is greater than 1000.

[Assistant] SELECT address, SUM(amount) FROM trading_platform.utxos WHERE spent = false GROUP BY address HAVING SUM(amount) > 1000;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.users ( user_id text, username text, email text, password_hash text, created_at timestamp )
CREATE TABLE trading_platform.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )
CREATE TABLE trading_platform.orders ( order_id text, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )
CREATE TABLE trading_platform.assets ( asset_id text, name text, symbol text, type text )
CREATE TABLE trading_platform.utxos ( utxo_id text, transaction_id text, output_index integer, address text, amount numeric, spent boolean )
CREATE TABLE trading_platform.dapps ( dapp_id text, name text, description text, url text )
CREATE TABLE trading_platform.peers ( peer_id text, ip_address text, port integer, last_seen timestamp )
CREATE TABLE trading_platform.metadata ( metadata_id text, asset_id text, key text, value text )
CREATE TABLE trading_platform.kyc_audit ( kyc_audit_id text, user_id text, status text, reviewed_at timestamp )


[User] What are the latest prices for tokens with symbol 'USDT'?

[Assistant] SELECT * FROM token_prices_latest WHERE symbol = 'USDT';

[User] Now show me the historical prices for 'USDT' from the last 7 days.

[Assistant] SELECT * FROM token_prices WHERE symbol = 'USDT' AND timestamp >= CURRENT_TIMESTAMP - INTERVAL '7' DAY;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )
CREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar )
CREATE TABLE erc20_balances ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk varchar )
CREATE TABLE nft_holders ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk varchar )
CREATE TABLE nft_holder_historical ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk integer )
CREATE TABLE sui_coins ( object_id varchar, status varchar, coin_type varchar, balance varchar, owner varchar )
CREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar )
CREATE TABLE nft_metadata ( blockchain varchar, contract_address varchar, token_id varchar, contract_name varchar, erc_type varchar, amount bigint, minter varchar, owner varchar, mint_block_number bigint, mint_time bigint, mint_transaction_hash varchar, mint_price varchar, token_uri varchar, metadata varchar, name varchar, image_uri varchar, traits varchar, updated_at bigint, status varchar, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )
CREATE TABLE nft_collections ( blockchain varchar, contract_address varchar, name varchar, symbol varchar, deploy_block_number bigint, deploy_block_time bigint, erc_type varchar, owner varchar, traits varchar, description varchar, slug varchar, media_info varchar, image_url varchar, banner_image_url varchar, updated_at bigint, banner varchar, token_count bigint, floor_price varchar, floor_price_symbol varchar, floor_price_contract varchar, pk integer )
CREATE TABLE token_prices ( uuid varchar, blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )
CREATE TABLE token_prices_latest ( blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )
CREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar, pk integer )
CREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )
CREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )
CREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )
CREATE TABLE mud_holesky_redstone ( address varchar, table_id varchar, key_bytes varchar, key0 varchar, key1 varchar, static_data varchar, encoded_lengths varchar, dynamic_data varchar, is_deleted boolean, block_number bigint, log_index bigint )
CREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )
CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )
CREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )
CREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )
CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )


[User] Provide a list of node IDs, IP addresses, and the contract IDs and timestamps of smart contracts that were hypothetically created by these nodes.

[Assistant] SELECT T1.node_id, T1.ip_address, T2.contract_id, T2.timestamp FROM blockchain.nodes AS T1 JOIN blockchain.smart_contracts AS T2 ON T1.node_id = T2.creator_address;

[User] Add the node's port number to the results.

[Assistant] SELECT T1.node_id, T1.ip_address, T1.port, T2.contract_id, T2.timestamp FROM blockchain.nodes AS T1 JOIN blockchain.smart_contracts AS T2 ON T1.node_id = T2.creator_address;

[User] Filter this list to only include contracts created after January 1st, 2024.

[Assistant] SELECT T1.node_id, T1.ip_address, T1.port, T2.contract_id, T2.timestamp FROM blockchain.nodes AS T1 JOIN blockchain.smart_contracts AS T2 ON T1.node_id = T2.creator_address WHERE T2.timestamp > '2024-01-01';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.nodes (
    node_id character varying(64) NOT NULL,  -- unique identifier for the node
    ip_address character varying(15) NOT NULL, -- IP address of the node
    port integer NOT NULL, -- port number of the node
    last_seen timestamp NOT NULL, -- last time the node was active
    PRIMARY KEY (node_id)
)
CREATE TABLE blockchain.users (
    user_id character varying(64) NOT NULL,  -- unique identifier for the user
    username character varying(128) NOT NULL, -- username of the user
    email character varying(128) NOT NULL, -- email address of the user
    password_hash text NOT NULL, -- hashed password of the user
    PRIMARY KEY (user_id)
)
CREATE TABLE blockchain.smart_contracts (
    contract_id character varying(64) NOT NULL,  -- unique identifier for the smart contract
    creator_address character varying(128) NOT NULL, -- address of the creator of the contract
    code text NOT NULL, -- code of the smart contract
    timestamp timestamp NOT NULL, -- time when the contract was deployed
    PRIMARY KEY (contract_id)
)


[User] Show me all contract addresses deployed by the address '0xabc...def'.

[Assistant] SELECT address FROM web3.contracts WHERE deployer_address = '0xabc...def';

[User] Can you refine that list to only include contracts that are currently 'active'?

[Assistant] SELECT address FROM web3.contracts WHERE deployer_address = '0xabc...def' AND status = 'active';

[User] Further filter it to only show those deployed between '2023-01-01' and '2023-12-31'.

[Assistant] SELECT address FROM web3.contracts WHERE deployer_address = '0xabc...def' AND status = 'active' AND deployed_at BETWEEN '2023-01-01' AND '2023-12-31';

[User] Instead of listing addresses, please count how many such contracts exist for this deployer, grouped by the network they are deployed on.

[Assistant] SELECT network_id, COUNT(*) FROM web3.contracts WHERE deployer_address = '0xabc...def' AND status = 'active' AND deployed_at BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY network_id;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.contracts ( contract_id text PRIMARY KEY, address text, abi text, bytecode text, deployer_address text, deployed_at timestamp, network_id text, status text )


[User] Show me the latest price and symbol for all tokens listed in the token_prices_latest table.

[Assistant] SELECT symbol, price FROM token_prices_latest;

[User] Filter that to only show tokens on the 'binancecoin' blockchain.

[Assistant] SELECT symbol, price FROM token_prices_latest WHERE blockchain = 'binancecoin';

[User] Actually, I only need the price and timestamp, and I want the blockchain to be 'polygon', not 'binancecoin'.

[Assistant] SELECT price, timestamp FROM token_prices_latest WHERE blockchain = 'polygon';

[User] Sort the results by timestamp in descending order and only show the top 10 entries.

[Assistant] SELECT price, timestamp FROM token_prices_latest WHERE blockchain = 'polygon' ORDER BY timestamp DESC LIMIT 10;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_metas ( block_timestamp timestamp(6) NOT NULL, block_number bigint NOT NULL, transaction_hash varchar NOT NULL, transaction_index bigint NOT NULL, from_address varchar NOT NULL, contract_address varchar NOT NULL, symbol varchar NOT NULL, total_supply varchar NOT NULL, name varchar NOT NULL, decimals bigint NOT NULL, is_erc20 integer NOT NULL, is_erc721 integer NOT NULL, is_erc1155 integer NOT NULL, is_proxy integer NOT NULL, extra_info varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE 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 )
CREATE 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 )
CREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )
CREATE TABLE sui_coins_metadata ( object_id varchar NOT NULL, coin_type varchar NOT NULL, status varchar NOT NULL, decimals bigint NOT NULL, description varchar NOT NULL, icon_url varchar NOT NULL, symbol varchar NOT NULL, name varchar NOT NULL )
CREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )
CREATE TABLE token_prices ( uuid varchar(36) NOT NULL, blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )
CREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )
CREATE TABLE token_balances ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )
CREATE TABLE token_activities ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar NOT NULL, tick varchar NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )
CREATE TABLE token_activities_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL )
CREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )
CREATE TABLE token_info_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(20) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL, minted decimal(38,0) NOT NULL, holders decimal(38,0) NOT NULL, txs decimal(38,0) NOT NULL, updated_timestamp timestamp(3) NOT NULL, completed_timestamp timestamp(3) NOT NULL, id varchar(255) NOT NULL )


[User] For wallet '0x...', list the token IDs of the NFTs currently held, the name of their collection, and that collection's floor price.

[Assistant] SELECT T1.token_id, T2.name, T2.floor_price FROM nft_holders AS T1 INNER JOIN nft_collections AS T2 ON T1.contract_address = T2.contract_address WHERE T1.wallet_address = '0x...';


[User] List the number of users created each year, showing the year and the count, ordered by the year.

[Assistant] SELECT EXTRACT(YEAR FROM created_at) AS creation_year, COUNT(*) FROM web3.users GROUP BY creation_year ORDER BY creation_year;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )


[User] How many users are registered in the system?

[Assistant] SELECT COUNT(*) FROM blockchain.users;

[User] List the user ID and email for users whose email contains the string 'support'.

[Assistant] SELECT user_id, email FROM blockchain.users WHERE email LIKE '%support%';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.users ( user_id.text, username.text, email.text, password_hash.text )


[User] Show me a list of users who have logged any action. Include their user ID and username.

[Assistant] SELECT DISTINCT u.user_id, u.username FROM users u JOIN logs l ON u.user_id = l.user_id;

[User] For these users, list each unique action type they have performed. Show the username and the action type.

[Assistant] SELECT DISTINCT u.username, l.action FROM users u JOIN logs l ON u.user_id = l.user_id;

[User] Now, for each user who has logged actions, count the total number of log entries they have. Show the username and the count.

[Assistant] SELECT u.username, COUNT(l.log_id) FROM users u JOIN logs l ON u.user_id = l.user_id GROUP BY u.username;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )
CREATE TABLE trading_platform.orders ( order_id text PRIMARY KEY, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp )
CREATE TABLE trading_platform.assets ( asset_id text PRIMARY KEY, name text, symbol text, type text )
CREATE TABLE trading_platform.dapps ( dapp_id text PRIMARY KEY, name text, description text, url text )
CREATE TABLE trading_platform.peers ( peer_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )
CREATE TABLE trading_platform.metadata ( metadata_id text PRIMARY KEY, asset_id text, key text, value text )
CREATE TABLE trading_platform.kyc_audit ( kyc_audit_id text PRIMARY KEY, user_id text, status text, reviewed_at timestamp )
CREATE TABLE trading_platform.logs ( log_id text PRIMARY KEY, user_id text, action text, details text, logged_at timestamp )
CREATE TABLE trading_platform.notifications ( notification_id text PRIMARY KEY, user_id text, message text, sent_at timestamp, read_at timestamp )


[User] Show me a list of all unique user IDs present in the wallet database.

[Assistant] SELECT DISTINCT user_id FROM web3.wallets;

[User] For each of those user IDs, how many wallets do they have? Show both the user ID and their wallet count.

[Assistant] SELECT user_id, COUNT(wallet_id) AS wallet_count FROM web3.wallets GROUP BY user_id;

[User] Please sort that list in descending order based on the wallet count.

[Assistant] SELECT user_id, COUNT(wallet_id) AS wallet_count FROM web3.wallets GROUP BY user_id ORDER BY wallet_count DESC;

[User] Can you filter the list to only show users who have more than 10 wallets?

[Assistant] SELECT user_id, COUNT(wallet_id) AS wallet_count FROM web3.wallets GROUP BY user_id HAVING COUNT(wallet_id) > 10 ORDER BY wallet_count DESC;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.wallets ( wallet_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, address character varying(128) NOT NULL, private_key text NOT NULL, created_at timestamp NOT NULL, PRIMARY KEY (wallet_id) )


[User] Find smart money addresses that have a positive ROI but their realized profit ratio is less than 50%. List their address, ROI, and realized ratio, ordered by ROI in descending order.

[Assistant] SELECT address, roi, realized_ratio FROM smart_money_profit WHERE roi > 0 AND realized_ratio < 50 ORDER BY roi DESC;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE smart_money_profit ( address character varying(100) NOT NULL, rank INT, profit numeric(38,6), roi numeric(38,2), realized_ratio numeric(38,2), most_profit_token character varying(100), last_trade_time character varying(100), chain character varying(100) )


[User] List all smart money token inflows, showing the token symbol, chain, and USD value.

[Assistant] SELECT token_symbol, chain, usd_value FROM smart_money_token_inflow;

[User] Filter that list to only show inflows on the 'BNB' chain.

[Assistant] SELECT token_symbol, chain, usd_value FROM smart_money_token_inflow WHERE chain = 'BNB';

[User] Also, only include inflows where the USD value is greater than 50000.

[Assistant] SELECT token_symbol, chain, usd_value FROM smart_money_token_inflow WHERE chain = 'BNB' AND usd_value > 50000;

[User] Order the results by USD value in descending order.

[Assistant] SELECT token_symbol, chain, usd_value FROM smart_money_token_inflow WHERE chain = 'BNB' AND usd_value > 50000 ORDER BY usd_value DESC;


[User] Provide a list of user ID, wallet ID, and details (contract ID, creator address, timestamp) for smart contracts created by addresses associated with wallets.

[Assistant] SELECT w.user_id, w.wallet_id, sc.contract_id, sc.creator_address, sc.timestamp FROM blockchain.wallets w JOIN blockchain.smart_contracts sc ON w.address_id = sc.creator_address;

[User] Filter this list to include only contracts whose code contains the string 'Ownable'.

[Assistant] SELECT w.user_id, w.wallet_id, sc.contract_id, sc.creator_address, sc.timestamp FROM blockchain.wallets w JOIN blockchain.smart_contracts sc ON w.address_id = sc.creator_address WHERE sc.code LIKE '%Ownable%';

[User] Further refine the results to only include contracts created by the address '0xAbCdEf1234567890AbCdEf1234567890AbCdEf12'.

[Assistant] SELECT w.user_id, w.wallet_id, sc.contract_id, sc.creator_address, sc.timestamp FROM blockchain.wallets w JOIN blockchain.smart_contracts sc ON w.address_id = sc.creator_address WHERE sc.code LIKE '%Ownable%' AND sc.creator_address = '0xAbCdEf1234567890AbCdEf1234567890AbCdEf12';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.blocks ( block_id.text, previous_block_id.text, timestamp.timestamp, nonce.integer, merkle_root.text, difficulty.integer )
CREATE TABLE blockchain.wallets ( wallet_id.text, user_id.text, address_id.text, private_key.text )
CREATE TABLE blockchain.smart_contracts ( contract_id.text, creator_address.text, code.text, timestamp.timestamp )


[User] Show me the balances held by the 'Coinbase' exchange. For each token, list the token symbol, balance, and the current price from the token basic info table.

[Assistant] SELECT ctb.token_symbol, ctb.balance, tbi.price FROM cex_token_balance ctb JOIN token_basic_info tbi ON ctb.token_address = tbi.token_address AND ctb.chain = tbi.chain WHERE ctb.exchange = 'Coinbase';

[User] Include the USD value of the balance (balance * current price) and order the results by this calculated USD value in descending order.

[Assistant] SELECT ctb.token_symbol, ctb.balance, tbi.price, (ctb.balance * tbi.price) AS current_usd_value FROM cex_token_balance ctb JOIN token_basic_info tbi ON ctb.token_address = tbi.token_address AND ctb.chain = tbi.chain WHERE ctb.exchange = 'Coinbase' ORDER BY current_usd_value DESC;


[User] List the token symbol, USD value, and narrative for all smart money token inflows.

[Assistant] SELECT token_symbol, usd_value, narrative FROM smart_money_token_inflow;

[User] Now, only show entries where the USD value is greater than 100000.

[Assistant] SELECT token_symbol, usd_value, narrative FROM smart_money_token_inflow WHERE usd_value > 100000;

[User] Include the chain for these inflows and order the results by USD value in descending order.

[Assistant] SELECT token_symbol, usd_value, narrative, chain FROM smart_money_token_inflow WHERE usd_value > 100000 ORDER BY usd_value DESC;

[User] Also, filter the list to only include inflows associated with the 'GameFi' narrative.

[Assistant] SELECT token_symbol, usd_value, narrative, chain FROM smart_money_token_inflow WHERE usd_value > 100000 AND narrative = 'GameFi' ORDER BY usd_value DESC;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE smart_money_token_inflow ( token_address text, token_symbol text, token_amount numeric, usd_value numeric, avg_price numeric, type numeric, address_amount numeric, narrative text, chain text )


[User] Show me the wallet addresses holding the ERC20 token with contract address '0xabcdeffedcba9876543210abcdefedcba9876'. Include the amount they hold.

[Assistant] SELECT wallet_address, amount FROM erc20_balances WHERE contract_address = '0xabcdeffedcba9876543210abcdefedcba9876';

[User] Instead of contract address, can you do this for a token symbol like 'USDC'?

[Assistant] SELECT eb.wallet_address, eb.amount FROM erc20_balances eb JOIN token_metas tm ON eb.contract_address = tm.contract_address WHERE tm.symbol = 'USDC' AND tm.is_erc20 = 1;

[User] Filter the results to only show wallets holding more than 1000 of this token.

[Assistant] SELECT eb.wallet_address, eb.amount FROM erc20_balances eb JOIN token_metas tm ON eb.contract_address = tm.contract_address WHERE tm.symbol = 'USDC' AND tm.is_erc20 = 1 AND CAST(eb.amount AS DECIMAL) > 1000;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash text, transaction_index bigint, from_address text, contract_address text, symbol text, total_supply text, name text, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info text, pk integer )
CREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text )
CREATE TABLE erc20_balances ( block_number bigint, contract_address text, wallet_address text, amount text, pk text )
CREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )
CREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )
CREATE TABLE sui_coins_metadata ( object_id text, coin_type text, status text, decimals bigint, description text, icon_url text, symbol text, name text )
CREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )
CREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )
CREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer )
CREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )
CREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )
CREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )
CREATE TABLE mud_holesky_redstone ( address text, table_id text, key_bytes text, key0 text, key1 text, static_data text, encoded_lengths text, dynamic_data text, is_deleted boolean, block_number bigint, log_index bigint )
CREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text )
CREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )
CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )
CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )


[User] List the ticker and creator for all tokens recorded in the `token_info_avalanche` table.

[Assistant] SELECT tick, creator FROM token_info_avalanche

[User] Now, for these tokens, show their latest price by joining with the `token_prices` table. Display the ticker and price, specifically for tokens on the 'avalanche' blockchain.

[Assistant] SELECT T1.tick, T2.price FROM token_info_avalanche AS T1 JOIN token_prices AS T2 ON T1.tick = T2.symbol WHERE T2.blockchain = 'avalanche'

[User] Filter that list to only include tokens where the price is greater than 0.1.

[Assistant] SELECT T1.tick, T2.price FROM token_info_avalanche AS T1 JOIN token_prices AS T2 ON T1.tick = T2.symbol WHERE T2.blockchain = 'avalanche' AND T2.price > 0.1

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE erc20_balances_historical ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.integer )
CREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text )
CREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )
CREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )
CREATE TABLE erc20_approval ( block_number.bigint, block_timestamp.timestamp, transaction_index.integer, transaction_hash.text, log_index.integer, contract_address.text, pk.integer )
CREATE TABLE token_balances ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )
CREATE TABLE token_info ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )
CREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )
CREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )
CREATE TABLE token_info_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text )
CREATE TABLE token_activities_bitcoin ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text )
CREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )


[User] Show me the details of tokens in the token_info_avalanche table that have the tick 'AVAX'.

[Assistant] SELECT * FROM token_info_avalanche WHERE tick = 'AVAX';

[User] Okay, now refine that. Just show me the tick, creator, and maximum supply for those 'AVAX' tokens, but only if the maximum supply is greater than 100000000.

[Assistant] SELECT tick, creator, max_supply FROM token_info_avalanche WHERE tick = 'AVAX' AND max_supply > 100000000;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_metas ( block_timestamp timestamp(6) NOT NULL, block_number bigint NOT NULL, transaction_hash varchar NOT NULL, transaction_index bigint NOT NULL, from_address varchar NOT NULL, contract_address varchar NOT NULL, symbol varchar NOT NULL, total_supply varchar NOT NULL, name varchar NOT NULL, decimals bigint NOT NULL, is_erc20 integer NOT NULL, is_erc721 integer NOT NULL, is_erc1155 integer NOT NULL, is_proxy integer NOT NULL, extra_info varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE nft_holders ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk varchar NOT NULL )
CREATE TABLE sui_coins ( object_id varchar NOT NULL, status varchar NOT NULL, coin_type varchar NOT NULL, balance varchar NOT NULL, owner varchar NOT NULL )
CREATE TABLE sui_coins_metadata ( object_id varchar NOT NULL, coin_type varchar NOT NULL, status varchar NOT NULL, decimals bigint NOT NULL, description varchar NOT NULL, icon_url varchar NOT NULL, symbol varchar NOT NULL, name varchar NOT NULL )
CREATE TABLE sui_nfts ( object_id varchar NOT NULL, status varchar NOT NULL, collection_type varchar NOT NULL, package_id varchar NOT NULL, previous_transaction varchar NOT NULL, display varchar NOT NULL, owner varchar NOT NULL, name varchar NOT NULL )
CREATE TABLE nft_metadata ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, token_id varchar NOT NULL, contract_name varchar NOT NULL, erc_type varchar NOT NULL, amount bigint NOT NULL, minter varchar NOT NULL, owner varchar NOT NULL, mint_block_number bigint NOT NULL, mint_time bigint NOT NULL, mint_transaction_hash varchar NOT NULL, mint_price varchar NOT NULL, token_uri varchar NOT NULL, metadata varchar NOT NULL, name varchar NOT NULL, image_uri varchar NOT NULL, traits varchar NOT NULL, updated_at bigint NOT NULL, status varchar NOT NULL, rarity_score real NOT NULL, rarity_rank integer NOT NULL, unique_attribute_count integer NOT NULL, pk integer NOT NULL )
CREATE TABLE token_prices ( uuid varchar(36) NOT NULL, blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )
CREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, address varchar(42) NOT NULL, decimals bigint NOT NULL, symbol varchar(36) NOT NULL, price real NOT NULL, timestamp timestamp(6) NOT NULL )
CREATE TABLE erc20_approval ( block_number bigint NOT NULL, block_timestamp timestamp(6) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar NOT NULL, log_index integer NOT NULL, contract_address varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE token_balances ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )
CREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )
CREATE TABLE mud_holesky_redstone ( address varchar NOT NULL, table_id varchar NOT NULL, key_bytes varchar NOT NULL, key0 varchar NOT NULL, key1 varchar NOT NULL, static_data varchar NOT NULL, encoded_lengths varchar NOT NULL, dynamic_data varchar NOT NULL, is_deleted boolean NOT NULL, block_number bigint NOT NULL, log_index bigint NOT NULL )
CREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(255) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply varchar NOT NULL, amount varchar NOT NULL )
CREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL )
CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(62) NOT NULL, to_address varchar(62) NOT NULL )
CREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL )
CREATE TABLE token_info_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(20) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL, minted decimal(38,0) NOT NULL, holders decimal(38,0) NOT NULL, txs decimal(38,0) NOT NULL, updated_timestamp timestamp(3) NOT NULL, completed_timestamp timestamp(3) NOT NULL, id varchar(255) NOT NULL )


[User] How many smart contracts were created in the year 2023?

[Assistant] SELECT COUNT(*) FROM blockchain.smart_contracts WHERE timestamp >= '2023-01-01' AND timestamp < '2024-01-01';

[User] List the top 5 creator addresses based on the total number of smart contracts they have deployed.

[Assistant] SELECT creator_address, COUNT(*) AS contract_count FROM blockchain.smart_contracts GROUP BY creator_address ORDER BY contract_count DESC LIMIT 5;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.smart_contracts ( contract_id.text, creator_address.text, code.text, timestamp.timestamp )


[User] Show me the total market cap and the total smart money inflow USD value for each narrative. Join the `token_basic_info` and `smart_money_token_inflow` tables based on narrative.

[Assistant] WITH Narratives AS ( SELECT DISTINCT narrative FROM token_basic_info WHERE narrative IS NOT NULL UNION SELECT DISTINCT narrative FROM smart_money_token_inflow WHERE narrative IS NOT NULL ) SELECT n.narrative, SUM(tbi.market_cap) AS total_market_cap, SUM(smi.usd_value) AS total_inflow_usd FROM Narratives n LEFT JOIN token_basic_info tbi ON n.narrative = tbi.narrative LEFT JOIN smart_money_token_inflow smi ON n.narrative = smi.narrative GROUP BY n.narrative ORDER BY total_inflow_usd DESC NULLS LAST;

[User] From that list, only show narratives where the total market cap is greater than 1,000,000,000.

[Assistant] WITH Narratives AS ( SELECT DISTINCT narrative FROM token_basic_info WHERE narrative IS NOT NULL UNION SELECT DISTINCT narrative FROM smart_money_token_inflow WHERE narrative IS NOT NULL ) SELECT n.narrative, SUM(tbi.market_cap) AS total_market_cap, SUM(smi.usd_value) AS total_inflow_usd FROM Narratives n LEFT JOIN token_basic_info tbi ON n.narrative = tbi.narrative LEFT JOIN smart_money_token_inflow smi ON n.narrative = smi.narrative GROUP BY n.narrative HAVING SUM(tbi.market_cap) > 1000000000 ORDER BY total_inflow_usd DESC NULLS LAST;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_basic_info ( coin_id text, token_name text, token_symbol text, token_address text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, highest_price_24h numeric, lowest_price_24h numeric, market_cap numeric, market_cap_rank numeric, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank numeric )
CREATE TABLE smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )
CREATE TABLE smart_money_token_performance ( token_address text, token_symbol text, pnl numeric, net_flow numeric, avg_cost numeric, price numeric, realized_ratio numeric, roi numeric, chain text )
CREATE TABLE smart_money_token_inflow ( token_address text, token_symbol text, token_amount numeric, usd_value numeric, avg_price numeric, type numeric, address_amount numeric, narrative text, chain text )


[User] Find tokens that appear in both the smart money token performance and the smart money token inflow tables. List the token symbol, chain, the PNL from the performance table, and the total USD value from all corresponding inflow records.

[Assistant] SELECT T1.token_symbol, T1.chain, T1.pnl, SUM(T2.usd_value) AS total_usd_inflow FROM smart_money_token_performance AS T1 JOIN smart_money_token_inflow AS T2 ON T1.token_symbol = T2.token_symbol AND T1.chain = T2.chain GROUP BY T1.token_symbol, T1.chain, T1.pnl

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_basic_info ( coin_id.text, token_name.text, token_symbol.text, token_address.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, highest_price_24h.numeric, lowest_price_24h.numeric, market_cap.numeric, market_cap_rank.numeric, market_cap_change_percentage_24h.text, total_volume.text, narrative.text, trend_rank.numeric )
CREATE TABLE narrative_info ( narrative.text, top_3_coins.text, price_change_percentage_1h.numeric, price_change_percentage_24h.numeric, price_change_percentage_7d.numeric, market_cap.numeric, volume_24h.numeric, trend_rank.numeric, token_num.numeric )
CREATE TABLE token_dexpool_info ( pair_address.text, token_name.text, token_symbol.text, chain.text, price.numeric, price_change_percentage_1h.numeric, price_change_percentage_6h.numeric, price_change_percentage_24h.numeric, makers_24h.numeric, volume_24h.numeric, liquidity.numeric, market_cap.numeric, trend_rank.numeric )
CREATE TABLE smart_money_token_performance ( token_address.text, token_symbol.text, pnl.numeric, net_flow.numeric, avg_cost.numeric, price.numeric, realized_ratio.numeric, roi.numeric, chain.text )
CREATE TABLE smart_money_token_inflow ( token_address.text, token_symbol.text, token_amount.numeric, usd_value.numeric, avg_price.numeric, type.numeric, address_amount.numeric, narrative.text, chain.text )


[User] Show me the average market cap and average 24-hour price change percentage for tokens on each chain.

[Assistant] SELECT chain, AVG(market_cap) AS average_market_cap, AVG(price_change_percentage_24h) AS average_price_change_24h FROM token_basic_info GROUP BY chain;

[User] Now, only show chains where the average market cap is greater than 1,000,000,000.

[Assistant] SELECT chain, AVG(market_cap) AS average_market_cap, AVG(price_change_percentage_24h) AS average_price_change_24h FROM token_basic_info GROUP BY chain HAVING AVG(market_cap) > 1000000000;

[User] Also, order the results by average market cap in descending order.

[Assistant] SELECT chain, AVG(market_cap) AS average_market_cap, AVG(price_change_percentage_24h) AS average_price_change_24h FROM token_basic_info GROUP BY chain HAVING AVG(market_cap) > 1000000000 ORDER BY average_market_cap DESC;

[User] Can you also include the total number of tokens for each of these chains?

[Assistant] SELECT chain, COUNT(*) AS number_of_tokens, AVG(market_cap) AS average_market_cap, AVG(price_change_percentage_24h) AS average_price_change_24h FROM token_basic_info GROUP BY chain HAVING AVG(market_cap) > 1000000000 ORDER BY average_market_cap DESC;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, token_name character varying(100) NOT NULL, token_symbol character varying(100) NOT NULL, token_address character varying(100) NOT NULL, chain text, price double precision, price_change_percentage_1h double precision, price_change_percentage_24h double precision, price_change_percentage_7d double precision, highest_price_24h double precision, lowest_price_24h double precision, market_cap double precision, market_cap_rank bigint, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank bigint )


[User] Show me the latest token activities on Avalanche, listing the type, amount, and timestamp.

[Assistant] SELECT type, amt, block_timestamp FROM token_activities_avalanche ORDER BY block_timestamp DESC LIMIT 100

[User] Filter that to only show activities of type 'transfer'.

[Assistant] SELECT type, amt, block_timestamp FROM token_activities_avalanche WHERE type = 'transfer' ORDER BY block_timestamp DESC LIMIT 100

[User] Now, only show entries where the amount is greater than 1000.

[Assistant] SELECT type, amt, block_timestamp FROM token_activities_avalanche WHERE type = 'transfer' AND amt > 1000 ORDER BY block_timestamp DESC LIMIT 100

[User] Could you also include the 'from' and 'to' addresses for these activities?

[Assistant] SELECT type, amt, block_timestamp, from_address, to_address FROM token_activities_avalanche WHERE type = 'transfer' AND amt > 1000 ORDER BY block_timestamp DESC LIMIT 100

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer )
CREATE TABLE erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar )
CREATE TABLE erc20_balances_historical ( block_number bigint, contract_address varchar, wallet_address varchar, amount varchar, pk integer )
CREATE TABLE nft_holder_historical ( block_number bigint, contract_address varchar, wallet_address varchar, token_id varchar, contract_type varchar, amount varchar, pk integer )
CREATE TABLE sui_coins ( object_id varchar, status varchar, coin_type varchar, balance varchar, owner varchar )
CREATE TABLE sui_coins_metadata ( object_id varchar, coin_type varchar, status varchar, decimals bigint, description varchar, icon_url varchar, symbol varchar, name varchar )
CREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar )
CREATE TABLE nft_metadata ( blockchain varchar, contract_address varchar, token_id varchar, contract_name varchar, erc_type varchar, amount bigint, minter varchar, owner varchar, mint_block_number bigint, mint_time bigint, mint_transaction_hash varchar, mint_price varchar, token_uri varchar, metadata varchar, name varchar, image_uri varchar, traits varchar, updated_at bigint, status varchar, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer )
CREATE TABLE nft_collections ( blockchain varchar, contract_address varchar, name varchar, symbol varchar, deploy_block_number bigint, deploy_block_time bigint, erc_type varchar, owner varchar, traits varchar, description varchar, slug varchar, media_info varchar, image_url varchar, banner_image_url varchar, updated_at bigint, banner varchar, token_count bigint, floor_price varchar, floor_price_symbol varchar, floor_price_contract varchar, pk integer )
CREATE TABLE token_prices ( uuid varchar, blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )
CREATE TABLE token_prices_latest ( blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp )
CREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash varchar, log_index integer, contract_address varchar, pk integer )
CREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )
CREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar )
CREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )
CREATE TABLE mud_holesky_redstone ( address varchar, table_id varchar, key_bytes varchar, key0 varchar, key1 varchar, static_data varchar, encoded_lengths varchar, dynamic_data varchar, is_deleted boolean, block_number bigint, log_index bigint )
CREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar )
CREATE 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 )
CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )
CREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, log_index integer, type varchar, tick varchar, id varchar, amt decimal, from_address varchar, to_address varchar )
CREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply decimal, amount decimal )
CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash varchar, tick varchar, max_supply decimal, lim decimal, wlim decimal, dec integer, creator varchar, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id varchar )


[User] Show me the user ID, wallet ID, address ID, and the transaction ID for transactions where the sender address is linked to an address associated with a wallet.

[Assistant] SELECT DISTINCT w.user_id, w.wallet_id, w.address_id, t.transaction_id FROM blockchain.wallets w JOIN blockchain.transactions t ON w.address_id = t.sender_address;

[User] Filter this list to only include transactions with an amount greater than 1000.

[Assistant] SELECT DISTINCT w.user_id, w.wallet_id, w.address_id, t.transaction_id FROM blockchain.wallets w JOIN blockchain.transactions t ON w.address_id = t.sender_address WHERE t.amount > 1000;

[User] Actually, I also want to see the amount and the transaction timestamp, and filter for transactions that occurred in 2023.

[Assistant] SELECT DISTINCT w.user_id, w.wallet_id, w.address_id, t.transaction_id, t.amount, t.timestamp FROM blockchain.wallets w JOIN blockchain.transactions t ON w.address_id = t.sender_address WHERE t.amount > 1000 AND t.timestamp >= '2023-01-01' AND t.timestamp < '2024-01-01';

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.blocks ( block_id text PRIMARY KEY, previous_block_id text, timestamp timestamp, nonce int, merkle_root text, difficulty int )
CREATE TABLE blockchain.transactions ( transaction_id text PRIMARY KEY, block_id text, sender_address text, receiver_address text, amount numeric, timestamp timestamp, signature text )
CREATE TABLE blockchain.nodes ( node_id text PRIMARY KEY, ip_address text, port int, last_seen timestamp )
CREATE TABLE blockchain.wallets ( wallet_id text PRIMARY KEY, user_id text, address_id text, private_key text )
CREATE TABLE blockchain.smart_contracts ( contract_id text PRIMARY KEY, creator_address text, code text, timestamp timestamp )


[User] Provide the total count of addresses and the minimum balance recorded in the system.

[Assistant] SELECT COUNT(*), MIN(balance) FROM blockchain.addresses;

[User] Now, show me the address ID and public key for all addresses that hold that minimum balance.

[Assistant] SELECT address_id, public_key FROM blockchain.addresses WHERE balance = (SELECT MIN(balance) FROM blockchain.addresses);

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.addresses ( address_id text, public_key text, balance numeric )


[User] Find the transaction IDs and timestamps for all transactions that resulted from an emitted event.

[Assistant] SELECT t.transaction_id, t.timestamp FROM web3.transactions t JOIN web3.events e ON t.transaction_id = e.transaction_id;

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.contracts ( contract_id text, address text, abi text, bytecode text, deployer_address text, deployed_at timestamp, network_id text, status text )
CREATE TABLE web3.events ( event_id text, contract_id text, event_name text, data text, emitted_at timestamp, transaction_id text, log_index integer )
CREATE TABLE web3.transactions ( transaction_id text, from_address text, to_address text, value numeric, gas_used integer, gas_price numeric, block_number integer, timestamp timestamp, input_data text, status text, nonce integer )
CREATE TABLE web3.tokens ( token_id text, contract_address text, token_name text, token_symbol text, decimals integer, total_supply numeric )
CREATE TABLE web3.token_transfers ( transfer_id text, token_id text, from_address text, to_address text, value numeric, transaction_id text, log_index integer )
CREATE TABLE web3.users ( user_id text, username text, email text, password_hash text, created_at timestamp )


[User] What is the total count of blocks and the average difficulty?

[Assistant] SELECT COUNT(*), AVG(difficulty) FROM blockchain.blocks

[User] Now, show me the total count and average difficulty only for blocks created in the year 2023.

[Assistant] SELECT COUNT(*), AVG(difficulty) FROM blockchain.blocks WHERE timestamp >= '2023-01-01' AND timestamp < '2024-01-01'

System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.blocks ( block_id text PRIMARY KEY, previous_block_id text, timestamp timestamp, nonce int, merkle_root text, difficulty int )