System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.trips (
    trip_id character varying(64) NOT NULL,  -- unique identifier for a specific trip instance
    route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips)
    vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used
    driver_id character varying(64) NOT NULL, -- identifier of the driver operating
    scheduled_departure timestamp with time zone NOT NULL, -- planned departure time
    actual_departure timestamp with time zone, -- actual departure time
    scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time
    actual_arrival timestamp with time zone, -- actual arrival time
    origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin)
    destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination)
    status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled
    passenger_count integer, -- number of passengers (if applicable)
    cargo_manifest_id character varying(64), -- link to cargo details (if applicable)
    PRIMARY KEY (trip_id)
)

[User] Can you show me all pairs of trips that use the same vehicle but have different drivers? Please include both trip IDs, vehicle_id, and the driver_id for each trip.

[Assistant]
SELECT t1.trip_id AS trip_id_1, t2.trip_id AS trip_id_2, t1.vehicle_id, t1.driver_id AS driver_id_1, t2.driver_id AS driver_id_2
FROM transportation.trips t1
JOIN transportation.trips t2
  ON t1.vehicle_id = t2.vehicle_id
 AND t1.trip_id < t2.trip_id
 AND t1.driver_id <> t2.driver_id;

[User] Actually, I also want to see only those pairs where both trips have a status of 'Completed'.

[Assistant]
SELECT t1.trip_id AS trip_id_1, t2.trip_id AS trip_id_2, t1.vehicle_id, t1.driver_id AS driver_id_1, t2.driver_id AS driver_id_2
FROM transportation.trips t1
JOIN transportation.trips t2
  ON t1.vehicle_id = t2.vehicle_id
 AND t1.trip_id < t2.trip_id
 AND t1.driver_id <> t2.driver_id
WHERE t1.status = 'Completed' AND t2.status = 'Completed';


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE gaming_technology.players ( player_id uuid PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb )

[User] Can you give me a count of players for each player status?

[Assistant] SELECT status, COUNT(player_id) FROM gaming_technology.players GROUP BY status;

[User] Now, only show me the statuses that have fewer than 100 players.

[Assistant] SELECT status, COUNT(player_id) FROM gaming_technology.players GROUP BY status HAVING COUNT(player_id) < 100;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE hospitality_technology.guests ( guest_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )
CREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )
CREATE TABLE hospitality_technology.staff ( staff_id text PRIMARY KEY, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level int, manager_id text, created_at timestamp )
CREATE TABLE hospitality_technology.services ( service_id text PRIMARY KEY, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )
CREATE TABLE hospitality_technology.service_orders ( order_id text PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text )
CREATE TABLE hospitality_technology.reviews ( review_id text PRIMARY KEY, property_id text, reservation_id text, guest_id text, rating_overall int, rating_cleanliness int, rating_service int, rating_location int, rating_value int, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )

[User] Show me the number of service orders placed for each service category.

[Assistant]
SELECT s.category, COUNT(so.order_id) AS order_count
FROM hospitality_technology.service_orders so
JOIN hospitality_technology.services s ON so.service_id = s.service_id
GROUP BY s.category;

[User] Only include categories with more than 10 orders and order by order_count descending.

[Assistant]
SELECT s.category, COUNT(so.order_id) AS order_count
FROM hospitality_technology.service_orders so
JOIN hospitality_technology.services s ON so.service_id = s.service_id
GROUP BY s.category
HAVING COUNT(so.order_id) > 10
ORDER BY order_count DESC;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp )

[User] Count the total number of users who have enabled email notifications but disabled push notifications.

[Assistant] SELECT COUNT(*) FROM social_media.user_settings WHERE email_notifications_enabled = TRUE AND push_notifications_enabled = FALSE;


System:
You are very professional for database language writing. You 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 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 )

[User] For each transaction, find the next transaction initiated by the same sender. List the original transaction_id, the next transaction_id, the sender address, and the time difference in hours between them.

[Assistant]
SELECT t1.transaction_id AS original_tx,
       t2.transaction_id AS next_tx,
       t1.from_address,
       EXTRACT(EPOCH FROM (t2.timestamp - t1.timestamp)) / 3600 AS hours_diff
FROM transactions t1
JOIN transactions t2
  ON t1.from_address = t2.from_address
 AND t2.timestamp = (
       SELECT MIN(timestamp)
       FROM transactions t3
       WHERE t3.from_address = t1.from_address
         AND t3.timestamp > t1.timestamp
   );


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government_services.service_locations ( location_id text, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean )

[User] Find the service locations that are not accessible and located in the state of 'California'. List their name, address, and city.

[Assistant] SELECT location_name ,  address ,  city FROM government_services.service_locations WHERE is_accessible = false AND state = 'California'


System:
You are very professional for database language writing. You 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.claims ( claim_id character varying(64) NOT NULL, policy_id character varying(64) NOT NULL, customer_id character varying(64) NOT NULL, incident_date timestamp NOT NULL, reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text NOT NULL, estimated_loss numeric(15, 2), status character varying(30) NOT NULL, settlement_amount numeric(15, 2), settlement_date date, claim_handler_id character varying(64), police_report_number character varying(100), PRIMARY KEY (claim_id) )

[User] List all claim IDs, policy IDs, and incident dates for claims reported after February 1st, 2024.

[Assistant]
SELECT claim_id, policy_id, incident_date
FROM insurance.claims
WHERE reported_date > '2024-02-01';


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.token_transfers ( transfer_id text PRIMARY KEY, token_id text, from_address text, to_address text, value numeric, transaction_id text, log_index int )

[User] List pairs of token transfers within the same transaction and for the same token_id where the transfer values are different. Show the transaction ID, token ID, and both transfer IDs and their values.

[Assistant] SELECT t1.transaction_id, t1.token_id, t1.transfer_id AS transfer_id_1, t1.value AS value_1, t2.transfer_id AS transfer_id_2, t2.value AS value_2 FROM web3.token_transfers AS t1 JOIN web3.token_transfers AS t2 ON t1.transaction_id = t2.transaction_id AND t1.token_id = t2.token_id AND t1.transfer_id < t2.transfer_id WHERE t1.value <> t2.value;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.time_entries (
    entry_id character varying(64) NOT NULL,  -- unique identifier for the time entry
    case_id character varying(64) NOT NULL, -- FK to cases table
    lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work)
    date_worked date NOT NULL, -- date the work was performed
    hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m)
    billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry
    description text NOT NULL, -- detailed description of the work performed
    is_billable boolean DEFAULT true, -- whether this time entry is billable to the client
    is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice
    invoice_id character varying(64), -- FK to invoices table (once billed)
    created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded
    PRIMARY KEY (entry_id)
)

[User] Show me the total hours and total billed amount for each lawyer and each case, including the lawyer_id and case_id.

[Assistant]
SELECT lawyer_id, case_id, SUM(hours_spent) AS total_hours, SUM(hours_spent * billing_rate) AS total_billed_amount
FROM legal_services.time_entries
WHERE is_billable = true AND is_billed = true
GROUP BY lawyer_id, case_id;

[User] Could you only include entries worked in 2023?

[Assistant]
SELECT lawyer_id, case_id, SUM(hours_spent) AS total_hours, SUM(hours_spent * billing_rate) AS total_billed_amount
FROM legal_services.time_entries
WHERE is_billable = true AND is_billed = true
  AND date_worked BETWEEN '2023-01-01' AND '2023-12-31'
GROUP BY lawyer_id, case_id;

[User] Now, show only those lawyers who have logged more than 20 billable and billed hours in total in 2023, across all cases.

[Assistant]
SELECT lawyer_id, SUM(hours_spent) AS total_hours, SUM(hours_spent * billing_rate) AS total_billed_amount
FROM legal_services.time_entries
WHERE is_billable = true AND is_billed = true
  AND date_worked BETWEEN '2023-01-01' AND '2023-12-31'
