System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE financial_services.customers ( customer_id text PRIMARY KEY, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )
CREATE TABLE financial_services.securities ( security_id text, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )
CREATE TABLE financial_services.loans ( loan_id text, account_id text, loan_type text, principal_amount numeric, current_principal_balance numeric, interest_rate numeric, term_months integer, origination_date date, maturity_date date, monthly_payment numeric, collateral_description text, status text )

[User] List all securities (security_id, ticker_symbol, security_name) that are traded on the NASDAQ exchange (exchange = 'NASDAQ') and belong to the 'Technology' sector.

[Assistant] SELECT security_id, ticker_symbol, security_name FROM financial_services.securities WHERE exchange = 'NASDAQ' AND sector = 'Technology';


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government_services.services ( service_id.text, agency_id.text, service_name.text, description.text, category.text, eligibility_criteria.text, standard_fee.numeric, average_processing_time_days.integer, is_active.boolean, online_application_url.text )

[User] Show me all services, their names, and their online application URLs for services that are both active and have an online application available.

[Assistant] SELECT service_name, online_application_url FROM government_services.services WHERE is_active = TRUE AND online_application_url IS NOT NULL AND online_application_url <> '';


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE gaming_technology.player_inventory ( inventory_id uuid, player_id uuid, item_id uuid, quantity integer, acquired_at timestamp with time zone, instance_data jsonb )

[User] List each unique item ID and the total number of inventory entries for that item.

[Assistant] SELECT item_id, COUNT(*) AS entry_count FROM gaming_technology.player_inventory GROUP BY item_id;

[User] Could you filter the list to only show items that appear in more than 5 inventory entries?

[Assistant] SELECT item_id, COUNT(*) AS entry_count FROM gaming_technology.player_inventory GROUP BY item_id HAVING COUNT(*) > 5;

[User] For these items, also calculate the average quantity per inventory entry.

[Assistant] SELECT item_id, COUNT(*) AS entry_count, AVG(quantity) AS average_quantity FROM gaming_technology.player_inventory GROUP BY item_id HAVING COUNT(*) > 5;

[User] Order the results by the average quantity in descending order.

[Assistant] SELECT item_id, COUNT(*) AS entry_count, AVG(quantity) AS average_quantity FROM gaming_technology.player_inventory GROUP BY item_id HAVING COUNT(*) > 5 ORDER BY average_quantity DESC;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE smart_money_token_inflow ( token_address character varying(100) NOT NULL, -- the token's address token_symbol character varying(100), -- the tokens's symbol token_amount numeric(38,2), -- the absolute value of the amount if user bought minus  the amount user sold of this token usd_value numeric(38,2), -- the absolute usd value of the bought token minus sold token avg_price numeric(38,6), -- the average cost price of user spent on this token type int, -- the direction of the trade on this token. 1 means buying, 2 means selling address_amount integer, -- the amount of the user bought this token narrative character varying(100), -- the category or narrative of the token chain character varying(100), -- the chain that the token resides ,PRIMARY KEY (token_address, chain) )

[User] Which token symbols have the highest number of addresses buying them on the Ethereum chain? Show the top 3 symbols, their total address_amount, and narrative.

[Assistant]
SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses
FROM smart_money_token_inflow
WHERE type = 1 AND chain = 'Ethereum'
GROUP BY token_symbol, narrative
ORDER BY total_buying_addresses DESC
LIMIT 3;

[User] I got incorrect results. I only want results where the summed address_amount is at least 10.

[Assistant]
SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses
FROM smart_money_token_inflow
WHERE type = 1 AND chain = 'Ethereum'
GROUP BY token_symbol, narrative
HAVING SUM(address_amount) >= 10
ORDER BY total_buying_addresses DESC
LIMIT 3;

[User] Please add the total usd_value spent on buying each of these tokens.

[Assistant]
SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses, SUM(usd_value) AS total_buy_usd_value
FROM smart_money_token_inflow
WHERE type = 1 AND chain = 'Ethereum'
GROUP BY token_symbol, narrative
HAVING SUM(address_amount) >= 10
ORDER BY total_buying_addresses DESC
LIMIT 3;

[User] Also include the average price (avg_price) for each token.

[Assistant]
SELECT token_symbol, narrative, SUM(address_amount) AS total_buying_addresses, SUM(usd_value) AS total_buy_usd_value, AVG(avg_price) AS average_price
FROM smart_money_token_inflow
WHERE type = 1 AND chain = 'Ethereum'
GROUP BY token_symbol, narrative
HAVING SUM(address_amount) >= 10
ORDER BY total_buying_addresses DESC
LIMIT 3;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.transactions ( transaction_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128), value numeric(38,14) NOT NULL, gas_used integer NOT NULL, gas_price numeric(38,14) NOT NULL, block_number integer NOT NULL, timestamp timestamp NOT NULL, input_data text, status character varying(32) NOT NULL, nonce integer NOT NULL, PRIMARY KEY (transaction_id) )

[User] Find the top 5 transactions with the highest gas prices that were successful, including the from_address, to_address, and block_number.

[Assistant] SELECT from_address, to_address, block_number, gas_price FROM web3.transactions WHERE status = 'success' ORDER BY gas_price DESC LIMIT 5;


System:
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )

[User] List all insurance products along with their type and base premium. Also, show whether each product is active.

[Assistant] SELECT product_id, product_name, product_type, base_premium, is_active FROM insurance.insurance_products;

[User] Can you filter the results to only show insurance products of type 'auto'?

[Assistant] SELECT product_id, product_name, product_type, base_premium, is_active FROM insurance.insurance_products WHERE product_type = 'auto';

[User] Also, sort these results by the base premium in ascending order.

[Assistant] SELECT product_id, product_name, product_type, base_premium, is_active FROM insurance.insurance_products WHERE product_type = 'auto' ORDER BY base_premium ASC;