GROUP BY lawyer_id
HAVING SUM(hours_spent) > 20;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.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 )

[User] Show me all appointments with their subjects and the names of the lawyers who handled them.

[Assistant]
SELECT a.appointment_id, a.subject, l.first_name, l.last_name
FROM legal_services.appointments a
JOIN legal_services.lawyers l ON a.lawyer_id = l.lawyer_id;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE social_media.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, full_name text, profile_picture_url text, bio text, location text, created_at timestamp, updated_at timestamp, is_verified bool )
CREATE TABLE social_media.posts ( post_id.text, user_id.text, content.text, media_url.text, media_type.text, created_at.timestamp, updated_at.timestamp, visibility.text, location_lat.numeric, location_lon.numeric )
CREATE TABLE social_media.comments ( comment_id text PRIMARY KEY, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )
CREATE TABLE social_media.follows ( follow_id text PRIMARY KEY, follower_user_id text, following_user_id text, created_at timestamp )
CREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp )
CREATE 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) )
CREATE TABLE social_media.messages ( message_id text PRIMARY KEY, conversation_id text, sender_user_id text, content text, media_url text, media_type text, sent_at timestamp, read_at timestamp )
CREATE TABLE social_media.conversations ( conversation_id text, created_at timestamp, last_message_at timestamp, is_group_chat boolean, group_name text )
CREATE TABLE social_media.conversation_participants ( participant_id text, conversation_id text, user_id text, joined_at timestamp, last_read_at timestamp )
CREATE TABLE social_media.notifications (
    notification_id character varying(64) NOT NULL, -- unique identifier for the notification
    recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id)
    sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications)
    notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message')
    target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id)
    target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation')
    created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created
    read_at timestamp, -- timestamp notification was marked as read
    PRIMARY KEY (notification_id)
)
CREATE TABLE social_media.user_settings ( setting_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL UNIQUE, theme character varying(20) DEFAULT 'light', email_notifications_enabled boolean DEFAULT true, push_notifications_enabled boolean DEFAULT true, private_profile boolean DEFAULT false, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (setting_id) )

[User] Show me the content of comments and the username of the author of the post the comment is on.

[Assistant] SELECT T1.content, T3.username FROM social_media.comments AS T1 JOIN social_media.posts AS T2 ON T1.post_id = T2.post_id JOIN social_media.users AS T3 ON T2.user_id = T3.user_id

[User] Only include comments made after '2024-01-01'.

[Assistant] SELECT T1.content, T3.username FROM social_media.comments AS T1 JOIN social_media.posts AS T2 ON T1.post_id = T2.post_id JOIN social_media.users AS T3 ON T2.user_id = T3.user_id WHERE T1.created_at > '2024-01-01'

[User] Actually, also show the post content and limit to the top 10 most recent comments.

[Assistant] SELECT T1.content, T3.username, T2.content FROM social_media.comments AS T1 JOIN social_media.posts AS T2 ON T1.post_id = T2.post_id JOIN social_media.users AS T3 ON T2.user_id = T3.user_id WHERE T1.created_at > '2024-01-01' ORDER BY T1.created_at DESC LIMIT 10


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE financial_services.securities ( security_id text PRIMARY KEY, ticker_symbol text, isin_code text, cusip_code text, security_name text, security_type text, exchange text, currency text, issuer_name text, sector text, last_updated timestamp )

[User] List all securities issued by 'Morgan Stanley' along with their ticker_symbol, security_name, and exchange. Then also show the sector for each.

[Assistant] SELECT ticker_symbol, security_name, exchange, sector FROM financial_services.securities WHERE issuer_name = 'Morgan Stanley';

[User] Only include those securities that are traded on the NASDAQ exchange.

[Assistant] SELECT ticker_symbol, security_name, exchange, sector FROM financial_services.securities WHERE issuer_name = 'Morgan Stanley' AND exchange = 'NASDAQ';

[User] Add another filter: the security_type must be 'Equity'.

[Assistant] SELECT ticker_symbol, security_name, exchange, sector FROM financial_services.securities WHERE issuer_name = 'Morgan Stanley' AND exchange = 'NASDAQ' AND security_type = 'Equity';

[User] Finally, sort the results by ticker_symbol in ascending order.

[Assistant] SELECT ticker_symbol, security_name, exchange, sector FROM financial_services.securities WHERE issuer_name = 'Morgan Stanley' AND exchange = 'NASDAQ' AND security_type = 'Equity' ORDER BY ticker_symbol ASC;


System:
You are very professional for database language writing. You 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.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] What is the average interest rate for auto loans (loan_type = 'Auto') with a principal amount between $20,000 and $50,000?

[Assistant] SELECT AVG(interest_rate) AS avg_interest_rate FROM financial_services.loans WHERE loan_type = 'Auto' AND principal_amount BETWEEN 20000 AND 50000;


[User] Show me the usernames and registration dates for players who registered between '2023-01-01' and '2023-12-31'.

[Assistant] SELECT username, registration_date FROM gaming_technology.players WHERE registration_date >= '2023-01-01' AND registration_date < '2024-01-01';


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.locations (
    location_id character varying(64) NOT NULL,  -- unique identifier for the location
    name character varying(255) NOT NULL, -- name of the location (e.g., Central Station, Depot Alpha, Pier 7)
    type character varying(64) NOT NULL, -- e.g., Station, Stop, Depot, Port, Airport, Customer Address
    address_line1 character varying(255), -- street address
    city character varying(128), -- city name
    state_province character varying(128), -- state or province
    postal_code character varying(32), -- postal code
    country character varying(64) NOT NULL, -- country name
    latitude numeric(9, 6), -- geographic latitude
    longitude numeric(9, 6), -- geographic longitude
    timezone character varying(64), -- IANA timezone name (e.g., America/New_York)
    PRIMARY KEY (location_id)
)

[User] Which locations lack a postal code? For each, display the name, type, city, and state_province.

[Assistant]
SELECT name, type, city, state_province
FROM transportation.locations
WHERE postal_code IS NULL;

[User] Also show the country and order the results by city in ascending order.

[Assistant]
SELECT name, type, city, state_province, country
FROM transportation.locations
WHERE postal_code IS NULL
ORDER BY city ASC;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, room_number character varying(10) NOT NULL, room_type_id character varying(64) NOT NULL, floor integer, status character varying(50) NOT NULL, is_smoking boolean NOT NULL DEFAULT false, features text, current_condition text, last_cleaned_at timestamp with time zone, PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )
CREATE TABLE hospitality_technology.room_types ( room_type_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, type_name character varying(100) NOT NULL, description text, base_rate numeric(10, 2) NOT NULL, max_occupancy integer NOT NULL, bed_type character varying(50), area_sqft numeric(8,2), amenities text, PRIMARY KEY (room_type_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )
CREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )
CREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )
CREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, reservation_id character varying(64) UNIQUE, guest_id character varying(64) NOT NULL, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source character varying(100), review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, is_public boolean DEFAULT true, staff_response text, response_staff_id character varying(64), response_date timestamp with time zone, PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) )

[User] List the names and prices of all services available in the 'Food & Beverage' department.

[Assistant]
SELECT service_name, price
FROM hospitality_technology.services
WHERE department = 'Food & Beverage' AND is_available = TRUE;

[User] Now show only those priced under 100 and display category as well.

[Assistant]
SELECT service_name, category, price
FROM hospitality_technology.services
WHERE department = 'Food & Beverage' AND is_available = TRUE
  AND price < 100;


System:
You are very professional for database language writing. You 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.servers ( server_id uuid, game_id uuid, server_name text, region text, ip_address text, port integer, current_players integer, max_players integer, status text, last_heartbeat timestamp with time zone )

[User] Find pairs of servers that are currently 'online' and share the same game_id, listing their server names and the shared game_id.

[Assistant] SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.game_id FROM gaming_technology.servers s1 JOIN gaming_technology.servers s2 ON s1.game_id = s2.game_id AND s1.server_id < s2.server_id WHERE s1.status = 'online' AND s2.status = 'online';

[User] For these pairs, show the sum of their current_players and the sum of their max_players.

[Assistant] SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.game_id, (s1.current_players + s2.current_players) AS combined_current_players, (s1.max_players + s2.max_players) AS combined_max_players FROM gaming_technology.servers s1 JOIN gaming_technology.servers s2 ON s1.game_id = s2.game_id AND s1.server_id < s2.server_id WHERE s1.status = 'online' AND s2.status = 'online';

[User] Order the results by game_id and then by the combined current players in descending order.

[Assistant] SELECT s1.server_name AS server1_name, s2.server_name AS server2_name, s1.game_id, (s1.current_players + s2.current_players) AS combined_current_players, (s1.max_players + s2.max_players) AS combined_max_players FROM gaming_technology.servers s1 JOIN gaming_technology.servers s2 ON s1.game_id = s2.game_id AND s1.server_id < s2.server_id WHERE s1.status = 'online' AND s2.status = 'online' ORDER BY s1.game_id, combined_current_players DESC;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.events ( event_id character varying(64) NOT NULL, contract_id character varying(64) NOT NULL, event_name character varying(128) NOT NULL, data text NOT NULL, emitted_at timestamp NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (event_id) )
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.token_transfers ( transfer_id character varying(64) NOT NULL, token_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128) NOT NULL, value numeric(38,14) NOT NULL, transaction_id character varying(64) NOT NULL, log_index integer NOT NULL, PRIMARY KEY (transfer_id) )
CREATE TABLE web3.wallets (
    wallet_id character varying(64) NOT NULL,  -- unique identifier for the wallet
    user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet
    address character varying(128) NOT NULL, -- address of the wallet
    private_key text NOT NULL, -- private key of the wallet
    created_at timestamp NOT NULL, -- time when the wallet was created
    PRIMARY KEY (wallet_id)
)
CREATE TABLE web3.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)
)

[User] List all transactions along with the user ID and username of the sender, if available. Show transaction id, from_address, user id, and username.

[Assistant]
SELECT tx.transaction_id, tx.from_address, w.user_id, u.username
FROM web3.transactions tx
LEFT JOIN web3.wallets w ON tx.from_address = w.address
LEFT JOIN web3.users u ON w.user_id = u.user_id;

[User] Actually, only include transactions where we can match the sender to a user, and sort the results by username.

[Assistant]
SELECT tx.transaction_id, tx.from_address, w.user_id, u.username
FROM web3.transactions tx
JOIN web3.wallets w ON tx.from_address = w.address
JOIN web3.users u ON w.user_id = u.user_id
ORDER BY u.username;


System:
You are very professional for database language writing. You 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_dexpool_info ( pair_address character varying(512) NOT NULL, -- the id of dexpool token_name character varying(100) NOT NULL, -- the name of the token in the dexpool token_symbol character varying(100) NOT NULL, -- the token's symbol chain text, -- the chain that the dexpool resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_6h double precision, -- change in value divided by the absolute price value of the original token price in 6 hours price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours makers_24h double precision, -- the makers of the dex pool in 24 hours volume_24h double precision, -- the trade volume of the dex pool in 24 hours liquidity double precision, -- the liquidity of the dex pool market_cap double precision, -- the market cap of the token trend_rank bigint, -- the rank of token in the dex pool of recent trending, value 1 expresses the most popular token. ,PRIMARY KEY (pair_address, chain) )

[User] What is the total market cap for all tokens listed on the 'Polygon' chain?

[Assistant] SELECT SUM(market_cap) FROM token_dexpool_info WHERE chain = 'Polygon';

[User] Only sum the market cap for tokens on 'Polygon' that have a 24-hour volume greater than 500000.

[Assistant] SELECT SUM(market_cap) FROM token_dexpool_info WHERE chain = 'Polygon' AND volume_24h > 500000;

[User] Also show the number of unique tokens that meet these criteria.

[Assistant] SELECT COUNT(DISTINCT token_symbol), SUM(market_cap) FROM token_dexpool_info WHERE chain = 'Polygon' AND volume_24h > 500000;

[User] Can you show the total market cap and token count for *each* chain that meets these volume criteria, ordered by total market cap descending?

[Assistant] SELECT chain, COUNT(DISTINCT token_symbol) AS token_count, SUM(market_cap) AS total_market_cap FROM token_dexpool_info WHERE volume_24h > 500000 GROUP BY chain ORDER BY total_market_cap DESC;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (property_id) )
CREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) )
CREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, guest_id character varying(64) NOT NULL, room_id character varying(64), room_type_id character varying(64) NOT NULL, check_in_date date NOT NULL, check_out_date date NOT NULL, actual_check_in_ts timestamp with time zone, actual_check_out_ts timestamp with time zone, num_adults integer NOT NULL, num_children integer DEFAULT 0, status character varying(50) NOT NULL, booking_source character varying(100), rate_plan_id character varying(64), total_amount numeric(12, 2), amount_paid numeric(12, 2) DEFAULT 0.00, special_requests text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) )
CREATE TABLE hospitality_technology.staff ( staff_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, position character varying(100) NOT NULL, work_email character varying(255) UNIQUE, work_phone character varying(30), hire_date date NOT NULL, termination_date date, is_active boolean NOT NULL DEFAULT true, access_level integer NOT NULL, manager_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (staff_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id) )
CREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) )

[User] List all staff members who have a manager, including each staff’s first and last name, position, and their manager’s first and last name, sorted by staff last name ascending.

[Assistant]
SELECT s.first_name AS staff_first_name,
       s.last_name AS staff_last_name,
       s.position,
       m.first_name AS manager_first_name,
       m.last_name AS manager_last_name
FROM hospitality_technology.staff s
JOIN hospitality_technology.staff m
  ON s.manager_id = m.staff_id
WHERE s.manager_id IS NOT NULL
ORDER BY s.last_name ASC;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp )
CREATE TABLE trading_platform.orders ( order_id.text, user_id.text, wallet_id.text, asset_id.text, order_type.text, quantity.numeric, price.numeric, status.text, created_at.timestamp )
CREATE TABLE trading_platform.trades ( trade_id.text, order_id.text, buyer_id.text, seller_id.text, asset_id.text, quantity.numeric, price.numeric, traded_at.timestamp )
CREATE TABLE trading_platform.utxos ( utxo_id.text, transaction_id.text, output_index.integer, address.text, amount.numeric, spent.boolean )

[User] Show me all trades where the traded quantity is less than 2, including the trade_id, quantity, and the buyer and seller IDs.

[Assistant]
SELECT trade_id, quantity, buyer_id, seller_id
FROM trading_platform.trades
WHERE quantity < 2;

[User] Now, include the asset_id and the traded price in the result.

[Assistant]
SELECT trade_id, asset_id, quantity, price, buyer_id, seller_id
FROM trading_platform.trades
WHERE quantity < 2;

[User] What if I just want to see trades where either the buyer_id or seller_id is 'user_x123'?

[Assistant]
SELECT trade_id, asset_id, quantity, price, buyer_id, seller_id
FROM trading_platform.trades
WHERE quantity < 2
  AND (buyer_id = 'user_x123' OR seller_id = 'user_x123');

[User] The query is missing the trade's order_id. Please include it as well.

[Assistant]
SELECT trade_id, order_id, asset_id, quantity, price, buyer_id, seller_id
FROM trading_platform.trades
WHERE quantity < 2
  AND (buyer_id = 'user_x123' OR seller_id = 'user_x123');


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE web3.events ( event_id.text, contract_id.text, event_name.text, data.text, emitted_at.timestamp, transaction_id.text, log_index.integer )
CREATE TABLE web3.tokens (
    token_id character varying(64) NOT NULL,  -- unique identifier for the token
    contract_address character varying(128) NOT NULL, -- address of the token contract
    token_name character varying(128) NOT NULL, -- name of the token
    token_symbol character varying(32) NOT NULL, -- symbol of the token
    decimals integer NOT NULL, -- number of decimals for the token
    total_supply numeric(38,14) NOT NULL, -- total supply of the token
    PRIMARY KEY (token_id)
)
CREATE TABLE web3.token_transfers ( transfer_id text PRIMARY KEY, token_id text, from_address text, to_address text, value numeric, transaction_id text, log_index int )

[User] Find token transfers that correspond directly to an event log (same transaction and log index). List the transfer ID, value, and the event name.

[Assistant] SELECT T1.transfer_id, T1.value, T2.event_name FROM web3.token_transfers AS T1 JOIN web3.events AS T2 ON T1.transaction_id = T2.transaction_id AND T1.log_index = T2.log_index;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE trading_platform.wallets (
    wallet_id character varying(64) NOT NULL,  -- unique identifier for the wallet
    user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet
    address character varying(128) NOT NULL, -- address of the wallet
    private_key text NOT NULL, -- private key of the wallet
    created_at timestamp NOT NULL, -- time when the wallet was created
    PRIMARY KEY (wallet_id)
)
CREATE TABLE trading_platform.orders (
    order_id character varying(64) NOT NULL,  -- unique identifier for the order
    user_id character varying(64) NOT NULL, -- identifier of the user placing the order
    wallet_id character varying(64) NOT NULL, -- identifier of the wallet used for the order
    asset_id character varying(64) NOT NULL, -- identifier of the asset being traded
    order_type character varying(32) NOT NULL, -- type of the order (e.g., buy, sell)
    quantity numeric(38,14) NOT NULL, -- quantity of the asset in the order
    price numeric(38,14) NOT NULL, -- price per unit of the asset
    status character varying(32) NOT NULL, -- status of the order (e.g., open, filled, canceled)
    created_at timestamp NOT NULL, -- time when the order was created
    PRIMARY KEY (order_id)
)
CREATE TABLE trading_platform.assets (
    asset_id character varying(64) NOT NULL,  -- unique identifier for the asset
    name character varying(128) NOT NULL, -- name of the asset
    symbol character varying(32) NOT NULL, -- symbol of the asset
    type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock)
    PRIMARY KEY (asset_id)
)
CREATE TABLE trading_platform.utxos (
    utxo_id character varying(64) NOT NULL,  -- unique identifier for the UTXO
    transaction_id character varying(64) NOT NULL, -- identifier of the transaction that created the UTXO
    output_index integer NOT NULL, -- index of the output in the transaction
    address character varying(128) NOT NULL, -- address that can spend the UTXO
    amount numeric(38,14) NOT NULL, -- amount of the asset in the UTXO
    spent boolean NOT NULL, -- whether the UTXO has been spent
    PRIMARY KEY (utxo_id)
)
CREATE TABLE trading_platform.dapps (
    dapp_id character varying(64) NOT NULL,  -- unique identifier for the DApp
    name character varying(128) NOT NULL, -- name of the DApp
    description text NOT NULL, -- description of the DApp
    url character varying(256) NOT NULL, -- URL of the DApp
    PRIMARY KEY (dapp_id)
)
CREATE TABLE trading_platform.peers (
    peer_id character varying(64) NOT NULL,  -- unique identifier for the peer
    ip_address character varying(15) NOT NULL, -- IP address of the peer
    port integer NOT NULL, -- port number of the peer
    last_seen timestamp NOT NULL, -- last time the peer was active
    PRIMARY KEY (peer_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.kyc_audit (
    kyc_audit_id character varying(64) NOT NULL,  -- unique identifier for the KYC audit
    user_id character varying(64) NOT NULL, -- identifier of the user being audited
    status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected)
    reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed
    PRIMARY KEY (kyc_audit_id)
)
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] List each asset's name and symbol along with the total number of open orders for that asset.

[Assistant]
SELECT a.name,
       a.symbol,
       COUNT(o.order_id) AS open_order_count
FROM trading_platform.assets a
LEFT JOIN trading_platform.orders o
  ON a.asset_id = o.asset_id
  AND o.status = 'open'
GROUP BY a.name, a.symbol;

[User] Now restrict the results to only assets with more than 5 open orders.

[Assistant]
SELECT a.name,
       a.symbol,
       COUNT(o.order_id) AS open_order_count
FROM trading_platform.assets a
LEFT JOIN trading_platform.orders o
  ON a.asset_id = o.asset_id
  AND o.status = 'open'
GROUP BY a.name, a.symbol
HAVING COUNT(o.order_id) > 5;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )
CREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )
CREATE TABLE healthcare.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) )

[User] Show me prescriptions with a route of 'Intravenous' and a frequency of 'Once Daily'. I need the prescription ID, medication ID, route, and frequency.

[Assistant] SELECT prescription_id ,  medication_id ,  route ,  frequency FROM healthcare.prescriptions WHERE route  =  'Intravenous' AND frequency  =  'Once Daily'

[User] Filter the previous list to only show prescriptions where the quantity dispensed is less than 10 and the end date is not null. Include the quantity dispensed and end date in the results.

[Assistant] SELECT prescription_id ,  medication_id ,  route ,  frequency ,  quantity_dispensed ,  end_date FROM healthcare.prescriptions WHERE route  =  'Intravenous' AND frequency  =  'Once Daily' AND quantity_dispensed  <  10 AND end_date IS NOT NULL


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )

[User] List all insurance providers along with the total number of plans they offer.

[Assistant]
SELECT insurance_provider, COUNT(*) AS plan_count
FROM healthcare.insurance_plans
GROUP BY insurance_provider;

[User] Only show providers with more than 2 plans.

[Assistant]
SELECT insurance_provider, COUNT(*) AS plan_count
FROM healthcare.insurance_plans
GROUP BY insurance_provider
HAVING COUNT(*) > 2;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors (
    doctor_id character varying(64) NOT NULL,  -- unique identifier for the doctor
    first_name character varying(100) NOT NULL, -- doctor's first name
    last_name character varying(100) NOT NULL, -- doctor's last name
    specialty character varying(100) NOT NULL, -- doctor's medical specialty
    license_number character varying(50) UNIQUE NOT NULL, -- doctor's medical license number
    phone_number character varying(20), -- doctor's contact phone
    email character varying(128) UNIQUE, -- doctor's contact email
    hospital_affiliation_id character varying(64), -- FK to hospitals table (optional)
    created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
    updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
    PRIMARY KEY (doctor_id)
)
CREATE TABLE healthcare.insurance_plans (
    plan_id character varying(64) NOT NULL, -- unique identifier for the insurance plan
    plan_name character varying(200) NOT NULL, -- name of the insurance plan
    insurance_provider character varying(100) NOT NULL, -- name of the insurance company
    plan_type character varying(50), -- e.g., PPO, HMO, EPO
    contact_phone character varying(20), -- provider contact number
    website character varying(255), -- provider website
    PRIMARY KEY (plan_id)
)

[User] Show each insurance plan name along with the number of doctors whose phone number matches the plan's contact_phone.

[Assistant]
SELECT p.plan_name, COUNT(d.doctor_id) AS matching_doctors
FROM healthcare.insurance_plans p
LEFT JOIN healthcare.doctors d ON p.contact_phone = d.phone_number
GROUP BY p.plan_name;


System:
You are very professional for database language writing. You 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 nft_holders ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )
CREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer )
CREATE TABLE sui_coins_metadata ( object_id.text, coin_type.text, status.text, decimals.bigint, description.text, icon_url.text, symbol.text, name.text )
CREATE TABLE sui_nfts ( object_id.text, status.text, collection_type.text, package_id.text, previous_transaction.text, display.text, owner.text, name.text )
CREATE TABLE nft_collections ( blockchain.text, contract_address.text, name.text, symbol.text, deploy_block_number.bigint, deploy_block_time.bigint, erc_type.text, owner.text, traits.text, description.text, slug.text, media_info.text, image_url.text, banner_image_url.text, updated_at.bigint, banner.text, token_count.bigint, floor_price.text, floor_price_symbol.text, floor_price_contract.text, pk.integer )
CREATE TABLE token_prices ( uuid.text, blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )
CREATE TABLE token_prices_latest ( blockchain.text, address.text, decimals.bigint, symbol.text, price.real, timestamp.timestamp )
CREATE TABLE token_balances_bitcoin ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.text, amount.text )
CREATE TABLE token_balances_avalanche ( block_number.bigint, block_timestamp.timestamp, tick.text, wallet_address.text, total_supply.decimal, amount.decimal )

[User] Show the contract address, symbol, and current total supply for all Avalanche tokens from token_balances_avalanche.

[Assistant]
SELECT tick AS contract_address, tick AS symbol, SUM(total_supply) AS current_total_supply
FROM token_balances_avalanche
GROUP BY tick;

[User] Now, include the latest price for each token by joining with token_prices_latest.

[Assistant]
SELECT tba.tick AS contract_address, tba.tick AS symbol, SUM(tba.total_supply) AS current_total_supply, tpl.price AS latest_price
FROM token_balances_avalanche tba
LEFT JOIN token_prices_latest tpl
  ON tpl.address = tba.tick AND tpl.blockchain = 'Avalanche'
GROUP BY tba.tick, tpl.price;

[User] Filter out tokens where the current_total_supply is less than 1000 and sort the results by latest_price descending.

[Assistant]
SELECT tba.tick AS contract_address, tba.tick AS symbol, SUM(tba.total_supply) AS current_total_supply, tpl.price AS latest_price
FROM token_balances_avalanche tba
LEFT JOIN token_prices_latest tpl
  ON tpl.address = tba.tick AND tpl.blockchain = 'Avalanche'
GROUP BY tba.tick, tpl.price
HAVING SUM(tba.total_supply) >= 1000
ORDER BY tpl.price DESC;


System:
You are very professional for database language writing. You 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.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) )

[User] Provide each game_id with the item_name of its cheapest item and its most expensive item.

[Assistant]
SELECT min_items.game_id,
       min_items.item_name AS cheapest_item,
       max_items.item_name AS most_expensive_item
FROM gaming_technology.in_game_items min_items
JOIN gaming_technology.in_game_items max_items
  ON min_items.game_id = max_items.game_id
WHERE min_items.cost_amount = (
        SELECT MIN(cost_amount)
        FROM gaming_technology.in_game_items
        WHERE game_id = min_items.game_id
      )
  AND max_items.cost_amount = (
        SELECT MAX(cost_amount)
        FROM gaming_technology.in_game_items
        WHERE game_id = max_items.game_id
      );

[User] Only include games that have more than one item available.

[Assistant]
SELECT t.game_id,
       t.cheapest_item,
       t.most_expensive_item
FROM (
  SELECT min_items.game_id,
         min_items.item_name AS cheapest_item,
         max_items.item_name AS most_expensive_item
  FROM gaming_technology.in_game_items min_items
  JOIN gaming_technology.in_game_items max_items
    ON min_items.game_id = max_items.game_id
  WHERE min_items.cost_amount = (
          SELECT MIN(cost_amount)
          FROM gaming_technology.in_game_items
          WHERE game_id = min_items.game_id
        )
    AND max_items.cost_amount = (
          SELECT MAX(cost_amount)
          FROM gaming_technology.in_game_items
          WHERE game_id = max_items.game_id
        )
) t
JOIN (
  SELECT game_id
  FROM gaming_technology.in_game_items
  GROUP BY game_id
  HAVING COUNT(*) > 1
) g
  ON t.game_id = g.game_id;

[User] Finally, order the results by game_id descending.

[Assistant]
SELECT t.game_id,
       t.cheapest_item,
       t.most_expensive_item
FROM (
  SELECT min_items.game_id,
         min_items.item_name AS cheapest_item,
         max_items.item_name AS most_expensive_item
  FROM gaming_technology.in_game_items min_items
  JOIN gaming_technology.in_game_items max_items
    ON min_items.game_id = max_items.game_id
  WHERE min_items.cost_amount = (
          SELECT MIN(cost_amount)
          FROM gaming_technology.in_game_items
          WHERE game_id = min_items.game_id
        )
    AND max_items.cost_amount = (
          SELECT MAX(cost_amount)
          FROM gaming_technology.in_game_items
          WHERE game_id = max_items.game_id
        )
) t
JOIN (
  SELECT game_id
  FROM gaming_technology.in_game_items
  GROUP BY game_id
  HAVING COUNT(*) > 1
) g
  ON t.game_id = g.game_id
ORDER BY t.game_id DESC;


System:
You are very professional for database language writing and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE manufacturing.component_inventory (
    inventory_record_id character varying(64) NOT NULL, -- unique ID for this inventory record/batch
    component_id character varying(64) NOT NULL, -- FK to the component
    quantity integer NOT NULL, -- number of units of this component in stock for this batch
    location_warehouse character varying(100), -- warehouse identifier
    location_bin character varying(100), -- specific bin or shelf location
    received_date timestamp NOT NULL, -- when this batch was received
    expiry_date date, -- expiry date if applicable (e.g., for sealants, adhesives)
    batch_number character varying(100), -- supplier batch number
    last_updated timestamp NOT NULL, -- timestamp of the last update to this record
    PRIMARY KEY (inventory_record_id)
)

[User] What is the purchase price of the components in a specific batch with batch_number 'BATCH123'?

[Assistant] I'm sorry, but I can't provide information on the purchase price of components as this data is not stored in the component_inventory table. If you have other questions or need assistance with data available in the table, such as quantity or location, I'm happy to help.


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government_services.service_locations (
    location_id character varying(64) NOT NULL, -- unique identifier for the physical location
    agency_id character varying(64) NOT NULL, -- FK to agencies table
    location_name character varying(200), -- e.g., Downtown DMV Office
    address text NOT NULL,
    city character varying(100),
    state character varying(50),
    postal_code character varying(20),
    latitude numeric(9, 6),
    longitude numeric(9, 6),
    operating_hours text, -- description of opening times
    contact_phone character varying(32),
    is_accessible boolean, -- accessibility information (e.g., wheelchair access)
    PRIMARY KEY (location_id)
)

[User] Find all service locations whose postal code starts with '75' and display their names, cities, and operating hours, including the agency ID.

[Assistant] SELECT location_name, city, operating_hours, agency_id FROM government_services.service_locations WHERE postal_code LIKE '75%';


System:
You are very professional for database language writing. You 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 )
CREATE TABLE token_basic_info ( coin_id character varying(100) NOT NULL, -- the id of the token token_name character varying(100) NOT NULL, -- the token's name token_symbol character varying(100) NOT NULL, -- the token's symbol token_address character varying(100) NOT NULL, -- the token's address chain text, -- the chain that the token resides price double precision, -- the current price of the token price_change_percentage_1h double precision, -- change in value divided by the absolute price value of the original token price in 1 hour price_change_percentage_24h double precision, -- change in value divided by the absolute price value of the original token price in 24 hours price_change_percentage_7d double precision, -- change in value divided by the absolute price value of the original token price in 7 days highest_price_24h double precision, -- the highest price of the token in 24 hours lowest_price_24h double precision,  -- the lowest price of the token in 24 hours market_cap double precision, -- the market cap of the token market_cap_rank bigint, -- the rank of the token market cap in desc market_cap_change_percentage_24h text, -- the percentage of market cap changes in 24 hours total_volume text, -- the trade volum of the token both in decentralized exchange(DEX) and centralized exchange(CEX) narrative text, -- the category or narrative of the token trend_rank biging, -- the trending rank of the token, value 1 expresses the most popular token. ,PRIMARY KEY (coin_id, chain) )
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 cex_token_balance ( snapshot_time character varying(32) NOT NULL,  -- the snapshot time of record, converted from original timestamp chain character varying(128) NOT NULL, -- the chain that the token resides address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX exchange character varying(512) NOT NULL, -- a centralized exchange name token_address character varying(128) NOT NULL, -- token contract address token_symbol character varying(512), --token symbol balance numeric(38,10), -- token balance usd_value numeric(38,14), -- value of the token held in USD price double precision, --price of the token in USD ,PRIMARY KEY (snapshot_time, exchange, address, chain, token_address) )
CREATE TABLE smart_money_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] Show me the average smart money ROI and the total PNL for each narrative category, based on the `smart_money_token_performance` and `token_basic_info` tables.

[Assistant] SELECT tbi.narrative, AVG(smp.roi) AS average_roi, SUM(smp.pnl) AS total_pnl FROM smart_money_token_performance smp JOIN token_basic_info tbi ON smp.token_symbol = tbi.token_symbol GROUP BY tbi.narrative ORDER BY average_roi DESC;

[User] Filter the results to only include narratives with an average ROI greater than 1 (100%) and a total PNL greater than 0. Order by total PNL descending.

[Assistant] SELECT tbi.narrative, AVG(smp.roi) AS average_roi, SUM(smp.pnl) AS total_pnl FROM smart_money_token_performance smp JOIN token_basic_info tbi ON smp.token_symbol = tbi.token_symbol GROUP BY tbi.narrative HAVING AVG(smp.roi) > 1 AND SUM(smp.pnl) > 0 ORDER BY total_pnl DESC;

[User] Break down these results by chain as well. Show narrative, chain, average ROI, and total PNL for narratives with average ROI > 1 and total PNL > 0 on each chain.

[Assistant] SELECT tbi.narrative, smp.chain, AVG(smp.roi) AS average_roi, SUM(smp.pnl) AS total_pnl FROM smart_money_token_performance smp JOIN token_basic_info tbi ON smp.token_symbol = tbi.token_symbol AND smp.chain = tbi.chain GROUP BY tbi.narrative, smp.chain HAVING AVG(smp.roi) > 1 AND SUM(smp.pnl) > 0 ORDER BY total_pnl DESC;

[User] Now, only show results where the total PNL is greater than $50,000 AND the number of unique tokens contributing to this PNL for that narrative and chain is at least 3. Include the count of unique tokens. Order by total PNL descending and limit to the top 10.

[Assistant] SELECT tbi.narrative, smp.chain, AVG(smp.roi) AS average_roi, SUM(smp.pnl) AS total_pnl, COUNT(DISTINCT smp.token_symbol) AS unique_token_count FROM smart_money_token_performance smp JOIN token_basic_info tbi ON smp.token_symbol = tbi.token_symbol AND smp.chain = tbi.chain GROUP BY tbi.narrative, smp.chain HAVING AVG(smp.roi) > 1 AND SUM(smp.pnl) > 50000 AND COUNT(DISTINCT smp.token_symbol) >= 3 ORDER BY total_pnl DESC LIMIT 10;


System:
You are very professional for database language writing. You 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 erc1155_approval_for_all ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text )
CREATE TABLE erc20_balances ( block_number bigint, contract_address text, wallet_address text, amount text, pk text )
CREATE TABLE erc20_balances_historical ( block_number bigint, contract_address text, wallet_address text, amount text, pk integer )
CREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text )
CREATE TABLE nft_holder_historical ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk integer )
CREATE TABLE sui_coins ( object_id text, status text, coin_type text, balance text, owner text )
CREATE TABLE sui_coins_metadata ( object_id text, coin_type text, status text, decimals bigint, description text, icon_url text, symbol text, name text )
CREATE TABLE sui_nfts ( object_id text, status text, collection_type text, package_id text, previous_transaction text, display text, owner text, name text )
CREATE TABLE nft_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 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_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_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 )

[User] Show me the total balance for each SUI coin type for coins with status 'exists'. Include the coin type and the sum of balances.

[Assistant] SELECT coin_type, SUM(CAST(balance AS DECIMAL)) AS total_balance FROM sui_coins WHERE status = 'exists' GROUP BY coin_type

[User] Add the symbol and name for each coin type by joining with the metadata table. Only include metadata entries where status is also 'exists'.

[Assistant] SELECT t1.coin_type, t2.symbol, t2.name, SUM(CAST(t1.balance AS DECIMAL)) AS total_balance FROM sui_coins AS t1 JOIN sui_coins_metadata AS t2 ON t1.coin_type = t2.coin_type WHERE t1.status = 'exists' AND t2.status = 'exists' GROUP BY t1.coin_type, t2.symbol, t2.name

[User] Only show coin types where the total balance is greater than 1000000000000 and order by total balance descending.

[Assistant] SELECT t1.coin_type, t2.symbol, t2.name, SUM(CAST(t1.balance AS DECIMAL)) AS total_balance FROM sui_coins AS t1 JOIN sui_coins_metadata AS t2 ON t1.coin_type = t2.coin_type WHERE t1.status = 'exists' AND t2.status = 'exists' GROUP BY t1.coin_type, t2.symbol, t2.name HAVING SUM(CAST(t1.balance AS DECIMAL)) > 1000000000000 ORDER BY total_balance DESC

[User] Filter these results further to only include coin types whose description in the metadata contains 'Liquid Staking'. Limit to the top 5.

[Assistant] SELECT t1.coin_type, t2.symbol, t2.name, SUM(CAST(t1.balance AS DECIMAL)) AS total_balance FROM sui_coins AS t1 JOIN sui_coins_metadata AS t2 ON t1.coin_type = t2.coin_type WHERE t1.status = 'exists' AND t2.status = 'exists' AND t2.description LIKE '%Liquid Staking%' GROUP BY t1.coin_type, t2.symbol, t2.name HAVING SUM(CAST(t1.balance AS DECIMAL)) > 1000000000000 ORDER BY total_balance DESC LIMIT 5


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.vehicles (
    vehicle_id character varying(64) NOT NULL,  -- unique identifier for the vehicle
    license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate
    vin character varying(17) UNIQUE, -- vehicle identification number
    make character varying(64) NOT NULL, -- manufacturer of the vehicle
    model character varying(64) NOT NULL, -- model of the vehicle
    year integer NOT NULL, -- manufacturing year
    type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van)
    capacity integer, -- passenger or cargo capacity
    fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen
    status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned
    depot_id character varying(64), -- identifier of the home depot/base
    acquisition_date date, -- date the vehicle was acquired
    PRIMARY KEY (vehicle_id)
)
CREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text )
CREATE TABLE transportation.passengers ( passenger_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp )
CREATE TABLE transportation.bookings ( booking_id character varying(64) NOT NULL, passenger_id character varying(64) NOT NULL, trip_id character varying(64) NOT NULL, seat_number character varying(16), booking_time timestamp with time zone NOT NULL, status character varying(32) NOT NULL, fare numeric(10, 2) NOT NULL, payment_transaction_id character varying(128), special_requests text, PRIMARY KEY (booking_id) )

[User] List all passengers who have made a booking for a trip on a route that covers more than 100 kilometers. Include the passenger's full name, email, the route number, and the distance in km.

[Assistant]
SELECT p.first_name, p.last_name, p.email, r.route_number, r.distance_km
FROM transportation.bookings b
JOIN transportation.passengers p ON b.passenger_id = p.passenger_id
JOIN transportation.routes r ON b.trip_id = r.route_id
WHERE r.distance_km > 100;


System:
You are very professional for database language writing. You 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 NOT NULL, -- Block number containing the transaction
    block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction
    transaction_index integer NOT NULL, -- Index of the transaction within the block
    transaction_hash varchar(66) NOT NULL, -- Transaction hash
    log_index integer NOT NULL, -- Log index
    contract_address varchar(42) NOT NULL  -- Event contract address
)
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.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.text )
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, -- object id of the coin metadata object
    coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN
    status varchar NOT NULL, -- coin status, eg. exists, deleted
    decimals bigint NOT NULL, -- decimals of the coin
    description varchar NOT NULL, -- description of the coin
    icon_url varchar NOT NULL, -- icon url of the coin
    symbol varchar NOT NULL, -- symbol of the coin
    name varchar NOT NULL  -- name of the coin
)
CREATE TABLE nft_collections ( blockchain varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )
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 NOT NULL, -- Block number containing the transaction
    block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction
    tick varchar NOT NULL, -- Token tick
    wallet_address varchar(42) NOT NULL, -- Address of owner
    total_supply decimal(38,0) NOT NULL, -- Max supply
    amount decimal(38,0) NOT NULL  -- The balance of wallet balance at the corresponding block height
)
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 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 NOT NULL, -- Block number containing the transaction
    block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction
    tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription
    wallet_address varchar(42) NOT NULL, -- Address of owner
    total_supply varchar NOT NULL, -- Max supply: Set max supply of the inscription
    amount varchar NOT NULL  -- The balance of wallet balance at the corresponding block height
)
CREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text )
CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )
CREATE TABLE token_balances_avalanche (
    block_number bigint NOT NULL, -- Block number containing the transaction
    block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction
    tick varchar(20) NOT NULL, -- Ticker: Identifier of the inscription
    wallet_address varchar(42) NOT NULL, -- Address of owner
    total_supply decimal(38,0) NOT NULL, -- Max supply: Set max supply of the inscription
    amount decimal(38,0) NOT NULL  -- The balance of wallet balance at the corresponding block height
)
CREATE TABLE token_info_avalanche ( block_timestamp timestamp, 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] List all active SUI coins with their symbol, name, and total balance across all owners.

[Assistant]
SELECT scm.coin_type, scm.symbol, scm.name, SUM(CAST(sc.balance AS DECIMAL)) AS total_balance
FROM sui_coins_metadata scm
JOIN sui_coins sc ON sc.coin_type = scm.coin_type
WHERE sc.status = 'active' AND scm.status = 'exists'
GROUP BY scm.coin_type, scm.symbol, scm.name;

[User] Filter coins with description containing 'staking' and sort by total_balance descending.

[Assistant]
SELECT sub.coin_type, sub.symbol, sub.name, sub.total_balance
FROM (
  SELECT scm.coin_type, scm.symbol, scm.name, SUM(CAST(sc.balance AS DECIMAL)) AS total_balance
  FROM sui_coins_metadata scm
  JOIN sui_coins sc ON sc.coin_type = scm.coin_type
  WHERE sc.status = 'active' AND scm.status = 'exists' AND LOWER(scm.description) LIKE '%staking%'
  GROUP BY scm.coin_type, scm.symbol, scm.name
) sub
ORDER BY sub.total_balance DESC;

[User] Limit the result to the top 3 coins.

[Assistant]
SELECT sub.coin_type, sub.symbol, sub.name, sub.total_balance
FROM (
  SELECT scm.coin_type, scm.symbol, scm.name, SUM(CAST(sc.balance AS DECIMAL)) AS total_balance
  FROM sui_coins_metadata scm
  JOIN sui_coins sc ON sc.coin_type = scm.coin_type
  WHERE sc.status = 'active' AND scm.status = 'exists' AND LOWER(scm.description) LIKE '%staking%'
  GROUP BY scm.coin_type, scm.symbol, scm.name
) sub
ORDER BY sub.total_balance DESC
LIMIT 3;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE hospitality_technology.guests ( guest_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, address_line1.text, city.text, state_province.text, postal_code.text, country_code.text, preferences.text, loyalty_member_id.text, communication_consent.boolean, created_at.timestamp, updated_at.timestamp )

[User] List the first and last names of guests residing in California who are loyalty members.

[Assistant] SELECT first_name, last_name FROM hospitality_technology.guests WHERE state_province = 'California' AND loyalty_member_id IS NOT NULL;

[User] Now, only include those who have communication consent enabled and sort by last name.

[Assistant] SELECT first_name, last_name FROM hospitality_technology.guests WHERE state_province = 'California' AND loyalty_member_id IS NOT NULL AND communication_consent = TRUE ORDER BY last_name;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.routes ( route_id text PRIMARY KEY, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes int, type text )

[User] Find all pairs of origin and destination cities, along with their route_number and distance, where the estimated duration is less than 90 minutes.

[Assistant] SELECT route_number, origin_location_id, destination_location_id, distance_km FROM transportation.routes WHERE estimated_duration_minutes < 90;


System:
You are very professional for database language writing. You 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 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 nft_holder_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, token_id varchar NOT NULL, contract_type varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE sui_coins_metadata (
    object_id varchar NOT NULL, -- object id of the coin metadata object
    coin_type varchar NOT NULL, -- coin type, eg. 0x...66::reap_token::REAP_TOKEN
    status varchar NOT NULL, -- coin status, eg. exists, deleted
    decimals bigint NOT NULL, -- decimals of the coin
    description varchar NOT NULL, -- description of the coin
    icon_url varchar NOT NULL, -- icon url of the coin
    symbol varchar NOT NULL, -- symbol of the coin
    name varchar NOT NULL  -- name of the coin
)
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 varchar NOT NULL, contract_address varchar NOT NULL, name varchar NOT NULL, symbol varchar NOT NULL, deploy_block_number bigint NOT NULL, deploy_block_time bigint NOT NULL, erc_type varchar NOT NULL, owner varchar NOT NULL, traits varchar NOT NULL, description varchar NOT NULL, slug varchar NOT NULL, media_info varchar NOT NULL, image_url varchar NOT NULL, banner_image_url varchar NOT NULL, updated_at bigint NOT NULL, banner varchar NOT NULL, token_count bigint NOT NULL, floor_price varchar NOT NULL, floor_price_symbol varchar NOT NULL, floor_price_contract varchar NOT NULL, pk integer NOT NULL )
CREATE TABLE token_prices ( uuid text, blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp )
CREATE TABLE token_info (
    block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table)
    block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table)
    tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table)
    tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table)
    tick varchar NOT NULL, -- Token tick
    max_supply decimal(38,0) NOT NULL, -- Max supply
    lim decimal(38,0) NOT NULL, -- Limit of each mint
    wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint
    dec integer NOT NULL, -- Decimal for minimum divie
    creator varchar(42) NOT NULL  -- Address originating the inscription (matches from_address in transactions table)
)
CREATE TABLE token_activities ( 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_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text )
CREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick 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 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 ERC20 tokens with total supply greater than 100,000,000, displaying symbol, name, contract address, and total supply from the token_metas table.

[Assistant] SELECT symbol, name, contract_address, total_supply FROM token_metas WHERE total_supply > '100000000';

[User] Include the number of decimals for each token and the latest USD price by joining with token_prices_latest.

[Assistant] SELECT tm.symbol, tm.name, tm.contract_address, tm.total_supply, tm.decimals, tpl.price FROM token_metas tm JOIN token_prices_latest tpl ON tm.contract_address = tpl.address WHERE tm.total_supply > '100000000';

[User] Filter the results to only include tokens where the latest USD price is less than 1.0.

[Assistant] SELECT tm.symbol, tm.name, tm.contract_address, tm.total_supply, tm.decimals, tpl.price FROM token_metas tm JOIN token_prices_latest tpl ON tm.contract_address = tpl.address WHERE tm.total_supply > '100000000' AND tpl.price < 1.0;

[User] Order the results by total supply descending and limit to the top 15 tokens.

[Assistant] SELECT tm.symbol, tm.name, tm.contract_address, tm.total_supply, tm.decimals, tpl.price FROM token_metas tm JOIN token_prices_latest tpl ON tm.contract_address = tpl.address WHERE tm.total_supply > '100000000' AND tpl.price < 1.0 ORDER BY CAST(tm.total_supply AS REAL) DESC LIMIT 15;


[User] Could you list projects that have completed more than one fundraising round, showing the project name and the number of rounds?

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

[User] For these projects with multiple rounds, can you show the earliest and latest investment date and the corresponding investment value for each project?

[Assistant] WITH ProjectRounds AS ( SELECT project_id, project_name, investment_value, investment_date, ROW_NUMBER() OVER(PARTITION BY project_id ORDER BY investment_date ASC) as rn_earliest, ROW_NUMBER() OVER(PARTITION BY project_id ORDER BY investment_date DESC) as rn_latest FROM project_fundraising_record ) SELECT pr_earliest.project_name, pr_earliest.investment_date AS earliest_date, pr_earliest.investment_value AS earliest_investment, pr_latest.investment_date AS latest_date, pr_latest.investment_value AS latest_investment FROM ProjectRounds pr_earliest JOIN ProjectRounds pr_latest ON pr_earliest.project_id = pr_latest.project_id WHERE pr_earliest.rn_earliest = 1 AND pr_latest.rn_latest = 1 AND pr_earliest.project_id IN ( SELECT project_id FROM project_fundraising_record GROUP BY project_id HAVING COUNT(*) > 1 ) ORDER BY pr_latest.investment_date DESC;

[User] Now, for those projects that also have a matching token, link the latest investment value to the token's current price and its smart money ROI. Match project name to token symbol or name case-insensitively.

[Assistant] WITH ProjectLatestRound AS ( SELECT project_id, project_name, investment_value, investment_date, ROW_NUMBER() OVER(PARTITION BY project_id ORDER BY investment_date DESC) as rn FROM project_fundraising_record WHERE project_id IN ( SELECT project_id FROM project_fundraising_record GROUP BY project_id HAVING COUNT(*) > 1 ) ) SELECT plr.project_name, plr.investment_value AS latest_investment, tbi.token_symbol, tbi.price AS current_token_price, smp.roi AS smart_money_roi FROM ProjectLatestRound plr JOIN token_basic_info tbi ON LOWER(tbi.token_symbol) LIKE '%' || LOWER(plr.project_name) || '%' OR LOWER(plr.project_name) LIKE '%' || LOWER(tbi.token_symbol) || '%' OR LOWER(tbi.token_name) LIKE '%' || LOWER(plr.project_name) || '%' OR LOWER(plr.project_name) LIKE '%' || LOWER(tbi.token_name) || '%' LEFT JOIN smart_money_token_performance smp ON tbi.token_symbol = smp.token_symbol WHERE plr.rn = 1;

[User] Filter the results to only include projects where the latest investment value is greater than $1,000,000 AND the token's smart money ROI is positive (greater than 0). Order the results by smart money ROI descending and show the top 10.

[Assistant] WITH ProjectLatestRound AS ( SELECT project_id, project_name, investment_value, investment_date, ROW_NUMBER() OVER(PARTITION BY project_id ORDER BY investment_date DESC) as rn FROM project_fundraising_record WHERE project_id IN ( SELECT project_id FROM project_fundraising_record GROUP BY project_id HAVING COUNT(*) > 1 ) ) SELECT plr.project_name, plr.investment_value AS latest_investment, tbi.token_symbol, tbi.price AS current_token_price, smp.roi AS smart_money_roi FROM ProjectLatestRound plr JOIN token_basic_info tbi ON LOWER(tbi.token_symbol) LIKE '%' || LOWER(plr.project_name) || '%' OR LOWER(plr.project_name) LIKE '%' || LOWER(tbi.token_symbol) || '%' OR LOWER(tbi.token_name) LIKE '%' || LOWER(plr.project_name) || '%' OR LOWER(plr.project_name) LIKE '%' || LOWER(tbi.token_name) || '%' JOIN smart_money_token_performance smp ON tbi.token_symbol = smp.token_symbol WHERE plr.rn = 1 AND plr.investment_value > 1000000 AND smp.roi > 0 ORDER BY smp.roi DESC LIMIT 10;


System:
You are very professional for database language writing. You 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, 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.market_data ( data_point_id bigserial NOT NULL, security_id character varying(64) NOT NULL, data_timestamp timestamp NOT NULL, open_price numeric(19, 8), high_price numeric(19, 8), low_price numeric(19, 8), close_price numeric(19, 8) NOT NULL, adjusted_close_price numeric(19, 8), volume bigint, source character varying(50), PRIMARY KEY (data_point_id), UNIQUE (security_id, data_timestamp), FOREIGN KEY (security_id) REFERENCES financial_services.securities(security_id) )

[User] Retrieve each customer_id, first_name, last_name, and close_price for market_data entries that occurred on the day of their account creation.

[Assistant] SELECT c.customer_id, c.first_name, c.last_name, md.close_price FROM financial_services.customers c JOIN financial_services.market_data md ON DATE(c.created_at) = DATE(md.data_timestamp);

[User] Actually, I want the adjusted_close_price instead of close_price.

[Assistant] SELECT c.customer_id, c.first_name, c.last_name, md.adjusted_close_price FROM financial_services.customers c JOIN financial_services.market_data md ON DATE(c.created_at) = DATE(md.data_timestamp);

[User] And only include records where the volume is greater than 1000.

[Assistant] SELECT c.customer_id, c.first_name, c.last_name, md.adjusted_close_price FROM financial_services.customers c JOIN financial_services.market_data md ON DATE(c.created_at) = DATE(md.data_timestamp) WHERE md.volume > 1000;


System:
You are very professional for database language writing. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE insurance.customers ( customer_id 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 )
CREATE TABLE insurance.claims (
    claim_id character varying(64) NOT NULL, -- unique identifier for the claim
    policy_id character varying(64) NOT NULL, -- identifier of the policy under which the claim is made (FK to policies)
    customer_id character varying(64) NOT NULL, -- identifier of the customer making the claim (FK to customers)
    incident_date timestamp NOT NULL, -- date and time of the incident leading to the claim
    reported_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the claim was reported
    description text NOT NULL, -- detailed description of the incident and claim
    estimated_loss numeric(15, 2), -- initial estimated cost of the loss
    status character varying(30) NOT NULL, -- e.g., Filed, Processing, Under Review, Approved, Denied, Settled
    settlement_amount numeric(15, 2), -- final amount paid out
    settlement_date date,
    claim_handler_id character varying(64), -- identifier for the employee handling the claim (FK to employees/adjusters)
    police_report_number character varying(100),
    PRIMARY KEY (claim_id)
)
CREATE TABLE insurance.insurance_products (
    product_id character varying(64) NOT NULL, -- unique identifier for the insurance product
    product_name character varying(150) NOT NULL, -- name of the insurance product (e.g., 'Comprehensive Auto Insurance')
    product_type character varying(50) NOT NULL, -- category like 'Auto', 'Home', 'Life', 'Health', 'Travel'
    description text, -- detailed description of the product
    base_premium numeric(10, 2) NOT NULL, -- starting premium before adjustments
    coverage_details text, -- details about what is covered (could be JSON or structured text)
    underwriting_rules text, -- rules used for assessing risk and eligibility
    is_active boolean NOT NULL DEFAULT true, -- whether the product is currently offered
    created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp,
    PRIMARY KEY (product_id)
)
CREATE TABLE insurance.claim_documents ( document_id character varying(64) NOT NULL, claim_id character varying(64) NOT NULL, document_type character varying(50) NOT NULL, file_name character varying(255) NOT NULL, file_path character varying(512) NOT NULL, file_size_bytes integer, mime_type character varying(100), uploaded_by character varying(64), uploaded_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, description text, PRIMARY KEY (document_id) )

[User] Show the total number of customers in each state.

[Assistant]
SELECT
  state,
  COUNT(customer_id)
FROM insurance.customers
GROUP BY
  state;